Allow linking to versioned docs from footer and page
See original GitHub issueHave you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I’m using the latest version of Docusaurus.
- I have tried the
npm run clear
oryarn clear
command. - I have tried
rm -rf node_modules yarn.lock package-lock.json
and re-installing packages. - I have tried creating a repro with https://new.docusaurus.io.
- I have read the console error message carefully (if applicable).
Description
I’m expecting to be able to use links in pages (such as index.js
) and in the footer config to docs.
We would like to have all files under the docs
directory to be served at the root of the site. We would also like to have the URLs for all docs versioned, so we’re following the setup for the second use case described here: https://docusaurus.io/docs/versioning#configuring-versioning-behavior.
When doing this, the links on the included reproduction site on index.js
as well as the footer are broken.
Reproducible demo
https://stackblitz.com/edit/github-pryivb?file=docusaurus.config.js
Steps to reproduce
- In
docusaurus.config.js
, in thedocs
preset object, setrouteBasePath
to “/” and add the following object under `versions’:
current: {
label: 'v1',
path: 'v1'
}
- See how the footer link and the tutorial link on the index page are now broken
Expected behavior
Docusaurus should be able to build the urls similar to how it is in the navBar (by introducing an item option to the footer to be able to specify type: 'doc'
and docId: 'your-doc-id-here
. If there is not currently a way to reference a page like this from a non-doc page (such as index.js
), I would expect some sort of API from Docusaurus to allow it to build out this link dynamically (similar to how the navbar links are)
Actual behavior
The links to docs are broken (see Docs -> Tutorial in the footer and the “Docusaurus Tutorial - 5min” button link on index.js
)
Your environment
- Public source code: https://stackblitz.com/edit/github-pryivb?file=docusaurus.config.js
- Public site URL: https://github-pryivb--3000.local.webcontainer.io/
- Docusaurus version used: 2.0.0-beta.20
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Any browser, Node v16.14.2
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): Any
Self-service
- I’d be willing to fix this bug myself.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top GitHub Comments
👍 for DocLink as a public API and usable in footer.It can use
useLayoutDoc(docId, docsPluginId)
similarly to DocNavbarItemIt would be fine to replace the setup we have for NavbarItems because users may also want custom footer items later and we could also introduce other item types
That could work, yeah. If you want to make a POC, feel free to!