@zebradil/docs-kit 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -44,7 +44,7 @@ The repository root is the npm package [`@zebradil/docs-kit`](https://www.npmjs.
44
44
  <!-- x-release-please-start-version -->
45
45
  ```jsonc
46
46
  // package.json
47
- { "private": true, "type": "module", "dependencies": { "@zebradil/docs-kit": "0.11.0" } }
47
+ { "private": true, "type": "module", "dependencies": { "@zebradil/docs-kit": "0.12.0" } }
48
48
  ```
49
49
  <!-- x-release-please-end -->
50
50
 
@@ -80,7 +80,7 @@ versions:
80
80
  pin: [v1.4] # always, e.g. a long-term support line
81
81
  ```
82
82
 
83
- The default branch stays at the site root. Each selected minor version is rebuilt from its newest patch tag `vX.Y.Z` with the current kit at `/vX.Y/`, from the tag's `src/content/docs`, `src/assets` and `public/`, with `site.yaml` from the default branch. A version switcher appears in the header and marks the newest release, and release pages carry a banner linking to the current docs and are kept out of search engines. Links between pages stay within a version only when they are relative. The workflow builds the versions only when it deploys; a release that no longer builds is skipped with a warning. To try it locally, run `npx astro build && npx --no-install docs-kit-versions` from `docs/` and serve `dist/`. See [ADR 0008](docs/adr/0008-versioned-docs-from-release-tags.md).
83
+ The default branch stays at the site root. Each selected minor version is rebuilt from its newest patch tag `vX.Y.Z` with the current kit at `/vX.Y/`, from the tag's `src/content/docs`, `src/assets` and `public/`, with `site.yaml` from the default branch. A version switcher appears in the header and marks the newest release, a banner on every other version, the default branch's included, links to the latest release, and release pages are kept out of search engines. Links between pages stay within a version only when they are relative. The workflow builds the versions only when it deploys; a release that no longer builds is skipped with a warning. To try it locally, run `npx astro build && npx --no-install docs-kit-versions` from `docs/` and serve `dist/`. See [ADR 0008](docs/adr/0008-versioned-docs-from-release-tags.md).
84
84
 
85
85
  For coding agents and LLMs, every site serves [`/llms.txt`](https://llmstxt.org), an index of all pages, and `/llms-full.txt`, all pages in one file. Each page's Markdown source is also served at its URL with `.md` appended (`/guides/configure/` → `/guides/configure.md`), with relative links made absolute. GitHub Pages cannot vary a response on the `Accept` header, so the `.md` URLs are the only Markdown route.
86
86
 
@@ -97,7 +97,7 @@ on:
97
97
  permissions: { contents: read, pages: write, id-token: write }
98
98
  jobs:
99
99
  docs:
100
- uses: Zebradil/docs-kit/.github/workflows/docs.yml@v0.11.0
100
+ uses: Zebradil/docs-kit/.github/workflows/docs.yml@v0.12.0
101
101
  ```
102
102
  <!-- x-release-please-end -->
103
103
 
@@ -105,7 +105,7 @@ Keep `uses:` on its own indented line: Renovate's github-actions manager finds r
105
105
 
106
106
  The caller must grant `pages: write` and `id-token: write`: a called workflow can only narrow the caller's token permissions, never widen them, and the deploy job needs both.
107
107
 
108
- On every run it installs `docs/` with `npm ci`, builds the CLI with `reference.cli.build` (run from the repository root) when set, regenerates the CLI reference with `help2md` into `docs/src/content/docs/reference/cli`, and builds the site with `npx astro build` (which validates `site.yaml`). On a pull request it fails if the regenerated reference differs from the committed one and prints the diff. On a push to the default branch it builds the release versions when `versions:` is set and deploys `docs/dist` to GitHub Pages. A tag pushed with a workflow's `GITHUB_TOKEN` triggers no other workflow, so a new release shows up with the next deploy; to publish it at once, run the docs workflow on the default branch after the tag exists, for example from the release job.
108
+ On every run it installs `docs/` with `npm ci`, runs `prebuild` (from the repository root) when set, builds the CLI with `reference.cli.build` (run from the repository root) when set, regenerates the CLI reference with `help2md` into `docs/src/content/docs/reference/cli`, and builds the site with `npx astro build` (which validates `site.yaml`). On a pull request it fails if the regenerated reference differs from the committed one and prints the diff. On a push to the default branch it builds the release versions when `versions:` is set and deploys `docs/dist` to GitHub Pages. A tag pushed with a workflow's `GITHUB_TOKEN` triggers no other workflow, so a new release shows up with the next deploy; to publish it at once, run the docs workflow on the default branch after the tag exists, for example from the release job.
109
109
 
110
110
  Inputs, all optional:
111
111
 
@@ -114,6 +114,7 @@ Inputs, all optional:
114
114
  | `directory` | `docs` | Docs directory, relative to the repository root. |
115
115
  | `nix` | `false` | Install Nix first, for `build: nix build` and friends. |
116
116
  | `deploy` | `true` | Deploy on pushes to the default branch. |
117
+ | `prebuild` | | Shell command run from the repository root before the CLI build, for generated files the site serves, such as `docs/public/demo/`. Release versions keep the `public/` of their tag, so they do not get these files. |
117
118
 
118
119
  Runs on `ubuntu-latest`, which already has Rust (cargo, rustup) and Go (default version linked into `/usr/bin`; a newer `go` line in `go.mod` makes Go download that toolchain itself); see the [runner image tool list](https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md).
119
120
 
package/package.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "validate": "node schema/validate.mjs"
30
30
  },
31
31
  "dependencies": {
32
- "@astrojs/starlight": "0.42.10",
32
+ "@astrojs/starlight": "0.42.11",
33
33
  "@fontsource-variable/fraunces": "5.3.0",
34
34
  "@fontsource-variable/instrument-sans": "5.3.0",
35
35
  "@fontsource-variable/jetbrains-mono": "5.3.0",
@@ -40,5 +40,5 @@
40
40
  "astro": "7.4.11",
41
41
  "yaml": "2.9.1"
42
42
  },
43
- "version": "0.11.0"
43
+ "version": "0.12.0"
44
44
  }
@@ -3,17 +3,36 @@ import Default from '@astrojs/starlight/components/Banner.astro';
3
3
  import { root, version } from 'virtual:docs-kit/site';
4
4
  ---
5
5
 
6
- {
7
- version && (
8
- <div class="kit-version-banner" data-pagefind-ignore>
9
- These docs are for {version}. <a href={root}>Read the current docs</a>.
10
- </div>
11
- )
12
- }
6
+ {/* Filled from versions.json at runtime: which release is the latest changes after a release's docs are built. */}
7
+ <kit-version-banner class="kit-version-banner" data-root={root} data-version={version} data-pagefind-ignore hidden>
8
+ These docs are for <span></span>. <a>Read the docs of the latest release</a>.
9
+ </kit-version-banner>
13
10
  <Default />
14
11
 
12
+ <script>
13
+ customElements.define(
14
+ 'kit-version-banner',
15
+ class extends HTMLElement {
16
+ async connectedCallback() {
17
+ const { root, version } = this.dataset as { root: string; version: string };
18
+ const response = await fetch(`${root}versions.json`).catch(() => undefined);
19
+ if (!response?.ok) return;
20
+ const versions: { name: string; path: string; latest?: true }[] = await response.json();
21
+ const latest = versions.find((v) => v.latest);
22
+ const current = version && `${version}/`;
23
+ if (!latest || latest.path === current) return;
24
+ const branch = versions.find((v) => v.path === '')?.name;
25
+ this.querySelector('span')!.textContent = version || `the development version (${branch})`;
26
+ this.querySelector('a')!.href = root + latest.path;
27
+ this.hidden = false;
28
+ }
29
+ },
30
+ );
31
+ </script>
32
+
15
33
  <style>
16
- .kit-version-banner {
34
+ .kit-version-banner:not([hidden]) {
35
+ display: block;
17
36
  padding: var(--sl-nav-pad-y) var(--sl-nav-pad-x);
18
37
  background-color: var(--sl-color-bg-accent);
19
38
  color: var(--sl-color-text-invert);
@@ -41,5 +41,6 @@ import { root, version } from 'virtual:docs-kit/site';
41
41
  kit-versions:not([hidden]) {
42
42
  display: flex;
43
43
  align-items: center;
44
+ margin-inline-start: 1rem;
44
45
  }
45
46
  </style>