Configuration
The Starlight Plugin Show 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 starlightPluginShowLatestVersion from "starlight-plugin-show-latest-version";
export default defineConfig({ integrations: [ starlight({ plugins: [ starlightPluginShowLatestVersion({ // Configuration options go here. }), ], title: "My Docs", }), ],});
Configuration options
The Starlight Plugin Show Latest Version plugin accepts the following configuration options:
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
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.
slug
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:
starlightPluginShowLatestVersion({ source: { type: "npm", slug: "starlight-plugin-show-latest-version", },}),
{owner}/{repo}
Here is an example for this exact repo:
starlightPluginShowLatestVersion({ source: { type: "github", slug: "trueberryless-org/starlight-plugin-show-latest-version", },}),
{owner}/{repo}
Here is an example for the GitLab repo:
starlightPluginShowLatestVersion({ source: { type: "gitlab", slug: "gitlab-org/gitlab", },}),
badge
Type: object
Default: { variant: "default", size: "medium" }
Customize the badge used to display the latest version of your Starlight plugin.
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.3size
Type: "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
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 node
pnpm astro add node
yarn astro add node
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 Plugin Show Latest Version plugin.
Read more about how the version tag is being extracted from the GitHub release here.