starlight-cannoli-plugins 2.2.0 → 2.3.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/README.md CHANGED
@@ -317,6 +317,36 @@ syncDocsToPublic({
317
317
  });
318
318
  ```
319
319
 
320
+ ### Starlight DOM Patches
321
+
322
+ An Astro integration that injects a client-side script to apply opt-in DOM patches on every page. Each patch is disabled by default and must be explicitly enabled.
323
+
324
+ **Options:**
325
+
326
+ - `hideSingleLineGutters` (optional, default: `false`): Hides the line number gutter on Expressive Code blocks that contain only a single line.
327
+ - `syncTocLabelsFromHeadings` (optional, default: `false`): Copies the rendered HTML of each heading into its matching Starlight TOC anchor label, so the TOC properly reflects any custom markup (e.g. math) present in the heading.
328
+ - `wrapDetailsContent` (optional, default: `false`): Wraps the content of every `<details>` element (excluding its `<summary>`) in a `<div class="details-wrapper">`, useful for applying consistent spacing or animation styles.
329
+
330
+ **Usage:**
331
+
332
+ ```ts
333
+ // astro.config.mjs
334
+ import { defineConfig } from "astro/config";
335
+ import starlight from "@astrojs/starlight";
336
+ import { starlightDomPatches } from "starlight-cannoli-plugins";
337
+
338
+ export default defineConfig({
339
+ integrations: [
340
+ starlightDomPatches({
341
+ hideSingleLineGutters: true,
342
+ syncTocLabelsFromHeadings: true,
343
+ wrapDetailsContent: true,
344
+ }),
345
+ starlight({ title: "My Docs" }),
346
+ ],
347
+ });
348
+ ```
349
+
320
350
  ## CLI Utilities
321
351
 
322
352
  ### cannoli-latex-cleanup
package/dist/index.d.ts CHANGED
@@ -11,9 +11,11 @@ import 'vfile';
11
11
  import 'mdast';
12
12
 
13
13
  interface DomPatchesOptions {
14
- /** Hide line number gutters on single-line code blocks. @default true */
14
+ /** Hide line number gutters on single-line code blocks. @default false */
15
15
  hideSingleLineGutters?: boolean;
16
- /** Wrap `<details>` content (excluding `<summary>`) in a `.details-wrapper` div. @default true */
16
+ /** Copy rendered heading innerHTML into matching Starlight TOC anchor labels. @default false */
17
+ syncTocLabelsFromHeadings?: boolean;
18
+ /** Wrap `<details>` content (excluding `<summary>`) in a `.details-wrapper` div. @default false */
17
19
  wrapDetailsContent?: boolean;
18
20
  }
19
21
  /**
package/dist/index.js CHANGED
@@ -19,7 +19,11 @@ import "./chunk-QGM4M3NI.js";
19
19
  // src/plugins/starlight-dom-patches/index.ts
20
20
  import { fileURLToPath } from "url";
21
21
  function starlightDomPatches(options = {}) {
22
- const { hideSingleLineGutters = true, wrapDetailsContent = true } = options;
22
+ const {
23
+ hideSingleLineGutters = false,
24
+ syncTocLabelsFromHeadings = false,
25
+ wrapDetailsContent = false
26
+ } = options;
23
27
  return {
24
28
  name: "starlight-dom-patches",
25
29
  hooks: {
@@ -42,6 +46,7 @@ function starlightDomPatches(options = {}) {
42
46
  const scriptPath = JSON.stringify(fileURLToPath(pageScriptUrl));
43
47
  const imports = [
44
48
  hideSingleLineGutters ? "hideSingleLineGutters" : null,
49
+ syncTocLabelsFromHeadings ? "syncTocLabelsFromHeadings" : null,
45
50
  wrapDetailsContent ? "wrapDetailsContent" : null
46
51
  ].filter(Boolean);
47
52
  if (imports.length === 0) return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "starlight-cannoli-plugins",
3
3
  "type": "module",
4
- "version": "2.2.0",
4
+ "version": "2.3.1",
5
5
  "description": "Starlight plugins for automatic sidebar generation and link validation",
6
6
  "license": "ISC",
7
7
  "main": "./dist/index.js",