Xref (Astro)

Xref (Astro)

Reference documents within the same repository.

:choco-info: Astro Only Documentation Below for docs.chocolatey.org

The documentation below covers how to use the <Xref /> Astro Component on docs.chocolatey.org. At this time, this Component is only available on docs.chocolatey.org.

Overview

The <Xref /> Component aims to give a way to link to documents within the same repository where the url will always work even if the file location changes. In the frontmatter of a .mdx or .md file, an xref key is assigned. When the files are compiled, the xref translates into an <a /> link. Things to know:

  • xref keys can never change once assigned.
  • No two files can have the same xref.
  • An xref key is required.

Define the Xref

--- order: 1 xref: example-define title: Define Xref description: An example of how to define the Xref Component ---

Use the Xref in another file

--- order: 2 xref: example-usage title: Use Xref description: An example of how to use the Xref Component --- import Xref from '@components/Xref.astro'; This is how you can .

The <Xref /> Component accepts an anchor="value" where the value is the Id of the anchor to target.

--- order: 3 xref: example-usage-with-anchor title: Use an Xref with an Anchor description: An example of how to use the Xref Component with an anchor. --- import Xref from '@components/Xref.astro'; This is how you can .