content icon indicating copy to clipboard operation
content copied to clipboard

Support content in MDX format

Open septatrix opened this issue 1 year ago • 7 comments

Is your feature request related to a problem? Please describe

Other frameworks for authoring static content such as Docusaurus, Vuepress/Vitepress, or Astro.JS use either MDX or a format that is very similar to it. The biggest difference from the Markdown extensions Nuxt Content uses is that components are written using angle brackets (<>...</>) instead of double colons :: ... ::. This makes transitioning to Nuxt more annoying, especially as a simple regex is not sufficient. (Nesting is handled differently, and both Docusaurus and Vitepress support callout containers using triple colons which would conflict.)

Describe the solution you'd like

Support mdx files in addition to md files.

Describe alternatives you've considered

Update the current parser to use angle brackets instead of colons. This would certainly work too (and e.g. Vitepress still uses the .md extension though it is very close to MDX) but would break existing sites so it should only be done on a major version update. Alternatively this could be made configurable but using .mdx files seems like a simpler solution for now.

Additional context

I do not know the exact flow in which markdown is parsed, transformed and rendered in content though there exists a remark-mdx plugin. However, I am not sure if it is easily injectable into Nuxt Content based on the order in which all other transformations/plugins are executed.

septatrix avatar Jan 12 '24 15:01 septatrix

You can use global components (not auto-imported I think...) with HTML syntax in your Markdown, just as you would use them in Vue files. See https://github.com/nuxt/content/issues/2248#issuecomment-1696080218 You only have to make sure to not use self-closing tags, as they currently do not work.

nobkd avatar Jan 12 '24 20:01 nobkd

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Aug 19 '24 01:08 github-actions[bot]

still interested in this.

stefanprobst avatar Aug 19 '24 05:08 stefanprobst