@knitli/astro-docs-template 0.4.2 → 0.4.4
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 +3 -1
- package/src/config.ts +21 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knitli/astro-docs-template",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Opinionated Astro + Starlight docs site template with Knitli branding",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"knitli",
|
|
@@ -63,6 +63,8 @@
|
|
|
63
63
|
"astro-favicons": "3.1.6",
|
|
64
64
|
"bun": "^1.3.9",
|
|
65
65
|
"lightningcss": "^1.30.2",
|
|
66
|
+
"postcss": "8.5.6",
|
|
67
|
+
"postcss-nesting": "^14.0.0",
|
|
66
68
|
"rehype-external-links": "^3.0.0",
|
|
67
69
|
"sharp": "^0.34.5",
|
|
68
70
|
"starlight-announcement": ">=0.1.1",
|
package/src/config.ts
CHANGED
|
@@ -18,6 +18,8 @@ import { defineConfig, fontProviders } from "astro/config";
|
|
|
18
18
|
import cloudflarePagesHeaders from "astro-cloudflare-pages-headers";
|
|
19
19
|
import astroD2 from "astro-d2";
|
|
20
20
|
import favicons from "astro-favicons";
|
|
21
|
+
import type { PluginCreator } from "postcss";
|
|
22
|
+
import type { pluginOptions } from "postcss-nesting";
|
|
21
23
|
import rehypeExternalLinks from "rehype-external-links";
|
|
22
24
|
import starlightAnnouncement from "starlight-announcement";
|
|
23
25
|
import starlightChangelogs from "starlight-changelogs";
|
|
@@ -48,6 +50,12 @@ function nonNullable<T>(value: T): value is NonNullable<T> {
|
|
|
48
50
|
return value != null;
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
const postcssNesting = async (options?: { edition: "2021" | "2024-02" }) => {
|
|
54
|
+
// Dynamically import postcss-nesting to avoid bundling it in the template's node_modules
|
|
55
|
+
const { default: createPlugin } = await import("postcss-nesting");
|
|
56
|
+
return createPlugin(options) as unknown as PluginCreator<pluginOptions>;
|
|
57
|
+
};
|
|
58
|
+
|
|
51
59
|
// ── Defaults (defined before interface so `typeof` references work) ──
|
|
52
60
|
|
|
53
61
|
export const {
|
|
@@ -164,6 +172,7 @@ export interface DocsTemplateOptions {
|
|
|
164
172
|
promotePatterns: string[];
|
|
165
173
|
demotePatterns: string[];
|
|
166
174
|
};
|
|
175
|
+
cloudflareConfigPath?: string;
|
|
167
176
|
rootDir: string;
|
|
168
177
|
shikiConfig?: typeof shikiCfg;
|
|
169
178
|
logoDark?: string;
|
|
@@ -395,11 +404,12 @@ const defaultHeadersConfig: OutgoingHttpHeaders = {
|
|
|
395
404
|
"default-src 'self'; script-src 'self' 'unsafe-inline' static.cloudflareinsights.com zaraz.cloudflare.com; connect-src 'self' cloudflareinsights.com *.cloudflareinsights.com; img-src 'self' media.knitli.com data: avatars.githubusercontent.com ui-avatars.com media.knitli.com knitli.com; style-src 'self' 'unsafe-inline' fonts.googleapis.com; font-src 'self' fonts.gstatic.com; frame-ancestors 'none'",
|
|
396
405
|
};
|
|
397
406
|
|
|
398
|
-
export default function createConfig(options: DocsTemplateOptions) {
|
|
407
|
+
export default async function createConfig(options: DocsTemplateOptions) {
|
|
399
408
|
const {
|
|
400
409
|
appName,
|
|
401
410
|
description,
|
|
402
411
|
llmConfig,
|
|
412
|
+
cloudflareConfigPath,
|
|
403
413
|
rootDir,
|
|
404
414
|
shikiConfig = shikiCfg,
|
|
405
415
|
logoDark = headlineLogoDark,
|
|
@@ -420,7 +430,7 @@ export default function createConfig(options: DocsTemplateOptions) {
|
|
|
420
430
|
site: "https://docs.knitli.com",
|
|
421
431
|
base: `/${appName.toLowerCase()}/`,
|
|
422
432
|
adapter: cloudflare({
|
|
423
|
-
configPath: `${rootDir}/wrangler.
|
|
433
|
+
configPath: cloudflareConfigPath || `${rootDir}/wrangler.jsonc`,
|
|
424
434
|
imageService: "compile",
|
|
425
435
|
}),
|
|
426
436
|
// Image optimization
|
|
@@ -507,7 +517,15 @@ export default function createConfig(options: DocsTemplateOptions) {
|
|
|
507
517
|
},
|
|
508
518
|
ssr: false,
|
|
509
519
|
},
|
|
510
|
-
css: {
|
|
520
|
+
css: {
|
|
521
|
+
postcss: {
|
|
522
|
+
plugins: [
|
|
523
|
+
await postcssNesting({
|
|
524
|
+
edition: "2024-02",
|
|
525
|
+
}),
|
|
526
|
+
],
|
|
527
|
+
},
|
|
528
|
+
},
|
|
511
529
|
},
|
|
512
530
|
prefetch: {
|
|
513
531
|
defaultStrategy: "viewport",
|