Skip to content

[Feature Request] MDX Support #1776

Open
@swyxio

Description

@swyxio

See #2064 for technical requirements.

Is your feature request related to a problem? Please describe.

I want to use MDX with NetlifyCMS. But I can't.

Describe the solution you'd like

NetlifyCMS should:

  • detect my .mdx files
  • not attempt to WYSIWYG my mdx files, but it can render in the right pane

Describe alternatives you've considered

nil. vuepress was mentioned in another issue

Additional context

some background chat done between me and @erquhart on the netlify internal slack as well as cms channel: https://netlify.slack.com/archives/C1C30FQFM/p1537919621000100

so i converted the gatsby netlifycms template to use mdx: https://gatsby-starter-netlify-cms-with-mdx.netlify.com/
source: https://github.com/sw-yx/gatsby-starter-netlify-cms-1
however netlifycms just totally fails to recognize mdx files instead of md files. i think the problem comes in config.yml where it is just hardcoded to parse markdown
in particular this line https://github.com/sw-yx/gatsby-starter-netlify-cms-1/blob/master/static/admin/config.yml#L11
what do you folks think we should do here?

@verythorough:

The collection field accepts an extension sub-field, but mdx is not a valid value for that right now:
https://www.netlifycms.org/docs/configuration-options/#collections
If it was added, we'd also need to add an mdx parser of some kind. Markdown is currently parsed/generated with Slate & Remark

@erquhart:

However we do it, MDX will require a fair amount of effort within the CMS itself.
Your work made me realize mdx has it's own extension - if that's always the case, we may be able to tackle a lot of this at the format level, before the file content ever reaches the editor.
To wit, the CMS reads in files and parses them before storing them in state, so maybe mdx files get some extra state pointing to the components they import, and those are then made available to the editor, but the markdown string that's passed to the editor is stripped of those import/export statements.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions