@knitli/astro-docs-template 0.1.2 → 0.2.1
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 +49 -48
- package/scaffolding/package.json +1 -2
- package/{dist/cli.js → src/cli.ts} +84 -34
- package/{dist/config.js → src/config.ts} +249 -163
- package/{dist/index.js → src/index.ts} +127 -35
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/config.d.ts +0 -59
- package/dist/config.d.ts.map +0 -1
- package/dist/index.d.ts +0 -69
- package/dist/index.d.ts.map +0 -1
|
@@ -1,43 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import sitemap from '@astrojs/sitemap';
|
|
5
|
-
import starlight from '@astrojs/starlight';
|
|
6
|
-
import { DocsAssets } from '@knitli/docs-components';
|
|
7
|
-
import llmEnhancements from '@nuasite/llm-enhancements';
|
|
8
|
-
import { fontProviders, defineConfig } from 'astro/config';
|
|
9
|
-
import cloudflarePagesHeaders from 'astro-cloudflare-pages-headers';
|
|
10
|
-
import astroD2 from 'astro-d2';
|
|
11
|
-
import favicons from 'astro-favicons';
|
|
12
|
-
import rehypeExternalLinks from 'rehype-external-links';
|
|
13
|
-
import starlightAnnouncement from 'starlight-announcement';
|
|
14
|
-
import starlightChangelogs from 'starlight-changelogs';
|
|
15
|
-
import starlightHeadingBadges from 'starlight-heading-badges';
|
|
16
|
-
import starlightLinksValidator from 'starlight-links-validator';
|
|
17
|
-
import starlightLlmsText from 'starlight-llms-txt';
|
|
18
|
-
import starlightPageActions from 'starlight-page-actions';
|
|
19
|
-
import { starlightIconsIntegration, starlightIconsPlugin } from 'starlight-plugin-icons';
|
|
20
|
-
import starlightScrollToTop from 'starlight-scroll-to-top';
|
|
21
|
-
import starlightSidebarTopics from 'starlight-sidebar-topics';
|
|
22
|
-
import starlightTags from 'starlight-tags';
|
|
23
|
-
import { searchForWorkspaceRoot } from 'vite';
|
|
24
|
-
import viteTsconfigPaths from 'vite-tsconfig-paths';
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Knitli Inc.
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
25
4
|
|
|
26
|
-
|
|
5
|
+
// @ts-check
|
|
6
|
+
|
|
7
|
+
import type { OutgoingHttpHeaders } from "node:http2";
|
|
8
|
+
import cloudflare from "@astrojs/cloudflare";
|
|
9
|
+
import markdoc from "@astrojs/markdoc";
|
|
10
|
+
import mdx from "@astrojs/mdx";
|
|
11
|
+
import sitemap from "@astrojs/sitemap";
|
|
12
|
+
import starlight from "@astrojs/starlight";
|
|
13
|
+
import { DocsAssets } from "@knitli/docs-components";
|
|
14
|
+
import llmEnhancements from "@nuasite/llm-enhancements";
|
|
15
|
+
import { defineConfig, fontProviders } from "astro/config";
|
|
16
|
+
import cloudflarePagesHeaders from "astro-cloudflare-pages-headers";
|
|
17
|
+
import astroD2 from "astro-d2";
|
|
18
|
+
import favicons from "astro-favicons";
|
|
19
|
+
import rehypeExternalLinks from "rehype-external-links";
|
|
20
|
+
import starlightAnnouncement from "starlight-announcement";
|
|
21
|
+
import starlightChangelogs from "starlight-changelogs";
|
|
22
|
+
import starlightHeadingBadges from "starlight-heading-badges";
|
|
23
|
+
import starlightLinksValidator from "starlight-links-validator";
|
|
24
|
+
import starlightLlmsText from "starlight-llms-txt";
|
|
25
|
+
import starlightPageActions from "starlight-page-actions";
|
|
26
|
+
import {
|
|
27
|
+
starlightIconsIntegration,
|
|
28
|
+
starlightIconsPlugin,
|
|
29
|
+
} from "starlight-plugin-icons";
|
|
30
|
+
import starlightScrollToTop from "starlight-scroll-to-top";
|
|
31
|
+
import starlightSidebarTopics from "starlight-sidebar-topics";
|
|
32
|
+
import starlightTags from "starlight-tags";
|
|
33
|
+
import { searchForWorkspaceRoot } from "vite";
|
|
34
|
+
import viteTsconfigPaths from "vite-tsconfig-paths";
|
|
35
|
+
|
|
36
|
+
type defaultIntegration =
|
|
37
|
+
| "sitemap"
|
|
38
|
+
| "astroD2"
|
|
39
|
+
| "markdoc"
|
|
40
|
+
| "mdx"
|
|
41
|
+
| "favicons"
|
|
42
|
+
| "cloudflare-pages-headers";
|
|
43
|
+
|
|
44
|
+
function nonNullable<T>(value: T): value is NonNullable<T> {
|
|
27
45
|
return value != null;
|
|
28
46
|
}
|
|
29
|
-
|
|
47
|
+
|
|
48
|
+
// ── Defaults (defined before interface so `typeof` references work) ──
|
|
49
|
+
|
|
50
|
+
export const {
|
|
30
51
|
headlineLogoDark,
|
|
31
52
|
headlineLogoLight,
|
|
32
53
|
variables,
|
|
33
54
|
docsStyle,
|
|
34
55
|
faviconIco,
|
|
35
|
-
faviconSvg
|
|
56
|
+
faviconSvg,
|
|
36
57
|
} = DocsAssets;
|
|
58
|
+
|
|
37
59
|
const shikiCfg = {
|
|
38
60
|
themes: {
|
|
39
|
-
light: "catppuccin-latte",
|
|
40
|
-
dark: "catppuccin-mocha"
|
|
61
|
+
light: "catppuccin-latte" as const,
|
|
62
|
+
dark: "catppuccin-mocha" as const,
|
|
41
63
|
},
|
|
42
64
|
bundledLangs: [
|
|
43
65
|
"ansi",
|
|
@@ -49,7 +71,7 @@ const shikiCfg = {
|
|
|
49
71
|
"rust",
|
|
50
72
|
"toml",
|
|
51
73
|
"typescript",
|
|
52
|
-
"yaml"
|
|
74
|
+
"yaml",
|
|
53
75
|
],
|
|
54
76
|
langAlias: {
|
|
55
77
|
js: "typescript",
|
|
@@ -57,61 +79,64 @@ const shikiCfg = {
|
|
|
57
79
|
py: "python",
|
|
58
80
|
rs: "rust",
|
|
59
81
|
sh: "bash",
|
|
60
|
-
yml: "yaml"
|
|
61
|
-
}
|
|
82
|
+
yml: "yaml",
|
|
83
|
+
},
|
|
62
84
|
};
|
|
85
|
+
|
|
63
86
|
const imgDomains = [
|
|
64
87
|
{ protocol: "https", hostname: "ui-avatars.com" },
|
|
65
88
|
{ protocol: "https", hostname: "knitli.com" },
|
|
66
89
|
{ protocol: "https", hostname: "*.knitli.com" },
|
|
67
90
|
{ protocol: "https", hostname: "*.githubusercontent.com" },
|
|
68
|
-
{ protocol: "https", hostname: "*.cloudflare.com" }
|
|
91
|
+
{ protocol: "https", hostname: "*.cloudflare.com" },
|
|
69
92
|
];
|
|
93
|
+
|
|
70
94
|
const defaultFontConfig = [
|
|
71
95
|
{
|
|
72
96
|
provider: fontProviders.google(),
|
|
73
97
|
name: "DM Mono",
|
|
74
98
|
cssVariable: "--font-sans",
|
|
75
|
-
weights: [400, 500, 700],
|
|
76
|
-
styles: ["normal", "italic"],
|
|
77
|
-
subsets: ["latin"],
|
|
78
|
-
formats: ["woff2"],
|
|
99
|
+
weights: [400, 500, 700] as [number, ...number[]],
|
|
100
|
+
styles: ["normal", "italic"] as [string, ...string[]],
|
|
101
|
+
subsets: ["latin"] as [string, ...string[]],
|
|
102
|
+
formats: ["woff2"] as [string, ...string[]],
|
|
79
103
|
fallbacks: [
|
|
80
104
|
"Roboto Mono",
|
|
81
105
|
"Menlo",
|
|
82
106
|
"Consolas",
|
|
83
107
|
"DejaVu Sans Mono",
|
|
84
|
-
"monospace"
|
|
85
|
-
]
|
|
108
|
+
"monospace",
|
|
109
|
+
],
|
|
86
110
|
},
|
|
87
111
|
{
|
|
88
112
|
provider: fontProviders.google(),
|
|
89
113
|
name: "JetBrains Mono",
|
|
90
114
|
cssVariable: "--font-mono",
|
|
91
|
-
weights: [400, 500, 700],
|
|
92
|
-
styles: ["normal", "italic"],
|
|
93
|
-
subsets: ["latin"],
|
|
94
|
-
formats: ["woff2"],
|
|
115
|
+
weights: [400, 500, 700] as [number, ...number[]],
|
|
116
|
+
styles: ["normal", "italic"] as [string, ...string[]],
|
|
117
|
+
subsets: ["latin"] as [string, ...string[]],
|
|
118
|
+
formats: ["woff2"] as [string, ...string[]],
|
|
95
119
|
fallbacks: [
|
|
96
120
|
"DM Mono",
|
|
97
121
|
"Roboto Mono",
|
|
98
122
|
"Menlo",
|
|
99
123
|
"Consolas",
|
|
100
124
|
"DejaVu Sans Mono",
|
|
101
|
-
"monospace"
|
|
102
|
-
]
|
|
103
|
-
}
|
|
125
|
+
"monospace",
|
|
126
|
+
],
|
|
127
|
+
},
|
|
104
128
|
];
|
|
129
|
+
|
|
105
130
|
const codeweaverFontConfig = [
|
|
106
131
|
{ ...defaultFontConfig[1], cssVariable: "--font-sans" },
|
|
107
132
|
{
|
|
108
133
|
provider: fontProviders.google(),
|
|
109
134
|
name: "IBM Plex Mono",
|
|
110
135
|
cssVariable: "--font-mono",
|
|
111
|
-
weights: [400, 500, 700],
|
|
112
|
-
styles: ["normal", "italic"],
|
|
113
|
-
subsets: ["latin"],
|
|
114
|
-
formats: ["woff2"],
|
|
136
|
+
weights: [400, 500, 700] as [number, ...number[]],
|
|
137
|
+
styles: ["normal", "italic"] as [string, ...string[]],
|
|
138
|
+
subsets: ["latin"] as [string, ...string[]],
|
|
139
|
+
formats: ["woff2"] as [string, ...string[]],
|
|
115
140
|
fallbacks: [
|
|
116
141
|
"JetBrains Mono",
|
|
117
142
|
"DM Mono",
|
|
@@ -119,16 +144,53 @@ const codeweaverFontConfig = [
|
|
|
119
144
|
"Menlo",
|
|
120
145
|
"Consolas",
|
|
121
146
|
"DejaVu Sans Mono",
|
|
122
|
-
"monospace"
|
|
123
|
-
]
|
|
124
|
-
}
|
|
147
|
+
"monospace",
|
|
148
|
+
],
|
|
149
|
+
},
|
|
125
150
|
];
|
|
126
|
-
|
|
151
|
+
|
|
152
|
+
// ── Public interface ──
|
|
153
|
+
|
|
154
|
+
export interface DocsTemplateOptions {
|
|
155
|
+
appName: string;
|
|
156
|
+
description: string;
|
|
157
|
+
llmConfig: {
|
|
158
|
+
llmDescription: string;
|
|
159
|
+
promotePatterns: string[];
|
|
160
|
+
demotePatterns: string[];
|
|
161
|
+
};
|
|
162
|
+
rootDir: string;
|
|
163
|
+
shikiConfig?: typeof shikiCfg;
|
|
164
|
+
logoDark?: string;
|
|
165
|
+
logoLight?: string;
|
|
166
|
+
imageDomains?: typeof imgDomains;
|
|
167
|
+
is_codeweaver?: boolean;
|
|
168
|
+
sitemapFilter?: (page: string) => boolean;
|
|
169
|
+
linkValidationConfig?: Record<string, unknown>;
|
|
170
|
+
sidebarConfig?: {
|
|
171
|
+
label: string;
|
|
172
|
+
autogenerate: { directory: string };
|
|
173
|
+
}[];
|
|
174
|
+
unwantedPlugins?: string[];
|
|
175
|
+
// biome-ignore lint/suspicious/noExplicitAny: plugin configs are opaque pass-throughs
|
|
176
|
+
pluginConfigs?: Record<string, any>;
|
|
177
|
+
unwantedIntegrations?: defaultIntegration[];
|
|
178
|
+
// biome-ignore lint/suspicious/noExplicitAny: integration configs are opaque pass-throughs
|
|
179
|
+
integrationConfigs?: Record<string, any>;
|
|
180
|
+
headersConfig?: OutgoingHttpHeaders;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export type IntegrationOptions = Pick<
|
|
184
|
+
DocsTemplateOptions,
|
|
185
|
+
"appName" | "sitemapFilter" | "integrationConfigs"
|
|
186
|
+
> & { unwantedIntegrations?: defaultIntegration[] };
|
|
187
|
+
|
|
188
|
+
const getIntegrations = (options: IntegrationOptions) => {
|
|
127
189
|
const {
|
|
128
190
|
appName,
|
|
129
191
|
sitemapFilter,
|
|
130
192
|
integrationConfigs,
|
|
131
|
-
unwantedIntegrations = []
|
|
193
|
+
unwantedIntegrations = [],
|
|
132
194
|
} = options;
|
|
133
195
|
const defaultIntegrations = [
|
|
134
196
|
astroD2({ skipGeneration: true }),
|
|
@@ -139,45 +201,57 @@ const getIntegrations = (options) => {
|
|
|
139
201
|
name: `${appName} Docs by Knitli`,
|
|
140
202
|
short_name: `${appName} Docs`,
|
|
141
203
|
input: {
|
|
142
|
-
favicons: [faviconSvg]
|
|
143
|
-
}
|
|
204
|
+
favicons: [faviconSvg],
|
|
205
|
+
},
|
|
144
206
|
}),
|
|
145
207
|
cloudflarePagesHeaders({}),
|
|
146
208
|
sitemap({
|
|
147
209
|
filter: sitemapFilter || ((page) => !/\^\/(?!cdn-cgi\/)/.test(page)),
|
|
148
210
|
changefreq: "weekly",
|
|
149
211
|
priority: 0.4,
|
|
150
|
-
lastmod:
|
|
212
|
+
lastmod: new Date(),
|
|
151
213
|
namespaces: {
|
|
152
214
|
image: false,
|
|
153
|
-
video: false
|
|
154
|
-
}
|
|
155
|
-
})
|
|
215
|
+
video: false,
|
|
216
|
+
},
|
|
217
|
+
}),
|
|
156
218
|
];
|
|
219
|
+
|
|
157
220
|
const filtered = defaultIntegrations.filter((integration) => {
|
|
158
221
|
const name = integration?.name;
|
|
159
|
-
return !name || !unwantedIntegrations.includes(name);
|
|
222
|
+
return !name || !unwantedIntegrations.includes(name as defaultIntegration);
|
|
160
223
|
});
|
|
224
|
+
|
|
161
225
|
if (!integrationConfigs) return filtered;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
226
|
+
|
|
227
|
+
const overrides = Object.entries(integrationConfigs)
|
|
228
|
+
.map(([integrationName, config]) => {
|
|
229
|
+
switch (integrationName) {
|
|
230
|
+
case "astroD2":
|
|
231
|
+
return astroD2(config);
|
|
232
|
+
case "markdoc":
|
|
233
|
+
return markdoc(config);
|
|
234
|
+
case "mdx":
|
|
235
|
+
return mdx(config);
|
|
236
|
+
case "favicons":
|
|
237
|
+
return favicons(config);
|
|
238
|
+
case "sitemap":
|
|
239
|
+
return sitemap(config);
|
|
240
|
+
default:
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
})
|
|
244
|
+
.filter(nonNullable);
|
|
245
|
+
|
|
178
246
|
return [...filtered, ...overrides];
|
|
179
247
|
};
|
|
180
|
-
|
|
248
|
+
|
|
249
|
+
export type PluginOptions = Pick<
|
|
250
|
+
DocsTemplateOptions,
|
|
251
|
+
"appName" | "llmConfig" | "pluginConfigs"
|
|
252
|
+
> & { unwantedPlugins?: string[] };
|
|
253
|
+
|
|
254
|
+
const get_plugins = (options: PluginOptions) => {
|
|
181
255
|
const { appName, llmConfig, pluginConfigs, unwantedPlugins = [] } = options;
|
|
182
256
|
const defaultPlugins = [
|
|
183
257
|
starlightAnnouncement(),
|
|
@@ -189,10 +263,12 @@ const get_plugins = (options) => {
|
|
|
189
263
|
starlightPageActions({
|
|
190
264
|
baseUrl: `https://docs.knitli.com/${appName.toLowerCase()}`,
|
|
191
265
|
actions: { claude: true, chatgpt: true, markdown: true },
|
|
192
|
-
share: true
|
|
266
|
+
share: true,
|
|
193
267
|
}),
|
|
194
268
|
starlightTags({ onInlineTagsNotFound: "warn" }),
|
|
195
|
-
pluginConfigs?.starlightSidebarTopics
|
|
269
|
+
pluginConfigs?.starlightSidebarTopics
|
|
270
|
+
? starlightSidebarTopics(pluginConfigs.starlightSidebarTopics)
|
|
271
|
+
: null,
|
|
196
272
|
starlightScrollToTop({ showOnHomepage: false }),
|
|
197
273
|
// We need to configure starlight-tags with a tags.yml.
|
|
198
274
|
//starlightTags(),
|
|
@@ -204,35 +280,44 @@ const get_plugins = (options) => {
|
|
|
204
280
|
minify: {
|
|
205
281
|
whitespace: true,
|
|
206
282
|
note: true,
|
|
207
|
-
details: true
|
|
208
|
-
}
|
|
209
|
-
})
|
|
283
|
+
details: true,
|
|
284
|
+
},
|
|
285
|
+
}),
|
|
210
286
|
];
|
|
211
|
-
|
|
287
|
+
|
|
288
|
+
const filtered = defaultPlugins
|
|
289
|
+
.filter(nonNullable)
|
|
290
|
+
.filter((plugin) => !unwantedPlugins.includes(plugin.name));
|
|
291
|
+
|
|
212
292
|
if (!pluginConfigs) return filtered;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
293
|
+
|
|
294
|
+
const overrides = Object.entries(pluginConfigs)
|
|
295
|
+
.map(([pluginName, config]) => {
|
|
296
|
+
switch (pluginName) {
|
|
297
|
+
case "starlightAnnouncement":
|
|
298
|
+
return starlightAnnouncement(config);
|
|
299
|
+
case "starlightIconsIntegration":
|
|
300
|
+
return starlightIconsIntegration(config);
|
|
301
|
+
case "starlightIconsPlugin":
|
|
302
|
+
return starlightIconsPlugin(config);
|
|
303
|
+
case "starlightLinksValidator":
|
|
304
|
+
return starlightLinksValidator(config);
|
|
305
|
+
case "starlightPageActions":
|
|
306
|
+
return starlightPageActions(config);
|
|
307
|
+
case "starlightTags":
|
|
308
|
+
return starlightTags(config);
|
|
309
|
+
case "starlightScrollToTop":
|
|
310
|
+
return starlightScrollToTop(config);
|
|
311
|
+
default:
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
})
|
|
315
|
+
.filter(nonNullable);
|
|
316
|
+
|
|
233
317
|
return [...filtered, ...overrides];
|
|
234
318
|
};
|
|
235
|
-
|
|
319
|
+
|
|
320
|
+
export default function createConfig(options: DocsTemplateOptions) {
|
|
236
321
|
const {
|
|
237
322
|
appName,
|
|
238
323
|
description,
|
|
@@ -249,57 +334,59 @@ function createConfig(options) {
|
|
|
249
334
|
integrationConfigs,
|
|
250
335
|
unwantedIntegrations,
|
|
251
336
|
unwantedPlugins,
|
|
252
|
-
headersConfig
|
|
337
|
+
headersConfig,
|
|
253
338
|
} = options;
|
|
339
|
+
|
|
340
|
+
// https://astro.build/config
|
|
254
341
|
return defineConfig({
|
|
255
342
|
site: "https://docs.knitli.com",
|
|
256
343
|
base: `/${appName.toLowerCase()}/`,
|
|
257
344
|
adapter: cloudflare({
|
|
258
345
|
prerenderEnvironment: "workerd",
|
|
259
346
|
experimental: {
|
|
260
|
-
headersAndRedirectsDevModeSupport: true
|
|
347
|
+
headersAndRedirectsDevModeSupport: true,
|
|
261
348
|
},
|
|
262
349
|
configPath: `${rootDir}/wrangler.jsonc`,
|
|
263
|
-
imageService: "compile"
|
|
350
|
+
imageService: "compile",
|
|
264
351
|
}),
|
|
265
352
|
// Image optimization
|
|
266
353
|
image: {
|
|
267
354
|
service: {
|
|
268
|
-
entrypoint: "astro/assets/services/sharp"
|
|
355
|
+
entrypoint: "astro/assets/services/sharp",
|
|
269
356
|
},
|
|
270
357
|
responsiveStyles: true,
|
|
271
358
|
layout: "constrained",
|
|
272
|
-
remotePatterns: imageDomains
|
|
359
|
+
remotePatterns: imageDomains,
|
|
273
360
|
},
|
|
274
361
|
compressHTML: true,
|
|
275
362
|
// biome-ignore lint/suspicious/noExplicitAny: Astro's FontFamily generic inference doesn't match spread patterns
|
|
276
|
-
fonts: is_codeweaver ? codeweaverFontConfig : defaultFontConfig,
|
|
363
|
+
fonts: (is_codeweaver ? codeweaverFontConfig : defaultFontConfig) as any,
|
|
277
364
|
// Build optimizations
|
|
278
365
|
build: {
|
|
279
366
|
inlineStylesheets: "auto",
|
|
280
|
-
assets: "_astro"
|
|
367
|
+
assets: "_astro",
|
|
281
368
|
},
|
|
282
369
|
markdown: {
|
|
283
370
|
shikiConfig: Object.fromEntries(
|
|
284
|
-
Object.entries(shikiConfig).filter(([key]) => key !== "bundledLangs")
|
|
371
|
+
Object.entries(shikiConfig).filter(([key]) => key !== "bundledLangs"),
|
|
285
372
|
),
|
|
286
373
|
rehypePlugins: [
|
|
287
374
|
rehypeExternalLinks({
|
|
288
375
|
content: { type: "text", value: " ↗" },
|
|
289
|
-
rel: ["nofollow"]
|
|
290
|
-
})
|
|
291
|
-
]
|
|
376
|
+
rel: ["nofollow"],
|
|
377
|
+
}),
|
|
378
|
+
],
|
|
292
379
|
},
|
|
293
380
|
server: {
|
|
294
|
-
headers: headersConfig
|
|
381
|
+
headers: headersConfig,
|
|
295
382
|
},
|
|
296
383
|
trailingSlash: "always",
|
|
297
384
|
// Vite configuration for better bundling
|
|
298
385
|
vite: {
|
|
299
386
|
server: {
|
|
300
387
|
fs: {
|
|
301
|
-
allow: [searchForWorkspaceRoot(rootDir)]
|
|
302
|
-
}
|
|
388
|
+
allow: [searchForWorkspaceRoot(rootDir)],
|
|
389
|
+
},
|
|
303
390
|
},
|
|
304
391
|
assetsInclude: [
|
|
305
392
|
"src/*.webp",
|
|
@@ -307,11 +394,11 @@ function createConfig(options) {
|
|
|
307
394
|
"src/*.jpg",
|
|
308
395
|
"src/*.jpeg",
|
|
309
396
|
"src/*.svg",
|
|
310
|
-
"src/*.avif"
|
|
397
|
+
"src/*.avif",
|
|
311
398
|
],
|
|
312
399
|
plugins: [viteTsconfigPaths({ loose: true })],
|
|
313
400
|
define: {
|
|
314
|
-
"import.meta.env.PUBLIC_DOCS_PRODUCT": JSON.stringify(appName)
|
|
401
|
+
"import.meta.env.PUBLIC_DOCS_PRODUCT": JSON.stringify(appName),
|
|
315
402
|
},
|
|
316
403
|
build: {
|
|
317
404
|
cssMinify: "lightningcss",
|
|
@@ -324,7 +411,7 @@ function createConfig(options) {
|
|
|
324
411
|
dir: `${rootDir}/dist/_astro/`,
|
|
325
412
|
compact: true,
|
|
326
413
|
interop: "esModule",
|
|
327
|
-
experimentalMinChunkSize:
|
|
414
|
+
experimentalMinChunkSize: 10000,
|
|
328
415
|
banner: `
|
|
329
416
|
/* SPDX-FileCopyrightText: 2026 Knitli Inc.
|
|
330
417
|
* SPDX-License-Identifier: MIT OR Apache-2.0
|
|
@@ -336,22 +423,22 @@ function createConfig(options) {
|
|
|
336
423
|
arrowFunctions: true,
|
|
337
424
|
constBindings: true,
|
|
338
425
|
objectShorthand: true,
|
|
339
|
-
symbols: true
|
|
426
|
+
symbols: true,
|
|
340
427
|
},
|
|
341
428
|
entryFileNames: "assets/[name]-[hash].js",
|
|
342
429
|
chunkFileNames: "assets/[name]-[hash].js",
|
|
343
|
-
assetFileNames: "assets/[name]-[hash][extname]"
|
|
430
|
+
assetFileNames: "assets/[name]-[hash][extname]",
|
|
344
431
|
},
|
|
345
|
-
treeshake: "smallest"
|
|
432
|
+
treeshake: "smallest",
|
|
346
433
|
},
|
|
347
|
-
ssr: false
|
|
434
|
+
ssr: false,
|
|
348
435
|
},
|
|
349
436
|
css: {
|
|
350
|
-
lightningcss: {}
|
|
351
|
-
}
|
|
437
|
+
lightningcss: {},
|
|
438
|
+
},
|
|
352
439
|
},
|
|
353
440
|
prefetch: {
|
|
354
|
-
defaultStrategy: "viewport"
|
|
441
|
+
defaultStrategy: "viewport",
|
|
355
442
|
},
|
|
356
443
|
prerenderConflictBehavior: "warn",
|
|
357
444
|
experimental: {
|
|
@@ -360,7 +447,7 @@ function createConfig(options) {
|
|
|
360
447
|
contentIntellisense: true,
|
|
361
448
|
queuedRendering: {
|
|
362
449
|
contentCache: true,
|
|
363
|
-
enabled: true
|
|
450
|
+
enabled: true,
|
|
364
451
|
},
|
|
365
452
|
rustCompiler: true,
|
|
366
453
|
svgo: {
|
|
@@ -369,13 +456,14 @@ function createConfig(options) {
|
|
|
369
456
|
name: "preset-default",
|
|
370
457
|
params: {
|
|
371
458
|
overrides: {
|
|
372
|
-
removeMetadata: false
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
]
|
|
377
|
-
}
|
|
459
|
+
removeMetadata: false,
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
],
|
|
464
|
+
},
|
|
378
465
|
},
|
|
466
|
+
|
|
379
467
|
// Static site generation for Cloudflare
|
|
380
468
|
output: "static",
|
|
381
469
|
integrations: [
|
|
@@ -383,20 +471,20 @@ function createConfig(options) {
|
|
|
383
471
|
appName,
|
|
384
472
|
sitemapFilter,
|
|
385
473
|
integrationConfigs,
|
|
386
|
-
unwantedIntegrations
|
|
474
|
+
unwantedIntegrations,
|
|
387
475
|
}),
|
|
388
476
|
starlight({
|
|
389
477
|
title: `${appName} Docs`,
|
|
390
478
|
pagefind: true,
|
|
391
|
-
description,
|
|
479
|
+
description: description,
|
|
392
480
|
logo: {
|
|
393
481
|
dark: logoDark,
|
|
394
482
|
light: logoLight,
|
|
395
483
|
alt: is_codeweaver ? "CodeWeaver Logo" : "Knitli Logo",
|
|
396
|
-
replacesTitle: true
|
|
484
|
+
replacesTitle: true,
|
|
397
485
|
},
|
|
398
486
|
editLink: {
|
|
399
|
-
baseUrl: `https://github.com/knitli/${appName.toLowerCase()}/edit/main/docs-site/src
|
|
487
|
+
baseUrl: `https://github.com/knitli/${appName.toLowerCase()}/edit/main/docs-site/src`,
|
|
400
488
|
},
|
|
401
489
|
expressiveCode: {
|
|
402
490
|
useStarlightDarkModeSwitch: true,
|
|
@@ -404,27 +492,27 @@ function createConfig(options) {
|
|
|
404
492
|
removeUnusedThemes: true,
|
|
405
493
|
shiki: {
|
|
406
494
|
...Object.fromEntries(
|
|
407
|
-
Object.entries(shikiConfig).filter(([key]) => key !== "themes")
|
|
408
|
-
)
|
|
409
|
-
}
|
|
495
|
+
Object.entries(shikiConfig).filter(([key]) => key !== "themes"),
|
|
496
|
+
),
|
|
497
|
+
},
|
|
410
498
|
},
|
|
411
499
|
plugins: get_plugins({
|
|
412
500
|
appName,
|
|
413
501
|
llmConfig,
|
|
414
502
|
pluginConfigs,
|
|
415
|
-
unwantedPlugins
|
|
503
|
+
unwantedPlugins,
|
|
416
504
|
// biome-ignore lint/suspicious/noExplicitAny: Starlight plugin types are complex Zod inferences
|
|
417
|
-
}),
|
|
505
|
+
}) as any[],
|
|
418
506
|
social: [
|
|
419
507
|
{
|
|
420
508
|
icon: "github",
|
|
421
509
|
label: "GitHub",
|
|
422
|
-
href: `https://github.com/knitli/${appName.toLowerCase()}
|
|
423
|
-
}
|
|
510
|
+
href: `https://github.com/knitli/${appName.toLowerCase()}`,
|
|
511
|
+
},
|
|
424
512
|
],
|
|
425
513
|
components: {
|
|
426
514
|
Footer: "@knitli/docs-components/Footer.astro",
|
|
427
|
-
PageFrame: "@knitli/docs-components/PageFrame.astro"
|
|
515
|
+
PageFrame: "@knitli/docs-components/PageFrame.astro",
|
|
428
516
|
},
|
|
429
517
|
customCss: [variables, docsStyle, `${rootDir}/src/styles/custom.css`],
|
|
430
518
|
head: [
|
|
@@ -432,34 +520,32 @@ function createConfig(options) {
|
|
|
432
520
|
tag: "meta",
|
|
433
521
|
attrs: {
|
|
434
522
|
property: "og:image",
|
|
435
|
-
content: `https://docs.knitli.com/${appName.toLowerCase()}/og-image.png
|
|
436
|
-
}
|
|
523
|
+
content: `https://docs.knitli.com/${appName.toLowerCase()}/og-image.png`,
|
|
524
|
+
},
|
|
437
525
|
},
|
|
438
526
|
{
|
|
439
527
|
tag: "meta",
|
|
440
528
|
attrs: {
|
|
441
529
|
property: "twitter:card",
|
|
442
|
-
content: "summary_large_image"
|
|
443
|
-
}
|
|
444
|
-
}
|
|
530
|
+
content: "summary_large_image",
|
|
531
|
+
},
|
|
532
|
+
},
|
|
445
533
|
],
|
|
446
534
|
sidebar: sidebarConfig || [
|
|
447
535
|
{
|
|
448
536
|
label: "Guides",
|
|
449
|
-
autogenerate: { directory: "guides" }
|
|
537
|
+
autogenerate: { directory: "guides" },
|
|
450
538
|
},
|
|
451
539
|
{
|
|
452
540
|
label: "Examples",
|
|
453
|
-
autogenerate: { directory: "examples" }
|
|
541
|
+
autogenerate: { directory: "examples" },
|
|
454
542
|
},
|
|
455
543
|
{
|
|
456
544
|
label: "Reference",
|
|
457
|
-
autogenerate: { directory: "reference" }
|
|
458
|
-
}
|
|
459
|
-
]
|
|
460
|
-
})
|
|
461
|
-
]
|
|
545
|
+
autogenerate: { directory: "reference" },
|
|
546
|
+
},
|
|
547
|
+
],
|
|
548
|
+
}),
|
|
549
|
+
],
|
|
462
550
|
});
|
|
463
551
|
}
|
|
464
|
-
|
|
465
|
-
export { createConfig as default, docsStyle, faviconIco, faviconSvg, headlineLogoDark, headlineLogoLight, variables };
|