Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for the .mdx format #7158

Open
Juniors017 opened this issue Mar 23, 2024 · 3 comments
Open

Support for the .mdx format #7158

Juniors017 opened this issue Mar 23, 2024 · 3 comments
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@Juniors017
Copy link

I'm using DecapCMS with Docusaurus, and like many other applications, Docusaurus utilizes .mdx files. I really wish that DecapCMS could support .mdx extensions.

@Juniors017 Juniors017 added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Mar 23, 2024
@mmkal
Copy link
Contributor

mmkal commented Mar 23, 2024

Proper .mdx support would be good, but for now you could use a custom formatter: https://decapcms.org/docs/custom-formatters

@Juniors017
Copy link
Author

Juniors017 commented Mar 26, 2024

hi
For now, I'm using this in my collections:

collections:
- name: docs
  label: Documentations
  label_singular: 'Documentation'
  folder: docs
  extension: "mdx" 
  format: "frontmatter"

It's functional.

Could you tell me more about the custom formatter? I'm not quite sure what it will bring to me. Maybe just for the preview? How do I create one for the .mdx format?

it's this code with gray-matter for exemple :

`const matter = require('gray-matter');
const { CMS } = require('mycollection'); 

CMS.registerCustomFormat('mdx', 'mdx', {
  fromFile: text => {
    const { data, content } = matter(text);
    return { frontmatter: data, content };
  },
  toFile: value => {
    const { frontmatter, content } = value;
    return matter.stringify(content, frontmatter);
  },
});`

@Juniors017
Copy link
Author

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

No branches or pull requests

2 participants