Gatsby-MDX + Netlify-CMS-Widget-MDX-TypeError:无法读取未定义的属性“ validate”

时间:2020-02-04 09:17:34

标签: javascript gatsby netlify netlify-cms

我无法让netlify-cms-widget-mdx工作。现在,我只是克隆了gatsby-starter-mdx,设置了netlify cms,现在正尝试添加此小部件。

我的cms.js文件如下所示:

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

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

然后按如下所示编辑config.yml:

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' }

哦,在我的gatsby-config

plugins: [
    {
      resolve: `gatsby-plugin-netlify-cms`,
      options: {
        modulePath: `${__dirname}/src/cms/cms.js`,
      },
    },
  • 我不确定我做错了什么。我得到的错误是(每当我在Netlify CMS中单击New Blog时):

TypeError:无法读取未定义的属性“ validate”

“我的博客文章”具有gatsby启动程序的标准格式。例如:

---
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!

非常感谢!

0 个答案:

没有答案