no
yes
I might be getting a bit carried away here, but keeping in mind #559 and #560, I think people might want a way to customize the slug from their side. The siteConfig.js option could look like this:
slug: 'unidecode' | 'uslug' | <customSlug function>
In line with docusaurus' idea to get started quickly, the two first string options would provide pre-configured slugs. Given a header like ## 汉čŻ/漢語
"unidecode" would generate the slug #yi-yu-han-yu"uslug" would generate #汉čŻćĽ˘čŞž.One of them would be the default.
The third option would be a custom callback giving the user total control over the slug output. I don't think this would make the code much more complex, as all the logic for this would be inside that toSlug.js file which would still just export one toSlug function to be used in the same way everywhere else.
I'd love to see something like this. My specific use case is for the Redux FAQ pages like https://redux.js.org/faq/actions . Right now, a header like this:
### How can I represent “side effects” such as AJAX calls? Why do we need things like “action creators”, “thunks”, and “middleware” to do async behavior?
Turns into a URL like:
https://redux.js.org/faq/actions#how-can-i-represent-side-effects-such-as-ajax-calls-why-do-we-need-things-like-action-creators-thunks-and-middleware-to-do-async-behavior
Which is unfortunately hideous and looks silly when you paste it elsewhere.
I'd originally worked around this when I first wrote the FAQ by adding hand-written "short anchor" tags right before each header, like <a id="actions-side-effects"></a>, and hand-writing the TOC links at the top using those anchors using URLs like https://redux.js.org/faq/actions#actions-side-effects`. That worked with our old version of Gitbook, but not the new one. Both current Gitbook and Docusaurus auto-generate a side TOC based on the header text.
Not a deal-breaker, but sure would be nice to have something like this.
I agree with @markerikson and am in the same boat. For common errors, I would even like to embed a link to where users can find help within the application itself, but that means I need to have stable slugs that I can guarantee won't change even if I decide to change the wording of the title.
We won't do this in v1. But this is doable in v2 by writing your own remark plugins/ rehype plugins to alter the slug. The docs functionality itself is a plugin in v2, so we won't do it in config.
Closing :)
Most helpful comment
I'd love to see something like this. My specific use case is for the Redux FAQ pages like https://redux.js.org/faq/actions . Right now, a header like this:
### How can I represent “side effects” such as AJAX calls? Why do we need things like “action creators”, “thunks”, and “middleware” to do async behavior?Turns into a URL like:
https://redux.js.org/faq/actions#how-can-i-represent-side-effects-such-as-ajax-calls-why-do-we-need-things-like-action-creators-thunks-and-middleware-to-do-async-behaviorWhich is unfortunately hideous and looks silly when you paste it elsewhere.
I'd originally worked around this when I first wrote the FAQ by adding hand-written "short anchor" tags right before each header, like
<a id="actions-side-effects"></a>, and hand-writing the TOC links at the top using those anchors using URLs like https://redux.js.org/faq/actions#actions-side-effects`. That worked with our old version of Gitbook, but not the new one. Both current Gitbook and Docusaurus auto-generate a side TOC based on the header text.Not a deal-breaker, but sure would be nice to have something like this.