How to use the netlify-cms.init function in netlify-cms

To help you get started, we’ve selected a few netlify-cms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github talves / netlify-cms-react-example / src / components / NetlifyCMS / index.js View on Github external
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() {
github talves / react-static-netlify-cms / src / containers / Admin / index.js View on Github external
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 =&gt; `<img alt="Youtube Video" src="http://img.youtube.com/vi/${obj.id}/maxresdefault.jpg">`,