1

I am having trouble getting netlify-cms-widget-mdx to work. For now, I just cloned the gatsby-starter-mdx, set up netlify cms 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`,
      },
    },
  • I'm not sure what I did wrong exactly. The error I get is (whenver I click on New Blog in the Netlify CMS) :

TypeError: Cannot read property 'validate' of undefined

My Blog Posts have the standard form of the gatsby starter. e.g. :

---
title: First Post MDX
date: 2020-02-03T18:47:01.270Z
description: A post on mdx
---
import Chart from '@components/Chart.js'

Welcome,
This is my first post on my new fake blog! How exciting! Here's MDX:

<Chart />

Bye!

Thanks a lot in advance!

MoazRub
  • 2,881
  • 2
  • 10
  • 20
  • am no expert in Gatsby but from the error I reckon you are missing a property that is required to create a new blog. Maybe go through the documentation again and see if you missed out a property that is required for a New blog. – automaticAllDramatic Feb 04 '20 at 09:23
  • 1
    For future people: I got the same error message when I had an invalid widget name (like `Image` instead of `image`). Maybe try commenting out all your `fields` and re-enabling them one-at-a-time? – Ed Brannin Feb 18 '20 at 18:22
  • Still development not done from dev team, https://github.com/netlify/netlify-cms/issues/1776 – Sivaraj-v Feb 15 '22 at 13:53

0 Answers0