Comments (11)
You need to setup the control / preview as this isn't a builtin widget - https://www.netlifycms.org/docs/custom-widgets/#registerwidget
from gatsby-mdx.
Thanks, didn't notice that part of the README.
Put in a PR to add Gatsby instructions since the Netlify docs didn't cover the integration:
#49
from gatsby-mdx.
I did register the widget in my /src/cmd/cms.js
file but it doesn't work.
I get No preview for widget 'mdx'
and No control for widget 'mdx'
.
Any idea?
import { MdxControl, MdxPreview } from "netlify-cms-widget-mdx
CMS.registerWidget("mdx", MdxControl, MdxPreview)
Thanks in advance!
from gatsby-mdx.
@Knaackee a full configuration setup would help a little more.
from gatsby-mdx.
Oh iam sorry. It's working now.
from gatsby-mdx.
I'm having the same problem. I get both errors:
"No control for widget 'mdx'."
"No preview for widget 'mdx'."
cms.js
import CMS from "netlify-cms-app"
import { MdxControl, MdxPreview, setupPreview } from "netlify-cms-widget-mdx"
import {shortcodes} from "."
CMS.registerWidget('mdx', MdxControl, setupPreview({
components: shortcodes
}))
gatsby-config.js
module.exports = {
siteMetadata: {
title: `Gatsby Default Starter`,
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
author: `@gatsbyjs`,
},
plugins: [
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `markdown-pages`,
path: `${__dirname}/src/markdown-pages`,
}
},
{
resolve: "gatsby-plugin-page-creator",
options: {
path: `${__dirname}/src/markdown-pages`,
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `gatsby-starter-default`,
short_name: `starter`,
start_url: `/`,
background_color: `#663399`,
theme_color: `#663399`,
display: `minimal-ui`,
icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
},
},
{
resolve: `gatsby-plugin-mdx`,
options: {
defaultLayouts: {
default: require.resolve(`./src/page-templates/default-page.template.js`),
},
extensions: [`.mdx`, `.md`]
},
},
{
resolve: `gatsby-plugin-netlify-cms`,
options: {
modulePath: `${__dirname}/src/cms/cms.js`, // for custom preview in the Netlify CMS
},
},
// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,
],
}
config.yml
backend:
name: git-gateway
repo: avorg/audioverse-public-website
branch: gatsby
commit_messages:
create: 'Create {{collection}} “{{slug}}”'
update: 'Update {{collection}} “{{slug}}”'
delete: 'Delete {{collection}} “{{slug}}”'
uploadMedia: '[skip ci] Upload “{{path}}”'
deleteMedia: '[skip ci] Delete “{{path}}”'
media_folder: static/img
public_folder: /img
local_backend: true
collections:
- name: "blog"
label: "Blog"
folder: "src/pages/blog"
create: true
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
fields:
- {label: "Template Key", name: "templateKey", widget: "hidden", default: "blog-post"}
- {label: "Title", name: "title", widget: "string"}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Description", name: "description", widget: "text"}
- {label: "Featured Post", name: "featuredpost", widget: "boolean"}
- {label: "Featured Image", name: "featuredimage", widget: image}
- {label: "Body", name: "body", widget: "markdown"}
- {label: "Tags", name: "tags", widget: "list"}
- name: "pages"
label: "Pages"
folder: "src/markdown-pages"
create: true
slug: "{{slug}}"
format: "frontmatter"
fields:
- {label: "Template Key", name: "templateKey", widget: "hidden", default: "page"}
- {label: "Title", name: "title", widget: "string"}
- {label: "Slug", name: "slug", widget: "string"}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Description", name: "description", widget: "text"}
- {label: "Featured Image", name: "featuredimage", widget: "image"}
- {label: "Body", name: "body", widget: "mdx"}
from gatsby-mdx.
@narthur well your setup should be fine, though the error the error indicates that the CMS.registerWidget
wasn't even called. I suggest checking if the file get's executed and if the error persists maybe make a repo to test the issue.
from gatsby-mdx.
@karolis-sh Thanks for taking a look! I'm pretty new to Gatsby. What's the easiest way to ensure cms.js is getting executed?
from gatsby-mdx.
@narthur I guess just add a console.log statement and check the terminal when starting the Gatsby app - that should indicate that you provided the correct modulePath
value
from gatsby-mdx.
Yeah, console.log
is not showing up when I reload the gatsby app. I guess I'll work on debugging why the page isn't getting executed.
from gatsby-mdx.
Just confirmed that the file is getting run. I imported some CSS in cms.js and it was applied to the preview. But the errors persist.
from gatsby-mdx.
Related Issues (20)
- Create docs site
- Update support for @mdx-js/*@0.16.x
- Add components override mechanics via MDXProvider HOT 2
- Support alternative default export syntax
- Update @mdx-js/runtime version
- Unite with other Gatsby MDX? HOT 2
- [netlify-cms-widget-mdx] Broken compatibility with latest netlify-cms-app HOT 1
- Fix changelog links
- Fix preview image in npm
- Update to MDX v1
- Better editor widget HOT 4
- mdx widget invalid mdx HOT 1
- SyntaxError: Unterminated string constant
- Props spreading + props
- TypeError: Cannot read property 'validate' of undefined
- how to configure netlify-cms-widget-mdx with NextJS ? HOT 2
- styled-components throw `invalid hook call error` HOT 4
- Plugin gatsby-transformer-mdx is not compatible with your gatsby version 3.2.0 - It requires gatsby@^2 HOT 1
- process.cwd is not a function error for netlify-cms-widget-mdx HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gatsby-mdx.