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

Replace remark-includes with MDX imports #20

Open
ptgott opened this issue Nov 1, 2024 · 0 comments
Open

Replace remark-includes with MDX imports #20

ptgott opened this issue Nov 1, 2024 · 0 comments

Comments

@ptgott
Copy link
Contributor

ptgott commented Nov 1, 2024

The Docusaurus site currently configures the remark-includes plugin to transform content before we build the site. This uses a lot of custom logic that we can replace with MDX-native imports, including both importing Markdown and importing code snippet content.

We can write a script that replaces our (!path!) syntax with:

  • An import statement at the top of the including page
  • A React-style component tag pair at the site of the (!path!) expression

Then we can run the script once for all of our partials.

We can also replace our home-grown parameter substitution logic with something like {props.name} in the Docusaurus Markdown import example.

Ideally, this will also mean that we don't have to invoke remark-includes in order to lint partials, since remark won't exit with an error as it does when it encounters our {{ param="value" }} syntax, and can lint these files as regular MDX documents. This will reduce the time it takes our remark linter to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant