Nav Links
Sometimes you may want to add more links to your Starlight docs outside of the sidebar navigation. Starlight does not currently support this out of the box.
With this utility you can add a list of links to the Astro config and they will be rendered in the navigation bar in both desktop and mobile.
Setup
-
Add a new sidebar entry to the Starlight plugin in
astro.config.mjs
with anylabel
that will be used in a later step. -
Add a list of links to the
items
object in the newly added sidebar entry using the Starlight Links syntax.Currently Group and Autogenerated groups are not supported.
-
Add the
navLinks.leading.useSidebarLabelled
entry to the Starlight Utils plugin. Use the label created above foruseSidebarLabelled
.Be sure that you’ve added
import starlightUtils from "@lorenzo_lewis/starlight-utils"
to the top of the file. -
That’s it! ✨
Configuration
The sidebar can be enabled by adding the navLinks
object to the Starlight Utils configuration.
navLinks
Type: { leading: NavConfig } | undefined
Default: undefined
Enables the navigation links for the respective position.
NavConfig
Type: { useSidebarLabelled: string }
useSidebarLabelled
: The name of the sidebar defined in the Starlight config that should be used for generating the respective nav links.