-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Find a way to link to category generated-index #6041
Comments
What about a new Firstly, I don't think generated category indexes will be linked to very often anyways, so we probably don't need special sugar for this. Then, the issue is only about how we can programmatically get the link to a doc plugin route, versioned. We have a similar need when we implemented the remark plugin to generate our API documentation: the link currently always links to the current version because the remark plugin is unaware of the version context. My idea is just a // The plugin baseUrl & version baseUrl will both be prepended
<a href={useVersionedLink('/category/guides')}>Guides</a> |
🤷♂️ I don't know, this makes sense to me to link to them and we already had the case for our own website. We'll see as category indexes grow in usage, for now relative links can be good enough for most users.
Also, I'm not sure we want to require users to use MDX/hooks to handle this use case inside markdown files. Maybe we could have a docs-only remark plugin and allow to just write If we know that 🤷♂️ that seems quite intuitive to me, but we can as well have a new protocol: Also, I'd find it interesting if our Link was a theme component. This would allow users to implement their own linking specific behaviors at runtime. |
Our docs plugin exports a lot of version-related hooks. This one is no special.
We do have a linkifier that transforms file paths to URLs. Maybe we can just use a sugar to indicate category indexes? (like |
Exposed in a not very elegant way BTW, not sure theming is the best for that. Maybe we should find a better solution like exposing these with https://nodejs.org/api/packages.html#package-entry-points Note those hooks are not publicly documented for the moment (neither is global data). The one you are suggesting is meant to be used by end-users so it's not exactly the same. I don't like magic protocols either but I don't really know how else to do without this. We also should think about users that will want to opt-out of MDX, and offer them a way to link to category index using plain MD GFM syntax |
For Uploady's doc site I wanted to link from navbar to an auto-generated category index and realized it wasn't possible. 😢 Luckily, found this issue and the useful comment along with docs explaining how to work around the limitation. But it definitely feels messy and over-doing something that should have been builtin and declarative. Sorry if too simplistic, but I was just expecting to have the option to specify a doc ID (in my sidebars.js) to the auto-generated index that I could link to. |
I just started out using docusaurus for an internal documentation hub and stumbled over the exact same issue. While writing the outline, I will just use hardcoded links (yikes) but, it would be awesome to just reference docs from the generated index via md, without any magic tricks, as @yoavniran mentioned. |
Have you read the Contributing Guidelines on issues?
Motivation
For docs, we recommend using relative file paths:
For our new category index feature, there is no
.md
file to link to so we must use regular links.Problem:
[Guides](/docs/next/category/guides).
trailingSlash
setting:[Guides](./category/guides).
This is particularly annoying for our own website, as we use different settings for dogfooding on dev/deployPreview/prod. It is not easy to find a good workaround so that our site could be deployed on every env without reporting broken links 😅 (see workaround ac44531)
It may be annoying for our users too.
We should probably find a way to link more easily to a category, but not sure how this should be done 🤷♂️
Self-service
The text was updated successfully, but these errors were encountered: