facebook / facebook/docusaurus

Allow linking to versioned docs from footer and page

Open
#7,402 7 comments 2 reactions 0 assignees View on GitHub
feature
Dominant language
TypeScript
Stars
66.2k
Forks
10k
Avg merge
1d 3h
Merged PRs (30d)
52

Description

### Have you read the Contributing Guidelines on issues?

- [X] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#reporting-new-issues).

### Prerequisites

- [X] I'm using the latest version of Docusaurus.
- [X] I have tried the `npm run clear` or `yarn clear` command.
- [X] I have tried `rm -rf node_modules yarn.lock package-lock.json` and re-installing packages.
- [X] I have tried creating a repro with https://new.docusaurus.io.
- [X] 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

1. In `docusaurus.config.js`, in the `docs` preset object, set `routeBasePath` to "/" and add the following object under `versions':
```json
current: {
label: 'v1',
path: 'v1'
}
```
2. 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.