2

I'm using Docusaurus for building a documentation web-site for a project. The content is written as MDX files. Since the project has different versions I'd like to use links that contain the specific version. For example, for version 1.0 a link should look like this:

Please see [a link to the code](https://github.com/seladb/my-project/blob/v1.0/file)

And for version 2.0 the same link should look like this:

Please see [a link to the code](https://github.com/seladb/my-project/blob/v2.0/file)

I tried building a simple component inside /docs that returns the version string, and since it's inside /docs it is copied to the versioned_docs folder each time a new version is created:

export const Version = () => {
  return ("v1.0")
}

However I'm not sure how to use it in the MDX file. This doesn't work:

import {Version} from '/docs/Version'

Please see [a link to the code](https://github.com/seladb/my-project/blob/<Version></Version>/file.js)

Any idea what is the right way to do it?

seladb
  • 852
  • 1
  • 13
  • 29

0 Answers0