facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
54.07k stars 8.1k forks source link

Recma plugins support #10237

Closed pomber closed 1 week ago

pomber commented 1 week ago

TL;DR: Docusaurus supports remark and rehype plugins, but not recma plugins.


Have you read the Contributing Guidelines on issues?

Prerequisites

Description

I'm working on an example showing how to use Code Hike v1 + Docusaurus, but Docusaurus is missing the option to pass recma plugins that Code Hike needs.

Reproducible demo

https://github.com/code-hike/examples/pull/8

Actual behavior

The MDXOptions from @docusaurus/mdx-loader:

export type MDXOptions = {
  admonitions: boolean | Partial<AdmonitionOptions>;
  remarkPlugins: MDXPlugin[];
  rehypePlugins: MDXPlugin[];
  beforeDefaultRemarkPlugins: MDXPlugin[];
  beforeDefaultRehypePlugins: MDXPlugin[];
};

Expected behavior

export type MDXOptions = {
  admonitions: boolean | Partial<AdmonitionOptions>;
  remarkPlugins: MDXPlugin[];
  rehypePlugins: MDXPlugin[];
  recmaPlugins: MDXPlugin[]; // <-- code hike needs this
  beforeDefaultRemarkPlugins: MDXPlugin[];
  beforeDefaultRehypePlugins: MDXPlugin[];
};

recmaPlugins is already supported by the ProcessorOptions from @mdx-js/mdx v3.0.0 that @docusaurus/mdx-loader is using.

Your environment

slorber commented 1 week ago

👍 that should be easy to add

What I understand is that you need plugins (docs, blog, pages) to support a recmaPlugins option as well right? It's not just the mdx loader parameters.

pomber commented 1 week ago

What I understand is that you need plugins (docs, blog, pages) to support a recmaPlugins option as well right? It's not just the mdx loader parameters.

Yes! I clicked (go to definition) on the remarkPlugins option from the docusaurus config and it took me directly to the MDXOptions type. That's why I put it here.