Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
C
cmscenter
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
吕祺
cmscenter
Commits
fb3dc4ff
Commit
fb3dc4ff
authored
Aug 25, 2021
by
吕祺
⛹🏽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change video
parent
31f00599
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
8 deletions
+73
-8
post.js
pages/post.js
+2
-2
config.yml
static/admin/config.yml
+10
-6
index.html
static/admin/index.html
+61
-0
No files found.
pages/post.js
View file @
fb3dc4ff
...
...
@@ -77,8 +77,8 @@ export default class PostPage extends React.Component {
{
/* {yymmdd(new Date(post.createDate)).join('/')} */
}
<
/div
>
<
/div
>
{
post
.
video
&&
<
Video
id
=
"video"
src
=
{
post
.
video
}
poster
=
{
post
.
videoPoster
}
/>
}
{
/* {
post.video && <Video id="video" src={post.video}
poster={post.videoPoster}/>}
*/
}
<
div
className
=
"post-content"
dangerouslySetInnerHTML
=
{(()
=>
{
...
...
static/admin/config.yml
View file @
fb3dc4ff
backend
:
#
name: test-repo
name
:
gitlab
name
:
test-repo
#
name: gitlab
branch
:
master
repo
:
lq/cmscenter
auth_type
:
implicit
...
...
@@ -18,6 +18,10 @@ collections:
name
:
"
frontPage"
file
:
"
content/frontpage.md"
fields
:
-
name
:
categories
label
:
Categories
widget
:
categories
separator
:
__
-
{
label
:
"
RollImage1"
,
name
:
"
rollimage1"
,
widget
:
"
image"
}
-
{
label
:
"
RollImage2"
,
name
:
"
rollimage2"
,
widget
:
"
image"
,
required
:
false
}
-
{
label
:
"
RollImage3"
,
name
:
"
rollimage3"
,
widget
:
"
image"
,
required
:
false
}
...
...
@@ -188,11 +192,11 @@ collections:
-
{
label
:
"
Title"
,
name
:
"
title"
,
widget
:
"
string"
}
-
{
label
:
"
type"
,
name
:
"
type"
,
widget
:
"
string"
,
required
:
false
}
-
{
label
:
"
createDate"
,
name
:
"
createDate"
,
widget
:
"
datetime"
}
-
{
label
:
"
Abstract"
,
name
:
"
abstract"
,
widget
:
"
text"
,
required
:
false
}
#
- { label: "Abstract", name: "abstract", widget: "text", required: false }
-
{
label
:
"
content"
,
name
:
"
content"
,
widget
:
"
markdown"
}
-
{
label
:
"
coverpic"
,
name
:
"
coverpic"
,
widget
:
"
image"
,
required
:
false
}
-
{
label
:
"
video"
,
name
:
"
video"
,
widget
:
"
image"
,
required
:
false
}
-
{
label
:
"
videoPoster"
,
name
:
"
videoPoster"
,
widget
:
"
image"
,
required
:
false
}
#
- { label: "coverpic", name: "coverpic", widget: "image", required: false }
#
- { label: "video", name: "video", widget: "image", required: false }
#
- { label: "videoPoster", name: "videoPoster", widget: "image", required: false }
# - label: "RonghuiPage"
...
...
static/admin/index.html
View file @
fb3dc4ff
...
...
@@ -9,5 +9,66 @@
<body>
<!-- Include the script that builds the page and powers Netlify CMS -->
<script
src=
"./netlify-cms.js"
></script>
<script>
CMS
.
registerEditorComponent
({
// Internal id of the component
id
:
"Video"
,
// Visible label
label
:
"video"
,
// Fields the user need to fill out when adding an instance of the component
fields
:
[
{
name
:
'poster'
,
label
:
'poster'
,
widget
:
'image'
,
},
{
name
:
'urls'
,
label
:
'urls'
,
widget
:
'string'
}
],
// Regex pattern used to search for instances of this block in the markdown document.
// Patterns are run in a multline environment (against the entire markdown document),
// and so generally should make use of the multiline flag (`m`). If you need to capture
// newlines in your capturing groups, you can either use something like
// `([\S\s]*)`, or you can additionally enable the "dot all" flag (`s`),
// which will cause `(.*)` to match newlines as well.
//
// Additionally, it's recommended that you use non-greedy capturing groups (e.g.
// `(.*?)` vs `(.*)`), especially if matching against newline characters.
pattern
:
/^<urls>$
\s
*
?
<poster>
(
.*
?)
<
\/
poster>
\n\n(
.*
?)\n
^<
\/
urls>$/m
s
,
// Given a RegExp Match object
// (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match#return_value),
// return an object with one property for each field defined in `fields`.
//
// This is used to populate the custom widget in the markdown editor in the CMS.
fromBlock
:
function
(
match
)
{
return
{
summary
:
match
[
1
],
urls
:
match
[
2
]
};
},
// Given an object with one property for each field defined in `fields`,
// return the string you wish to be inserted into your markdown.
//
// This is used to serialize the data from the custom widget to the
// markdown document
toBlock
:
function
(
data
)
{
return
`
<video src="
${
data
.
urls
}
" poster="
${
data
.
poster
}
" controls="controls">
</video>
`
;
},
// Preview output for this component. Can either be a string or a React component
// (component gives better render performance)
toPreview
:
function
(
data
)
{
return
`
<video src="
${
data
.
urls
}
" poster="
${
data
.
poster
}
" controls="controls">
</video>
`
;
}
});
</script>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment