@knitli/astro-docs-template 0.4.3 → 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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/config.ts +14 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knitli/astro-docs-template",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "Opinionated Astro + Starlight docs site template with Knitli branding",
5
5
  "keywords": [
6
6
  "knitli",
@@ -63,7 +63,7 @@
63
63
  "astro-favicons": "3.1.6",
64
64
  "bun": "^1.3.9",
65
65
  "lightningcss": "^1.30.2",
66
- "postcss": "^8.5.9",
66
+ "postcss": "8.5.6",
67
67
  "postcss-nesting": "^14.0.0",
68
68
  "rehype-external-links": "^3.0.0",
69
69
  "sharp": "^0.34.5",
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 {
@@ -396,7 +404,7 @@ const defaultHeadersConfig: OutgoingHttpHeaders = {
396
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'",
397
405
  };
398
406
 
399
- export default function createConfig(options: DocsTemplateOptions) {
407
+ export default async function createConfig(options: DocsTemplateOptions) {
400
408
  const {
401
409
  appName,
402
410
  description,
@@ -511,7 +519,11 @@ export default function createConfig(options: DocsTemplateOptions) {
511
519
  },
512
520
  css: {
513
521
  postcss: {
514
- plugins: [require("postcss-nesting")()],
522
+ plugins: [
523
+ await postcssNesting({
524
+ edition: "2024-02",
525
+ }),
526
+ ],
515
527
  },
516
528
  },
517
529
  },