Skip to content
Starlight Latest Version Loading...

Configuration

The Starlight Latest Version plugin can be configured inside the astro.config.mjs configuration file of your project:

astro.config.mjs
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",
}),
],
});

The Starlight Latest Version plugin accepts the following configuration options:

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:

Terminal window
{package}

Here is an example for this exact package:

starlightLatestVersion({
source: {
type: "npm",
slug: "starlight-latest-version",
},
}),

Type: object Default: { variant: "default", size: "medium" }

Customize the badge used to display the latest version of your Starlight plugin.

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.3

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.3

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:

Terminal window
npx astro add node

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.