karolis-sh / gatsby-mdx

Utilities to work with MDX and netlify-cms in Gatsby sites
MIT License
60 stars 9 forks source link

TypeError: Cannot read property 'validate' of undefined #59

Closed jesterbeaver closed 4 years ago

jesterbeaver commented 4 years ago

Hi This is a really cool project! I am having trouble getting it to work though. For now, I just cloned the gatsby-starter-mdx, set up netlify and am now trying to add this widget.

My cms.js file looks as follows:

import CMS from 'netlify-cms-app'
import { MdxControl, MdxPreview } from 'netlify-cms-widget-mdx'

CMS.registerWidget('mdx', MdxControl, MdxPreview)

And I edited my config.yml as follows:

backend:
  name: git-gateway
  branch: master

media_folder: static/img
public_folder: /img

collections:
  - name: 'blog'
    label: 'Blog'
    folder: 'content/blog'
    create: true
    slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
    editor:
      preview: false
    extension: 'mdx'
    format: 'frontmatter'
    fields:
      - { label: 'Title', name: 'title', widget: 'string' }
      - { label: 'Publish Date', name: 'date', widget: 'datetime' }
      - { label: 'Description', name: 'description', widget: 'string' }
      - { label: 'Body', name: 'body', widget: 'mdx' }

Oh and in my gatsby-config

plugins: [
    {
      resolve: `gatsby-plugin-netlify-cms`,
      options: {
        modulePath: `${__dirname}/src/cms/cms.js`,
      },
    },

TypeError: Cannot read property 'validate' of undefined

Thanks a lot in advance!