Configuration
The Starlight Latest Version plugin can be configured inside the astro.config.mjs configuration file of your project:
import starlight from "@astrojs/starlight";import { defineConfig } from "astro/config";import starlightLatestVersion from "starlight-latest-version";
export default defineConfig({ integrations: [ starlight({ plugins: [ starlightLatestVersion({ // Configuration options go here. }), ], title: "My Docs", }), ],});Configuration options
Section titled “Configuration options”The Starlight Latest Version plugin accepts the following configuration options:
source
Section titled “source”Type: { type: "npm" | "github" | "gitlab", slug: string }
Required
Provide the source where your package is released. This is necessary to fetch the latest version of your package.
Type: "npm" | "github" | "gitlab"
Default: "npm"
The type of the source where your package is released.
You can choose between "npm", "github" or "gitlab". This allows you to better customise the plugin to where you publish and release your packages.
Type: string
Required
The slug of the source where your package is released.
Depending on the source type, the slug must follow the syntax:
{package}Here is an example for this exact package:
starlightLatestVersion({ source: { type: "npm", slug: "starlight-latest-version", },}),{owner}/{repo}Here is an example for this exact repo:
starlightLatestVersion({ source: { type: "github", slug: "trueberryless-org/starlight-latest-version", },}),{owner}/{repo}Here is an example for the GitLab repo:
starlightLatestVersion({ source: { type: "gitlab", slug: "gitlab-org/gitlab", },}),Type: object
Default: { variant: "default", size: "medium" }
Customize the badge used to display the latest version of your Starlight plugin.
variant
Section titled “variant”Type: "default" | "note" | "danger" | "success" | "caution" | "tip"
Default: "default"
The variant of the badge to use.
Here you can see how the different variants look like:
v1.2.3 v1.2.3 v1.2.3 v1.2.3 v1.2.3 v1.2.3Type: "small" | "medium" | "large"
Default: "medium"
The size of the badge to use.
Here you can see how the different sizes look like:
v1.2.3 v1.2.3 v1.2.3showInSiteTitle
Section titled “showInSiteTitle”Type: "false" | "true" | "deferred"
Default: "false"
Whether to show the latest version of your Starlight plugin in the site title. By default, the plugin does not show the latest version in the site title.
If you set this option to "true", the latest version will be displayed in the site title and the badge will be rendered at build time, no further configuration needed.
If you set this option to "deferred", the latest version will be displayed in the site title and the badge will be rendered at runtime. This is useful if you want to fetch the latest version on-demand. However, you will have to add a server adapter because the plugin override now uses server:defer in order to fetch the latest version of your package.
For example, you can add the Node adapter by running one of the following commands:
npx astro add nodepnpm astro add nodeyarn astro add noderegexPattern
Section titled “regexPattern”Type: string
Override the regex pattern used to extract the version from the tag_name of the latest release on GitHub.
This is useful if your tag_name does not follow best practice and only necessary in rare cases. Nonetheless, it’s supported by the Starlight Latest Version plugin.
Read more about how the version tag is being extracted from the GitHub release here.