Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount () {
console.log(`CMS [${process.env.NODE_ENV}]`, CMS, )
if (process.env.NODE_ENV === 'development') {
config.backend = {
"name": "file-system",
"api_root": "http://localhost:3000/api"
}
CMS.registerBackend('file-system', FileSystemBackend);
}
CMS.init({config});
CMS.registerPreviewTemplate('authors', AuthorsPreview);
CMS.registerEditorComponent(EditorYoutube);
}
render() {
constructor(props) {
super(props)
const CMSExport = require('netlify-cms')
const CMS = CMSExport.default
CMS.init = CMSExport.init
console.log('CMS stored in state of component Admin', CMS)
this.state = {
CMS,
}
CMS.registerPreviewStyle('/admin/site.css')
CMS.registerPreviewTemplate('docs', DocumentPreview)
CMS.registerEditorComponent({
id: 'youtube',
label: 'Youtube',
fields: [{ name: 'id', label: 'Youtube Video ID' }],
pattern: /^{{<\s?youtube (\S+)\s?>}}/,
fromBlock: match => ({
id: match[1],
}),
toBlock: obj => `{{< youtube ${obj.id} >}}`,
toPreview: obj => `<img alt="Youtube Video" src="http://img.youtube.com/vi/${obj.id}/maxresdefault.jpg">`,