@knitli/astro-docs-template 0.4.4 → 0.4.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knitli/astro-docs-template",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "Opinionated Astro + Starlight docs site template with Knitli branding",
5
5
  "keywords": [
6
6
  "knitli",
@@ -45,23 +45,24 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@astrojs/check": "^0.9.6",
48
- "@astrojs/cloudflare": "^13.1.7",
48
+ "@astrojs/cloudflare": "^13.1.8",
49
49
  "@astrojs/compiler-rs": "^0.1.6",
50
50
  "@astrojs/markdoc": "^1.0.0",
51
51
  "@astrojs/mdx": "^5.0.3",
52
52
  "@astrojs/sitemap": "^3.7.2",
53
- "@astrojs/starlight": "^0.38.2",
53
+ "@astrojs/starlight": "^0.38.3",
54
54
  "@biomejs/biome": "^2.4.2",
55
55
  "@knitli/docs-components": "*",
56
56
  "@knitli/tsconfig": "*",
57
- "@nuasite/llm-enhancements": "^0.19.1",
57
+ "@nuasite/llm-enhancements": "^0.23.0",
58
58
  "@types/bun": "^1.3.4",
59
- "@types/node": "^24.0.2",
60
- "astro": "^6.1.4",
59
+ "@types/mdast": "^4.0.4",
60
+ "@types/node": "^24.12.2",
61
+ "astro": "^6.1.5",
61
62
  "astro-cloudflare-pages-headers": "^1.7.7",
62
63
  "astro-d2": "^0.10.0",
63
64
  "astro-favicons": "3.1.6",
64
- "bun": "^1.3.9",
65
+ "bun": "^1.3.11",
65
66
  "lightningcss": "^1.30.2",
66
67
  "postcss": "8.5.6",
67
68
  "postcss-nesting": "^14.0.0",
@@ -78,7 +79,8 @@
78
79
  "starlight-sidebar-topics": ">=0.7.1",
79
80
  "starlight-tags": ">=0.4.0",
80
81
  "svgo": "^4.0.0",
81
- "vite": "^7.3.1",
82
+ "unist-util-visit": "^5.1.0",
83
+ "vite": "^7.3.2",
82
84
  "vite-tsconfig-paths": "6.1.1"
83
85
  },
84
86
  "devDependencies": {
package/src/config.ts CHANGED
@@ -36,6 +36,7 @@ import starlightSidebarTopics from "starlight-sidebar-topics";
36
36
  import starlightTags from "starlight-tags";
37
37
  import { searchForWorkspaceRoot } from "vite";
38
38
  import viteTsconfigPaths from "vite-tsconfig-paths";
39
+ import { remarkVersion } from "./remarkPlugin.js";
39
40
 
40
41
  type defaultIntegration =
41
42
  | "sitemap"
@@ -460,6 +461,7 @@ export default async function createConfig(options: DocsTemplateOptions) {
460
461
  { content: { type: "text", value: " ↗" }, rel: ["nofollow"] },
461
462
  ],
462
463
  ],
464
+ remarkPlugins: [remarkVersion],
463
465
  },
464
466
  server: {
465
467
  headers: { ...defaultHeadersConfig, ...headersConfig },
@@ -472,6 +474,9 @@ export default async function createConfig(options: DocsTemplateOptions) {
472
474
  allow: [searchForWorkspaceRoot(rootDir)],
473
475
  },
474
476
  },
477
+ optimizeDeps: {
478
+ exclude: [""],
479
+ },
475
480
  assetsInclude: [
476
481
  "src/*.webp",
477
482
  "src/*.png",
@@ -0,0 +1,59 @@
1
+ // SPDX-FileCopyrightText: 2026 Knitli Inc.
2
+ //
3
+ // SPDX-License-Identifier: MIT OR Apache-2.0
4
+
5
+ /**
6
+ * Remark plugin that replaces {{VERSION}} tokens in markdown content
7
+ * with the current version derived from `git describe`.
8
+ *
9
+ * Runs at build time — no runtime cost.
10
+ */
11
+
12
+ import { execFileSync } from "node:child_process";
13
+ import type { Root, Text } from "mdast";
14
+ import { visit } from "unist-util-visit";
15
+
16
+ let cachedVersion: string | undefined;
17
+
18
+ function getVersion(): string {
19
+ if (cachedVersion !== undefined) return cachedVersion;
20
+
21
+ try {
22
+ const raw = execFileSync("git", ["describe", "--tags", "--always"], {
23
+ encoding: "utf-8",
24
+ timeout: 5000,
25
+ }).trim();
26
+
27
+ // Convert git describe output to clean version:
28
+ // v0.2.0 -> 0.2.0
29
+ // v0.2.0-3-gabcdef -> 0.2.0-dev
30
+ // v0.1.0-alpha.5-103-gabcdef -> 0.1.0-dev
31
+ // v0.2.0-beta.1 -> 0.2.0-beta.1
32
+ const match = raw.match(
33
+ /^v?(\d+\.\d+\.\d+)(?:-[a-z]+\.\d+)?(?:-(\d+)-g[a-f0-9]+)?$/,
34
+ );
35
+ if (match) {
36
+ const baseVersion = match[1];
37
+ const commitDistance = match[2];
38
+ cachedVersion = commitDistance ? `${baseVersion}-dev` : baseVersion;
39
+ } else {
40
+ cachedVersion = raw.replace(/^v/, "");
41
+ }
42
+ } catch {
43
+ cachedVersion = "0.0.0-unknown";
44
+ }
45
+
46
+ return cachedVersion || "0.0.0-unknown";
47
+ }
48
+
49
+ export function remarkVersion(): (tree: Root) => void {
50
+ return (tree: Root) => {
51
+ const version = getVersion();
52
+
53
+ visit(tree, "text", (node: Text) => {
54
+ if (node.value.includes("{{VERSION}}")) {
55
+ node.value = node.value.replaceAll("{{VERSION}}", version);
56
+ }
57
+ });
58
+ };
59
+ }