Commit fb3dc4ff authored by 吕祺's avatar 吕祺 ⛹🏽

change video

parent 31f00599
......@@ -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={(() => {
......
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"
......
......@@ -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>$/ms,
// 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment