starlight-cannoli-plugins 2.1.10 → 2.3.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/dist/index.d.ts CHANGED
@@ -1,15 +1,27 @@
1
1
  export { starlightIndexOnlySidebar } from './plugins/starlight-index-only-sidebar.js';
2
+ import { AstroIntegration } from 'astro';
2
3
  export { SyncDocsToPublicOptions, syncDocsToPublic } from './plugins/astro-sync-docs-to-public.js';
3
4
  export { default as rehypeValidateLinks } from './plugins/rehype-validate-links.js';
4
5
  export { astroNormalizePaths } from './plugins/astro-normalize-paths.js';
5
6
  import { RemarkLatexCompileOptions } from './plugins/astro-latex-compile.js';
6
7
  export { default as remarkLatexCompile } from './plugins/astro-latex-compile.js';
7
- import { AstroIntegration } from 'astro';
8
8
  import '@astrojs/starlight/types';
9
9
  import 'hast';
10
10
  import 'vfile';
11
11
  import 'mdast';
12
12
 
13
+ interface DomPatchesOptions {
14
+ /** Hide line number gutters on single-line code blocks. @default false */
15
+ hideSingleLineGutters?: boolean;
16
+ /** Wrap `<details>` content (excluding `<summary>`) in a `.details-wrapper` div. @default false */
17
+ wrapDetailsContent?: boolean;
18
+ }
19
+ /**
20
+ * Astro integration that injects a client-side script to apply DOM patches
21
+ * on every page. Each patch can be individually enabled or disabled via options.
22
+ */
23
+ declare function starlightDomPatches(options?: DomPatchesOptions): AstroIntegration;
24
+
13
25
  interface LatexCompileOptions extends RemarkLatexCompileOptions {
14
26
  /**
15
27
  * When `true`, SVG files in `svgOutputDir` that are no longer referenced by
@@ -22,4 +34,4 @@ interface LatexCompileOptions extends RemarkLatexCompileOptions {
22
34
  }
23
35
  declare function astroLatexCompile(options: LatexCompileOptions): AstroIntegration;
24
36
 
25
- export { type LatexCompileOptions, astroLatexCompile };
37
+ export { type DomPatchesOptions, type LatexCompileOptions, astroLatexCompile, starlightDomPatches };
package/dist/index.js CHANGED
@@ -16,6 +16,46 @@ import {
16
16
  import "./chunk-IY4A67ZP.js";
17
17
  import "./chunk-QGM4M3NI.js";
18
18
 
19
+ // src/plugins/starlight-dom-patches/index.ts
20
+ import { fileURLToPath } from "url";
21
+ function starlightDomPatches(options = {}) {
22
+ const { hideSingleLineGutters = false, wrapDetailsContent = false } = options;
23
+ return {
24
+ name: "starlight-dom-patches",
25
+ hooks: {
26
+ "astro:config:setup": ({ injectScript }) => {
27
+ const currentFile = fileURLToPath(import.meta.url);
28
+ let pageScriptUrl;
29
+ if (currentFile.endsWith(".ts")) {
30
+ pageScriptUrl = new URL("./page-script.ts", import.meta.url);
31
+ } else if (currentFile.endsWith("starlight-dom-patches.js")) {
32
+ pageScriptUrl = new URL(
33
+ "./starlight-dom-patches/page-script.js",
34
+ import.meta.url
35
+ );
36
+ } else {
37
+ pageScriptUrl = new URL(
38
+ "./plugins/starlight-dom-patches/page-script.js",
39
+ import.meta.url
40
+ );
41
+ }
42
+ const scriptPath = JSON.stringify(fileURLToPath(pageScriptUrl));
43
+ const imports = [
44
+ hideSingleLineGutters ? "hideSingleLineGutters" : null,
45
+ wrapDetailsContent ? "wrapDetailsContent" : null
46
+ ].filter(Boolean);
47
+ if (imports.length === 0) return;
48
+ const calls = imports.map((fn) => `${fn}();`).join("\n");
49
+ injectScript(
50
+ "page",
51
+ `import { ${imports.join(", ")} } from ${scriptPath};
52
+ ${calls}`
53
+ );
54
+ }
55
+ }
56
+ };
57
+ }
58
+
19
59
  // src/plugins/astro-latex-compile/astro-integration.ts
20
60
  import fs from "fs";
21
61
  import { readdir, rm } from "fs/promises";
@@ -82,6 +122,7 @@ export {
82
122
  astroNormalizePaths,
83
123
  rehypeValidateLinks,
84
124
  remarkLatexCompile,
125
+ starlightDomPatches,
85
126
  starlightIndexOnlySidebar,
86
127
  syncDocsToPublic
87
128
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "starlight-cannoli-plugins",
3
3
  "type": "module",
4
- "version": "2.1.10",
4
+ "version": "2.3.0",
5
5
  "description": "Starlight plugins for automatic sidebar generation and link validation",
6
6
  "license": "ISC",
7
7
  "main": "./dist/index.js",