@dogsbay/docs-layout 0.2.0-beta.86 → 0.2.0-beta.88

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dogsbay/docs-layout",
3
- "version": "0.2.0-beta.86",
3
+ "version": "0.2.0-beta.88",
4
4
  "description": "Standard documentation layout components for Dogsbay",
5
5
  "type": "module",
6
6
  "exports": {
@@ -29,8 +29,8 @@
29
29
  "./json-ld": "./src/json-ld.ts"
30
30
  },
31
31
  "dependencies": {
32
- "@dogsbay/ui": "0.2.0-beta.86",
33
- "@dogsbay/primitives": "0.2.0-beta.86"
32
+ "@dogsbay/primitives": "0.2.0-beta.88",
33
+ "@dogsbay/ui": "0.2.0-beta.88"
34
34
  },
35
35
  "devDependencies": {
36
36
  "vitest": "^3.0.0"
@@ -35,7 +35,7 @@ import DocsNavClient from "./DocsNavClient.astro";
35
35
  import Separator from "@dogsbay/ui/separator/Separator.astro";
36
36
  import ThemeToggle from "@dogsbay/ui/theme-toggle/ThemeToggle.astro";
37
37
  import DocsToc from "./DocsToc.astro";
38
- import { resolveTocPlacement, type TocMode } from "./toc-placement.js";
38
+ import { resolveTocPlacement, hasDisplayableToc, type TocMode } from "./toc-placement.js";
39
39
  import DocsFooter from "./DocsFooter.astro";
40
40
  import SearchDialog from "./SearchDialog.astro";
41
41
  import TagList from "./TagList.astro";
@@ -528,7 +528,10 @@ const hasMetaStrip = (
528
528
  // TOC placement: which container(s) + the right-rail plugin region render.
529
529
  // Logic lives in toc-placement.ts so it's unit-tested; this file just consumes.
530
530
  const tocPlacement = resolveTocPlacement(toc, {
531
- hasHeadings: headings.length > 0,
531
+ // Only show a TOC when the page has 2+ displayable headings (depth 2–3);
532
+ // the H1 doesn't count and a one-item TOC is noise. Keeps "On this page"
533
+ // off landing/welcome pages that are just an H1 + prose.
534
+ hasHeadings: hasDisplayableToc(headings),
532
535
  wideLayout: !!wideLayout,
533
536
  });
534
537
 
@@ -1012,7 +1015,7 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
1012
1015
  Hidden when nothing fills it (see the empty-rail style below). */}
1013
1016
  {tocPlacement.regionRail && (
1014
1017
  <aside
1015
- class="dba-right-rail sticky top-12 hidden h-[calc(100vh-3rem)] w-56 shrink-0 overflow-y-auto border-l p-4 lg:block"
1018
+ class="dba-right-rail sticky top-12 hidden h-[calc(100vh-3rem)] w-80 shrink-0 overflow-y-auto border-l p-4 lg:block xl:w-96"
1016
1019
  data-right-rail
1017
1020
  >
1018
1021
  <slot name="right-rail" />
@@ -25,6 +25,26 @@ export interface TocPlacement {
25
25
  regionRail: boolean;
26
26
  }
27
27
 
28
+ /**
29
+ * Whether a page has enough displayable headings to warrant a TOC. The TOC
30
+ * (`DocsToc`) only lists depth `minDepth`–`maxDepth` (2–3 by default), so the
31
+ * page H1 never counts; and a TOC of a single entry isn't useful, so require
32
+ * `min` (2) by default. Pages like a landing/welcome page — H1 + prose, no
33
+ * sub-sections — therefore get no "On this page".
34
+ */
35
+ export function hasDisplayableToc(
36
+ headings: { depth: number }[],
37
+ opts: { minDepth?: number; maxDepth?: number; min?: number } = {},
38
+ ): boolean {
39
+ const { minDepth = 2, maxDepth = 3, min = 2 } = opts;
40
+ let count = 0;
41
+ for (const h of headings) {
42
+ if (h.depth >= minDepth && h.depth <= maxDepth) count++;
43
+ if (count >= min) return true;
44
+ }
45
+ return false;
46
+ }
47
+
28
48
  export interface TocPlacementInput {
29
49
  /** Page has at least one heading to list. */
30
50
  hasHeadings: boolean;