-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
Add option to maintain case for generated heading ids #7946
Copy link
Copy link
Closed
Labels
apprenticeIssues that are good candidates to be handled by a Docusaurus apprentice / traineeIssues that are good candidates to be handled by a Docusaurus apprentice / traineedomain: markdownRelated to Markdown parsing or syntaxRelated to Markdown parsing or syntaxfeatureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Metadata
Metadata
Assignees
Labels
apprenticeIssues that are good candidates to be handled by a Docusaurus apprentice / traineeIssues that are good candidates to be handled by a Docusaurus apprentice / traineedomain: markdownRelated to Markdown parsing or syntaxRelated to Markdown parsing or syntaxfeatureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Have you read the Contributing Guidelines on issues?
Description
We are migrating from a custom docs implementation to Docusaurus and need to maintain the case consistency of our current headings in our docs for external links currently pointed at our docs.
We thought about using the custom header ids, but we have a lot and it adds a lot of cruft to the md files and will have to added to each new header moving forward to maintain consistency.
It would be nice to have an option specified in docusaurus.config.js that will pass in
maintainCaseto the github slugger to preserve the casing of the heading anchors.Has this been requested on Canny?
https://docusaurus.io/feature-requests/p/add-option-to-keep-capitalization-in-generated-heading-ids (older one but pretty much same request)
Motivation
Its been requested before (link in the canny inpuyt), and the answer was the custom header ids. That feature is great for a handful of custom links, but it would be great to turn this option on and it would eliminate the need to have to specify a custom id on each of our headings.
API design
Have a config option named
maintainHeaderCasingthat will be specified in the config file. This option will need to be passed down and passed as an option to the slugger here:https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-mdx-loader/src/remark/headings/index.ts#L39
Have you tried building it?
Yes, we've patched it locally for our current needs by hard coding
maintainCasingin the options to true here:https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-mdx-loader/src/remark/headings/index.ts#L39
I'd be willing to contribute a fully working solution passing in the config option as well. I'll just need to figure out how to access the config from here.
Self-service