Keep the docs of each release
The theme works with the Starlight plugin
starlight-versions. The docs of each
earlier release stay at /<version>/, and a version select shows next to the
theme select. This site uses it: the select shows Latest and v0.1.
Procedure
Section titled “Procedure”-
Install the plugin in the site:
Terminal window npm install starlight-versions -
In
src/content.config.ts, add theversionscollection:import { docsVersionsLoader } from 'starlight-versions/loader';export const collections = {docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),versions: defineCollection({ loader: docsVersionsLoader() }),}; -
In
astro.config.mjs, add the plugin afterstarlightAurora(). Give it the release that the docs show now:import starlightVersions from 'starlight-versions';plugins: [starlightAurora({ hyper: true }),starlightVersions({ versions: [{ slug: '1.0' }] }),], -
Build the site. The first build with a new version copies the current docs into
src/content/docs/1.0/and writessrc/content/versions/1.0.json. -
Compare the copy with the current pages, and commit the new files. From now on, change only the current docs.
starlight-versions writes the copied pages again without GitHub tables’ escapes, and reads them as MDX:
\|in a table cell splits the cell, and<,{or}in text stops the build. Fix the copy by hand, or copy the source pages over it and add theslug:line that it wrote. -
At the next release, add its slug at the start of
versionsand build again.
Old versions from before the move
Section titled “Old versions from before the move”A Pages deploy from a workflow replaces the whole site. To keep an old version folder that the new site does not build (an mdBook copy, for example), build it in the docs workflow on each deploy and put it in the uploaded site, as GraphQLite does for its v0.9.2 mdBook docs.
With hyper
Section titled “With hyper”starlight-versions and hyper both replace Starlight’s theme select. With
hyper: true, starlight-aurora shows the version select in its own theme
select, in either order of the two plugins. The build then prints this warning
from starlight-versions. You can ignore it:
A `<ThemeSelect>` component override is already defined in your Starlight configuration.