Getting Started
Show the latest released version of your package in your documentation.
Prerequisites
You will need to have a Starlight website set up. If you don’t have one yet, you can follow the “Getting Started” guide in the Starlight docs to create one.
Installation
-
starlight-plugin-show-latest-version
is a Starlight plugin. Install it by running the following command in your terminal:Terminal window npm install starlight-plugin-show-latest-versionTerminal window pnpm add starlight-plugin-show-latest-versionTerminal window yarn add starlight-plugin-show-latest-version -
Configure the plugin in your Starlight configuration in the
astro.config.mjs
file.astro.config.mjs 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({source: {slug: "starlight-plugin-show-latest-version",},})],title: 'My Docs',}),],}) -
You can now use the plugin components in your Astro components or set the
showInSiteTitle
option to display the latest version in the site title. -
Start the development server to preview the plugin in action.
The Starlight Plugin Show Latest Version plugin behavior can be tweaked using various configuration options.
Component overrides
The Starlight Plugin Show Latest Version plugin uses a Starlight component override for the SiteTitle
component to add the VersionBadge
to the site title.
If you have a custom SiteTitle
component override in your Starlight project, you will need to manually render the DynamicVersionBadge
component from the Starlight Plugin Show Latest Version plugin in your custom component:
---import Default from '@astrojs/starlight/components/SiteTitle.astro'import DynamicVersionBadge from 'starlight-plugin-show-latest-version/components/DynamicVersionBadge.astro'---
<Default><slot /></Default><p>Custom content in the SiteTitle override</p><DynamicVersionBadge />