@dogsbay/docs-layout 0.2.0-beta.18 → 0.2.0-beta.180

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.
@@ -31,9 +31,13 @@ import SidebarMenuItem from "@dogsbay/ui/sidebar/SidebarMenuItem.astro";
31
31
  import SidebarMenuButton from "@dogsbay/ui/sidebar/SidebarMenuButton.astro";
32
32
  import SidebarSeparator from "@dogsbay/ui/sidebar/SidebarSeparator.astro";
33
33
  import SidebarNavTree from "@dogsbay/ui/sidebar/SidebarNavTree.astro";
34
+ import DocsNavClient from "./DocsNavClient.astro";
34
35
  import Separator from "@dogsbay/ui/separator/Separator.astro";
35
36
  import ThemeToggle from "@dogsbay/ui/theme-toggle/ThemeToggle.astro";
36
37
  import DocsToc from "./DocsToc.astro";
38
+ import "./section-switcher.css";
39
+ import { resolveTocPlacement, hasDisplayableToc, type TocMode } from "./toc-placement.js";
40
+ import { linkIconAttrs } from "./link-icons.js";
37
41
  import DocsFooter from "./DocsFooter.astro";
38
42
  import SearchDialog from "./SearchDialog.astro";
39
43
  import TagList from "./TagList.astro";
@@ -41,10 +45,20 @@ import StatusBadge from "./StatusBadge.astro";
41
45
  import TypeBadge from "./TypeBadge.astro";
42
46
  import PageActions from "./PageActions.astro";
43
47
  import VersionSwitcher from "./VersionSwitcher.astro";
48
+ import ProductSwitcher from "./ProductSwitcher.astro";
49
+ import AnnouncementBar from "./AnnouncementBar.astro";
50
+ import HeaderLinks from "./HeaderLinks.astro";
51
+ import SocialLinks from "./SocialLinks.astro";
52
+ import { headerLinksFrom, type LinksFrom, type SiteChromeData } from "./site-chrome.js";
53
+ import { COLOR_MODE_HEAD_SCRIPTS } from "@dogsbay/elements/color-mode-head";
54
+ import { ANNOUNCEMENT_CSS, ANNOUNCEMENT_HEAD_SCRIPT } from "@dogsbay/elements/announcement-head";
44
55
  import LocaleSwitcher from "./LocaleSwitcher.astro";
45
- import { filterNavByAxis } from "./nav-filter.js";
56
+ import { filterNavByAxis, rootVersionFilter } from "./nav-filter.js";
57
+ import { versionBadge, versionBanner, type VersionBannerWording } from "./switcher.js";
46
58
  import type { LlmProviderName } from "./llm-actions.js";
47
- import { jsonLdTypeFor, normalizeCustomJsonLd } from "./json-ld.js";
59
+ import { jsonLdTypeFor, normalizeCustomJsonLd, buildArticleJsonLd, buildWebSiteJsonLd } from "./json-ld.js";
60
+ import { pageFacets, scopeNav, sectionMenu, type PageFacets } from "@dogsbay/site-files";
61
+ import { sectionSwitcherHtml } from "./section-switcher.js";
48
62
  import { resolveTagKeywords } from "./tag-list-data.js";
49
63
 
50
64
  interface NavItem {
@@ -86,6 +100,8 @@ type TagPaletteName =
86
100
  interface Props {
87
101
  /** Site name shown in header and sidebar logo */
88
102
  siteName: string;
103
+ /** The line under the site name in the sidebar header (`site.tagline`). Default "Documentation". */
104
+ siteTagline?: string;
89
105
  /** Page title for <title> tag */
90
106
  title: string;
91
107
  /** Home URL — also used as the base for the canonical link if absolute */
@@ -112,7 +128,13 @@ interface Props {
112
128
  siteDescription?: string;
113
129
  /** Copyright text (HTML allowed) */
114
130
  copyright?: string;
115
- /** Favicon path (default: "/favicon.ico"). Set to false to disable. */
131
+ /**
132
+ * Favicon path. No host-root default — that 404s on subpath
133
+ * deploys. The format-astro emitter passes a combined-prefix
134
+ * path (e.g. `/<repo>/favicon.ico`) computed from site.url +
135
+ * basePath. Pass an empty string or `false` to disable. When
136
+ * undefined, no `<link rel="icon">` is emitted.
137
+ */
116
138
  favicon?: string | false;
117
139
  /** Per-page OG image URL. Overrides defaultOgImage. */
118
140
  ogImage?: string;
@@ -122,21 +144,34 @@ interface Props {
122
144
  ogType?: "article" | "website";
123
145
  /** Canonical URL for this page. Auto-computed from siteUrl + pathname when absolute siteUrl is provided. */
124
146
  canonicalUrl?: string;
147
+ /** `hreflang` alternates for this page's copies in other languages (absolute URLs), written after the canonical link. */
148
+ alternates?: { hreflang: string; href: string }[];
149
+ /** JSON-LD `BreadcrumbList` for this page, written after its own JSON-LD block. */
150
+ breadcrumbJsonLd?: Record<string, unknown>;
125
151
  /** Twitter / X handle including the leading "@" */
126
152
  twitterHandle?: string;
127
153
  /** Theme color hint for browsers (hex string) */
128
154
  themeColor?: string;
129
155
  /**
130
- * Emit `<meta name="robots" content="noindex, nofollow">` when
156
+ * Emit `noindex` in the `<meta name="robots">` directive when
131
157
  * true. Tells external search engines (Google, Bing) to skip
132
- * this page. Has NO effect on in-site Pagefind search — for
133
- * that, use `excludeFromSearch`. The two are independent: a
134
- * page can be excluded from external SEs but still appear in
135
- * Pagefind (e.g. duplicate / old content readers might still
136
- * want to find when they're already on the site), or vice
137
- * versa.
158
+ * indexing this page. Independent of `nofollow` — common pattern
159
+ * for tag / index pages is noindex + follow (don't list this
160
+ * page in results, but do crawl through to the real content).
161
+ *
162
+ * Has NO effect on in-site Pagefind search — for that, use
163
+ * `excludeFromSearch`. The two are independent: a page can be
164
+ * excluded from external SEs but still appear in Pagefind (e.g.
165
+ * duplicate / old content readers might still want to find when
166
+ * they're already on the site), or vice versa.
138
167
  */
139
168
  noindex?: boolean;
169
+ /**
170
+ * Emit `nofollow` in the `<meta name="robots">` directive when
171
+ * true. Tells crawlers not to follow outbound links from this
172
+ * page. Independent of `noindex`. Default false.
173
+ */
174
+ nofollow?: boolean;
140
175
  /**
141
176
  * Exclude this page from in-site Pagefind search results.
142
177
  *
@@ -179,6 +214,12 @@ interface Props {
179
214
  * a non-root base path (e.g. "/docs/pagefind/").
180
215
  */
181
216
  pagefindUrl?: string;
217
+ /**
218
+ * Base Pagefind prefixes result URLs with. Forwarded to SearchDialog;
219
+ * format-astro passes the right value for the deploy layout. See
220
+ * `pagefind-base-url.ts` for why no constant works.
221
+ */
222
+ pagefindBaseUrl?: string;
182
223
  /**
183
224
  * Whether the site emits per-page `.md` mirror endpoints. When true,
184
225
  * the page advertises `<link rel="alternate" type="text/markdown">`
@@ -213,6 +254,12 @@ interface Props {
213
254
  * `taxonomies.tags.labels`.
214
255
  */
215
256
  tagLabels?: Record<string, string>;
257
+ /**
258
+ * Color chips whose prefix has no color automatically (a stable
259
+ * palette color per first segment). Sourced from
260
+ * `taxonomies.tags.autoColor`.
261
+ */
262
+ tagAutoColor?: boolean;
216
263
  /**
217
264
  * Page lifecycle status. Renders a StatusBadge for non-stable
218
265
  * states. Drafts/deprecated get strong colors.
@@ -273,6 +320,16 @@ interface Props {
273
320
  * chip rendering elsewhere). When unset, raw slugs are shown.
274
321
  */
275
322
  taxonomies?: Record<string, string[]>;
323
+ /**
324
+ * The page's search facets (facet name → values), as `pageFacets` from
325
+ * `@dogsbay/site-files` maps them — the ONE mapping dogsbay-ssg uses for its
326
+ * search index too. format-astro computes it with the config's
327
+ * `hierarchical` taxonomies. When absent, the layout runs `pageFacets` over
328
+ * `tags`, `audience`, `category`, `status`, `pageType`, `taxonomies` and
329
+ * `multiSource` itself. Each pair becomes a hidden
330
+ * `data-pagefind-filter="name:value"` element.
331
+ */
332
+ facets?: PageFacets;
276
333
  /**
277
334
  * Map of taxonomy name → index path for declared taxonomies.
278
335
  * Used to wire links from built-in field badges (TypeBadge,
@@ -302,6 +359,17 @@ interface Props {
302
359
  * opt in. See plans/auto-lede.md.
303
360
  */
304
361
  autoH1?: boolean;
362
+ /**
363
+ * The version badge's wording on a page whose version has `badge: true`
364
+ * (`{label}` is the version's label). Default "Version: {label}", as
365
+ * dogsbay-ssg's English `versionBadge` string.
366
+ */
367
+ versionBadgeWording?: string;
368
+ /**
369
+ * The version banner's words (an older, unmaintained or unreleased version, and the link to the
370
+ * latest), as dogsbay-ssg's English strings by default. A version's own `banner:` text is used as written.
371
+ */
372
+ versionBannerWording?: Partial<VersionBannerWording>;
305
373
  /**
306
374
  * When `true`, render `<p>{description}</p>` below the auto H1
307
375
  * (or above the meta strip when there's no H1) — used when the
@@ -324,6 +392,10 @@ interface Props {
324
392
  version?: string;
325
393
  locale?: string;
326
394
  originalSlug: string;
395
+ /** With a `products:` block: the version's URL segment (`latest`, or `""` at the product's root). */
396
+ versionPath?: string;
397
+ /** With a `products:` block: the product's other versions' URL segments. */
398
+ siblingVersionPaths?: string[];
327
399
  };
328
400
  /**
329
401
  * Switcher data emitted by format-astro's `emitSwitcherMap`.
@@ -333,7 +405,7 @@ interface Props {
333
405
  * `@/data/switcherMap.json`.
334
406
  */
335
407
  switcherMap?: {
336
- versions: Array<{ id: string; label?: string; eol?: boolean; default?: boolean }>;
408
+ versions: Array<{ id: string; label?: string; eol?: boolean; default?: boolean; root?: boolean }>;
337
409
  byLogicalKey: Record<string, Record<string, string>>;
338
410
  };
339
411
  /**
@@ -341,6 +413,32 @@ interface Props {
341
413
  * (`<basePath>/<version>/`). Defaults to "/docs".
342
414
  */
343
415
  basePath?: string;
416
+ /**
417
+ * Sidebar navigation render mode.
418
+ *
419
+ * - `"client"` (default): emit the small `<DocsNavClient />` placeholder;
420
+ * the tree is hydrated from `/_dogsbay/nav.json` once per session.
421
+ * Page HTML shrinks dramatically at scale (~50 KB vs ~1.2 MB on a
422
+ * 2k-page site). No-JS users see a sitemap fallback link.
423
+ * - `"ssr-full"`: render the full nav tree into every page's HTML.
424
+ * Best for very small sites or strict no-JS / SEO contexts.
425
+ *
426
+ * See plans/client-rendered-nav.md.
427
+ */
428
+ navMode?: "client" | "ssr-full";
429
+ /**
430
+ * `"section"`: the sidebar holds only the page's section (the top-level
431
+ * nav entry that holds it), under a section menu and a link home; the home
432
+ * page and pages in no section list the sections. Default `"site"`.
433
+ * Rules: `scopeNav` in @dogsbay/site-files. See plans/nav-scope.md.
434
+ */
435
+ navScope?: "site" | "section";
436
+ /**
437
+ * An unlisted page (plans/unlisted-pages.md) is in no listed nav entry: this is where it sits
438
+ * instead, its nearest listed ancestor's link, which locates its section for `navScope:
439
+ * "section"`. Nothing in the sidebar is marked current on such a page.
440
+ */
441
+ navLocate?: string;
344
442
  /**
345
443
  * Per-page LLM action UI. When set and `enabled !== false`, renders
346
444
  * the PageActions cluster (Copy markdown + Open in Claude/ChatGPT/
@@ -375,16 +473,89 @@ interface Props {
375
473
  * in per-page.
376
474
  */
377
475
  wideLayout?: boolean;
476
+
477
+ /**
478
+ * Which chrome this page wears.
479
+ *
480
+ * `"docs"` (default) is the full documentation shell. `"blog"` drops
481
+ * the sidebar and its nav fetch, and turns on the byline row — the
482
+ * blog is the same SITE, not a second design system, so the header,
483
+ * footer, search, page actions, TOC and every theme token stay
484
+ * identical. See plans/blog-capability.md Phase 3.
485
+ */
486
+ chrome?: "docs" | "blog";
487
+
488
+ /** Post authors. No byline is rendered when absent — never a placeholder. */
489
+ author?: string[];
490
+ /** ISO publish date for the byline. */
491
+ publishedDate?: string;
492
+ /** ISO updated date; shown only when it differs from publishedDate. */
493
+ updatedDate?: string;
494
+ /**
495
+ * Reading estimate in whole minutes. Computed at EMIT time from the
496
+ * TreeNode word count — a browser-side count would re-walk the DOM on
497
+ * every load for a number that cannot change.
498
+ */
499
+ readingMinutes?: number;
500
+ /** Optional hero image URL, rendered above the prose. */
501
+ heroImage?: string;
502
+ /**
503
+ * Table-of-contents placement. Default `"top"`.
504
+ * - `"top"` — expandable "On this page" disclosure at the top of the
505
+ * article, identical on desktop and mobile; frees the right rail for the
506
+ * `right-rail` named slot (e.g. an Ask AI panel).
507
+ * - `"popover"` — an "On this page" dropdown in the header.
508
+ * - `"rail"` — the classic right-hand TOC sidebar (pre-`toc` behaviour).
509
+ * - `"off"` — no table of contents.
510
+ * See plans/ask-branch1-placement-toc.md.
511
+ */
512
+ toc?: TocMode;
513
+ /**
514
+ * Internal/external link-icon glyphs. When set, a small trailing icon
515
+ * marks links in the prose — external (absolute / protocol-relative
516
+ * href) vs internal (root / relative) — classified purely by href
517
+ * shape in CSS. Either side may be absent to mark only that link kind.
518
+ * Sourced from `content.linkIcons` in `dogsbay.config.yml`.
519
+ * See plans/link-resolution-and-icons.md.
520
+ */
521
+ linkIcons?: {
522
+ external?: string;
523
+ internal?: string;
524
+ };
525
+ /**
526
+ * "Powered by DogsBay" footer attribution. Generated sites pass
527
+ * `siteConfig.poweredBy`, which defaults to true and is turned off with
528
+ * `poweredBy: false` in dogsbay.config.yml. See docs/powered-by.md.
529
+ */
530
+ poweredBy?: boolean;
531
+ /**
532
+ * Link previews for readers (`linkPreviews: true` in dogsbay.config.yml, off by default): a card
533
+ * with the target's title, section and excerpt after a moment of hover or keyboard focus on a
534
+ * link in the page's content (`@dogsbay/elements/link-previews`). See docs/link-previews.md.
535
+ */
536
+ linkPreviews?: boolean;
537
+ /**
538
+ * The site's chrome (`chrome` in site.json, format-astro's `chromeData`): logo, colour mode,
539
+ * announcement bar, header links, social icons, footer columns. With it, the header's
540
+ * repository icon is `siteChrome.header.social` (site.repoUrl is its default there), not
541
+ * `repoUrl`. See plans/site-chrome.md.
542
+ */
543
+ siteChrome?: SiteChromeData;
378
544
  class?: string;
379
545
  }
380
546
 
381
547
  const {
548
+ poweredBy = false,
549
+ linkPreviews = false,
550
+ siteChrome,
382
551
  siteName,
552
+ siteTagline,
383
553
  title,
384
554
  siteUrl = "/",
385
555
  nav,
386
556
  navGroups,
387
557
  headings = [],
558
+ toc = "top",
388
559
  prev,
389
560
  next,
390
561
  repoUrl,
@@ -393,42 +564,121 @@ const {
393
564
  editUrl,
394
565
  lastUpdated,
395
566
  copyright,
396
- favicon = "/favicon.ico",
567
+ favicon,
397
568
  ogImage,
398
569
  defaultOgImage,
399
570
  ogType = "article",
400
571
  canonicalUrl,
572
+ alternates = [],
573
+ breadcrumbJsonLd,
401
574
  twitterHandle,
402
575
  themeColor,
403
576
  noindex,
577
+ nofollow,
404
578
  excludeFromSearch,
405
579
  plausibleDomain,
406
580
  plausibleScriptUrl,
407
581
  hideSearch = false,
408
- pagefindUrl = "/pagefind/",
582
+ // No default for pagefindUrl — host-root absolute paths break on
583
+ // subpath-mounted deploys (GH Pages project pages, multi-mount
584
+ // Cloudflare). format-astro's emitter always passes the
585
+ // combined-prefix-aware URL; manual instantiation must too.
586
+ // Undefined here propagates to SearchDialog where the JS loader
587
+ // throws on first open instead of silently 404'ing the bundle.
588
+ pagefindUrl,
589
+ pagefindBaseUrl,
409
590
  mdMirror = false,
410
591
  tags,
411
592
  tagsIndexPath = "/tags",
412
593
  tagPrefixes,
413
594
  tagLabels,
595
+ tagAutoColor = false,
414
596
  status,
415
597
  pageType,
416
598
  audience,
417
599
  category,
418
600
  taxonomies,
601
+ facets,
419
602
  taxonomyIndexPaths,
420
603
  taxonomyDisplay,
421
604
  autoH1,
605
+ versionBadgeWording,
606
+ versionBannerWording,
422
607
  autoLede,
423
608
  llmActions,
424
609
  customJsonLd,
425
610
  multiSource,
426
611
  switcherMap,
427
612
  basePath,
613
+ navMode = "client",
614
+ navScope = "site",
615
+ navLocate,
428
616
  wideLayout = false,
617
+ chrome = "docs",
618
+ author,
619
+ publishedDate,
620
+ updatedDate,
621
+ readingMinutes,
622
+ heroImage,
623
+ linkIcons,
429
624
  class: className,
430
625
  } = Astro.props;
431
626
 
627
+ // The page's search facets: given (format-astro, with the config's hierarchical
628
+ // taxonomies) or mapped here from the props, by the same function either way.
629
+ const pageFacetValues: PageFacets =
630
+ facets ??
631
+ pageFacets(
632
+ { tags, audience, category, status, type: pageType, taxonomies },
633
+ { tagPrefixes, unit: { product: multiSource?.namespace, version: multiSource?.version } },
634
+ );
635
+
636
+ // The version served at the site root (`path: ""`), if any: the sidebar
637
+ // keeps its pages by leaving out the other versions' folders.
638
+ // With a products: block the page carries its version's URL segment, which may
639
+ // differ from its id (`latest`); at the product's root (`""`) its menu leaves
640
+ // out the product's other versions' folders.
641
+ const navRootVersion = multiSource?.versionPath !== undefined
642
+ ? multiSource.versionPath === ""
643
+ ? { rootVersion: multiSource.version, versionSegments: multiSource.siblingVersionPaths ?? [] }
644
+ : {}
645
+ : rootVersionFilter(switcherMap?.versions);
646
+ // "Version: 3.33" above the title, on a version with `badge: true` (Docusaurus's version badge)
647
+ const badgeText = versionBadge(switcherMap as never, multiSource as never, versionBadgeWording);
648
+ // "You are viewing documentation for an older version. Go to the latest version" (dogsbay-ssg's banner)
649
+ const bannerData = versionBanner(switcherMap as never, multiSource as never, versionBannerWording);
650
+ const navVersion = multiSource?.versionPath ? multiSource.versionPath : multiSource?.version;
651
+
652
+ // Section scope (build.navScope: section). In ssr-full the section and its
653
+ // menu are worked out here; in client mode docs-nav-client.ts does the same
654
+ // with the same functions. The home page lists the sections.
655
+ const navHome = basePath || "/";
656
+ const sectionScoped = navScope === "section";
657
+ const ssrSection = sectionScoped && navMode !== "client" && nav
658
+ ? (() => {
659
+ const axisNav = filterNavByAxis(nav, {
660
+ basePath: basePath ?? "/docs",
661
+ namespace: multiSource?.namespace,
662
+ version: navVersion,
663
+ locale: multiSource?.locale,
664
+ ...navRootVersion,
665
+ });
666
+ const opts = { home: navHome };
667
+ // An unlisted page is located by where it sits (navLocate), not by its own path
668
+ const locate = navLocate ?? currentPath;
669
+ return {
670
+ items: scopeNav(axisNav, locate, "section", opts).items,
671
+ switcher: sectionSwitcherHtml({ ...sectionMenu(axisNav, locate, opts), homeHref: navHome }),
672
+ };
673
+ })()
674
+ : undefined;
675
+
676
+ // Link icons — classified in CSS by href shape. `data-link-icons`
677
+ // lists which kinds are active; the glyphs ride in CSS custom props
678
+ // (single-quoted so they're valid `content:` string values).
679
+ const { tokens: _linkIconTokens, style: _linkIconStyle } =
680
+ linkIconAttrs(linkIcons);
681
+
432
682
  // Resolve LLM action visibility + placement once. The component
433
683
  // guards against missing markdownBody / mdUrl internally, but we
434
684
  // also gate at the layout level so the slots stay empty when
@@ -446,6 +696,14 @@ const showLlmActionsInline =
446
696
  llmActionsEnabled
447
697
  && (llmActionsPlacement === "inline" || llmActionsPlacement === "both");
448
698
  const llmFooterLink = !!llmActions && llmActions.footerLink !== false;
699
+ // A header holding links AND the menus (product, version, page actions) is crowded: search and
700
+ // the page actions are icons below 2xl, and below lg the menus wrap to as many rows as they need
701
+ // (the header grows; data-header on <html> sets the height headings jump below). The links sit in
702
+ // the bar from the first width they fit at (headerLinksFrom), in the sidebar below it. Tigera's
703
+ // header needed it: 1280 px broke labels, 390 px scrolled sideways.
704
+ const headerCrowded = chrome === "docs" && !!siteChrome?.header?.links.length && (!!switcherMap || showLlmActionsHeader);
705
+ const linksFrom: LinksFrom = siteChrome?.header?.links.length ? headerLinksFrom(siteChrome.header.links, headerCrowded) : "lg";
706
+ const LINKS_LIST_HIDDEN: Record<LinksFrom, string> = { lg: "lg:hidden", xl: "xl:hidden", "2xl": "2xl:hidden", never: "" };
449
707
  // Per-mount llms.txt URL — Dogsbay emits `<basePath>/llms.txt`
450
708
  // (sitemap-index pattern), so the footer link must be basePath-
451
709
  // prefixed too. Falls back to `/llms.txt` when basePath is empty
@@ -475,20 +733,108 @@ const hasMetaStrip = (
475
733
  (typeof pageType === "string" && pageType.length > 0)
476
734
  );
477
735
 
736
+ // TOC placement: which container(s) + the right-rail plugin region render.
737
+ // Logic lives in toc-placement.ts so it's unit-tested; this file just consumes.
738
+ const tocPlacement = resolveTocPlacement(toc, {
739
+ // Only show a TOC when the page has 2+ displayable headings (depth 2–3);
740
+ // the H1 doesn't count and a one-item TOC is noise. Keeps "On this page"
741
+ // off landing/welcome pages that are just an H1 + prose.
742
+ hasHeadings: hasDisplayableToc(headings),
743
+ wideLayout: !!wideLayout,
744
+ });
745
+
478
746
  const currentPath = Astro.url.pathname.replace(/\/$/, "") || "/";
479
747
 
480
748
  // SEO computation
481
749
  const metaDescription = description ?? siteDescription;
482
750
  const metaOgImage = ogImage ?? defaultOgImage;
483
751
  const isAbsoluteSiteUrl = /^https?:\/\//.test(siteUrl);
752
+ // Compose canonical from ORIGIN + pathname. siteUrl may carry a
753
+ // path component (the urlBase that drives Astro's `base` — see
754
+ // plans/astro-base-from-site-url.md), and Astro.url.pathname
755
+ // already includes that prefix. Naively concatenating siteUrl +
756
+ // pathname double-counts the urlBase (e.g. .../repo/repo/page).
757
+ // Strip path off siteUrl by reparsing as a URL.
758
+ let canonicalOrigin: string | undefined;
759
+ if (isAbsoluteSiteUrl) {
760
+ try {
761
+ const u = new URL(siteUrl);
762
+ canonicalOrigin = `${u.protocol}//${u.host}`;
763
+ } catch {
764
+ // Malformed siteUrl — fall back to the original (no path) behavior.
765
+ canonicalOrigin = siteUrl.replace(/\/$/, "");
766
+ }
767
+ }
484
768
  const computedCanonical = canonicalUrl
485
- ?? (isAbsoluteSiteUrl
486
- ? siteUrl.replace(/\/$/, "") + Astro.url.pathname
769
+ ?? (canonicalOrigin
770
+ ? canonicalOrigin + Astro.url.pathname
487
771
  : undefined);
488
772
 
489
- // Markdown mirror — append `.md` to the current path for the alternate link
773
+ /**
774
+ * Format an ISO date for a byline.
775
+ *
776
+ * Runs at BUILD time, so the output is baked into the HTML and every
777
+ * reader sees the same string — no hydration flash, and no dependence on
778
+ * the visitor's locale for a date the author wrote. Falls back to the
779
+ * raw value if it will not parse, so a typo shows up as itself rather
780
+ * than as "Invalid Date".
781
+ */
782
+ /**
783
+ * A value as a machine-readable ISO 8601 datetime, or "" when it is
784
+ * not a date at all.
785
+ *
786
+ * Unlike `_formatPostDate`, an unparseable value must NOT pass
787
+ * through: this feeds `article:published_time` / `modified_time`,
788
+ * where a malformed datetime is worse than an absent one — a consumer
789
+ * either ignores the whole article object or shows garbage.
790
+ * `lastUpdated` is documented as also accepting a version/tag string
791
+ * ("v2.1"), which must never reach these tags.
792
+ */
793
+ function isoDate(value: string | undefined): string {
794
+ if (!value) return "";
795
+ const d = new Date(value);
796
+ return Number.isNaN(d.getTime()) ? "" : d.toISOString();
797
+ }
798
+
799
+ function _formatPostDate(iso: string): string {
800
+ const d = new Date(iso);
801
+ if (Number.isNaN(d.getTime())) return iso;
802
+ // timeZone: "UTC" is load-bearing. parseMeta normalizes `created:
803
+ // 2026-01-01` to "2026-01-01T00:00:00.000Z", so a build host in any
804
+ // negative-offset zone (the default on many CI runners) would render
805
+ // "31 December 2025". DocsFooter already carries this fix; these
806
+ // copies dropped it.
807
+ return d.toLocaleDateString("en-GB", {
808
+ year: "numeric",
809
+ month: "long",
810
+ day: "numeric",
811
+ timeZone: "UTC",
812
+ });
813
+ }
814
+
815
+ // Markdown mirror for the alternate link.
816
+ //
817
+ // Leaf pages append `.md` to the trimmed path (`/getting-started/` →
818
+ // `/getting-started.md`), matching the emitted `<slug>.md.ts` endpoint.
819
+ // The SITE INDEX is the exception: it is emitted as `index.md.ts`, so
820
+ // its mirror is `<base>/index.md`. Appending `.md` there produced
821
+ // `/.md` (root-served) or `/blog.md` (mounted) — neither exists, and on
822
+ // a mounted site `/blog.md` also falls outside the `/blog/*` route.
823
+ // Both leaf and index URLs carry a trailing slash under Astro's
824
+ // directory build format, so only "is this the site root" distinguishes
825
+ // them. Kept in step with `shouldRewriteToMarkdown`, which is handed the
826
+ // same combined prefix.
827
+ // Use the `basePath` PROP, not import.meta.env.BASE_URL. Astro's `base`
828
+ // carries only site.url's path (urlBase); the prop carries the COMBINED
829
+ // urlBase + site.basePath prefix — the same value the middleware gets —
830
+ // so on a `site.basePath: /docs` deploy the two would otherwise disagree
831
+ // about which page is the index.
832
+ const mdMirrorBase = (basePath ?? "").replace(/\/+$/, "");
833
+ const mdMirrorPath = Astro.url.pathname.replace(/\/$/, "");
490
834
  const mdMirrorHref = mdMirror
491
- ? (Astro.url.pathname.replace(/\/$/, "") || "") + ".md"
835
+ ? mdMirrorPath === mdMirrorBase
836
+ ? `${mdMirrorBase}/index.md`
837
+ : `${mdMirrorPath}.md`
492
838
  : undefined;
493
839
 
494
840
  // Tag keywords for HTML meta + JSON-LD. Slug-based identifiers
@@ -509,17 +855,30 @@ const tagKeywords = resolveTagKeywords(tags, tagLabels);
509
855
  // Course; everything else → Article. Matches the conventions
510
856
  // search engines key off for educational / tutorial / reference
511
857
  // SERP rendering. See `json-ld.ts` for the full mapping table.
512
- const articleJsonLd = (ogType === "article" && tagKeywords.length > 0)
513
- ? {
514
- "@context": "https://schema.org",
515
- "@type": jsonLdTypeFor(pageType),
516
- headline: title,
517
- keywords: tagKeywords.join(", "),
518
- ...(metaDescription ? { description: metaDescription } : {}),
519
- ...(metaOgImage ? { image: metaOgImage } : {}),
520
- ...(computedCanonical ? { url: computedCanonical } : {}),
521
- }
522
- : undefined;
858
+ // Structured data is emitted for EVERY page, not only tagged articles.
859
+ // This used to also require `tagKeywords.length > 0`, so an untagged
860
+ // page — a homepage, a landing page, a section index — emitted none at
861
+ // all. An external agent audit reported "No JSON-LD structured data
862
+ // found on homepage" and it was right: the page most likely to be an
863
+ // agent's entry point was the one describing itself the least.
864
+ // Keywords are enrichment, not a precondition for identity.
865
+ const articleJsonLd = ogType === "article"
866
+ ? buildArticleJsonLd({
867
+ type: jsonLdTypeFor(pageType),
868
+ title,
869
+ siteName,
870
+ keywords: tagKeywords,
871
+ description: metaDescription,
872
+ image: metaOgImage,
873
+ url: computedCanonical,
874
+ headings,
875
+ })
876
+ : buildWebSiteJsonLd({
877
+ siteName,
878
+ title,
879
+ description: metaDescription,
880
+ url: computedCanonical,
881
+ });
523
882
 
524
883
  // `customJsonLd` accepts either a single object or an array.
525
884
  // Normalize to an array so we can iterate uniformly. Empty array
@@ -531,18 +890,146 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
531
890
  ---
532
891
 
533
892
  <!doctype html>
534
- <html lang="en">
893
+ <html lang="en" class:list={[siteChrome?.colorMode === "dark" && "dark"]} data-header={headerCrowded ? "crowded" : undefined}>
535
894
  <head>
895
+ {/* colorMode: dark is in the built page (the html class), so it holds with no script (a sandboxed preview); the head script still honours a stored "light" */}
536
896
  <meta charset="UTF-8" />
537
897
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
538
898
  <title>{title} | {siteName}</title>
539
899
 
900
+ <style is:global>
901
+ /*
902
+ The sticky-chrome contract. This header is exactly this tall, and
903
+ anything else that sticks (the release-comparison toolbar) offsets
904
+ by the same variable — so they cannot drift apart.
905
+ */
906
+ :root {
907
+ --db-header-height: 3rem;
908
+ }
909
+ /*
910
+ A crowded header (links + menus) wraps its menus below 1024 px and grows with them, usually
911
+ to two rows: the variable is that estimate, for what offsets by it, and a heading jumped to
912
+ lands below it (a third row, with a language menu too, can still cover it).
913
+ */
914
+ @media (max-width: 63.99rem) {
915
+ :root[data-header="crowded"] {
916
+ --db-header-height: 5.25rem;
917
+ }
918
+ :root[data-header="crowded"] :is(h1, h2, h3, h4, h5, h6)[id] {
919
+ scroll-margin-top: calc(var(--db-header-height) + 1rem);
920
+ }
921
+ }
922
+
923
+ /*
924
+ Diagrams drawn by Pele (`content.diagrams: pele`, plans/pele-diagrams.md).
925
+ Pele colours its SVGs from these variables, so a diagram takes the theme
926
+ and .dark switches them. Here rather than in Diagram.astro or global.css:
927
+ those are copied into a site once, this package is re-pinned on every
928
+ build. Borders are thin, so the theme's --border alone is too faint for
929
+ node outlines. The base mapping is the same as dogsbay-ssg's ssg.css.
930
+ */
931
+ .pele {
932
+ --pele-bg: var(--background);
933
+ --pele-fg: var(--foreground);
934
+ --pele-muted: var(--muted-foreground);
935
+ --pele-line: var(--foreground);
936
+ --pele-surface: var(--muted);
937
+ --pele-surface-alt: color-mix(in oklab, var(--muted), var(--foreground) 7%);
938
+ --pele-border: color-mix(in oklab, var(--border), var(--muted-foreground) 45%);
939
+ --pele-accent: var(--primary);
940
+ --pele-font: var(--font-sans);
941
+ --pele-font-mono: var(--font-code, monospace);
942
+ --pele-radius: calc(var(--radius) - 4px);
943
+ /*
944
+ Series colours (pie, xy, git, timeline, treemap, …; gantt's critical
945
+ tasks). Pele writes labels in --pele-bg on these fills, so they are
946
+ darker in light mode and lighter in dark mode. Its own palette is
947
+ fixed, and put white text on yellow (1.6:1). Same hues, in Pele's
948
+ order. dogsbay-ssg's ssg.css does not map these yet.
949
+ */
950
+ --pele-series-1: oklch(0.5 0.13 250);
951
+ --pele-series-2: oklch(0.5 0.15 55);
952
+ --pele-series-3: oklch(0.5 0.13 145);
953
+ --pele-series-4: oklch(0.5 0.16 25);
954
+ --pele-series-5: oklch(0.5 0.09 195);
955
+ --pele-series-6: oklch(0.5 0.12 95);
956
+ --pele-series-7: oklch(0.5 0.12 320);
957
+ --pele-series-8: oklch(0.5 0.06 60);
958
+ --pele-critical: var(--pele-series-4);
959
+ --pele-error: var(--pele-series-4);
960
+ }
961
+ .dark .pele {
962
+ --pele-series-1: oklch(0.78 0.13 250);
963
+ --pele-series-2: oklch(0.78 0.15 55);
964
+ --pele-series-3: oklch(0.78 0.13 145);
965
+ --pele-series-4: oklch(0.78 0.16 25);
966
+ --pele-series-5: oklch(0.78 0.09 195);
967
+ --pele-series-6: oklch(0.78 0.12 95);
968
+ --pele-series-7: oklch(0.78 0.12 320);
969
+ --pele-series-8: oklch(0.78 0.06 60);
970
+ }
971
+ /*
972
+ Diagram.astro inverts diagrams in dark mode, for Mermaid's fixed colours;
973
+ Pele's are already dark. Unlayered, so this wins over the dark:invert and
974
+ dark:hue-rotate utilities.
975
+ */
976
+ .diagram-content:has(> svg.pele),
977
+ .diagram-content > svg.pele {
978
+ filter: none;
979
+ }
980
+
981
+ /*
982
+ Internal/external link icons. Opt-in via `content.linkIcons`,
983
+ which sets `data-link-icons` (which kinds are active) and the
984
+ `--db-link-icon-*` custom props (the glyphs) on <body>. Links are
985
+ classified purely by href shape, so it covers both structured
986
+ links and raw-HTML anchors from imported content. Scoped to
987
+ `.docs-prose` so nav/header/footer links are untouched; buttons
988
+ (`<a data-variant>`, from Button.astro) and anything inside `.not-prose` carry no icon.
989
+ */
990
+ body[data-link-icons~="external"] .docs-prose a[href^="http://" i]:not([data-variant], .not-prose, .not-prose *)::after,
991
+ body[data-link-icons~="external"] .docs-prose a[href^="https://" i]:not([data-variant], .not-prose, .not-prose *)::after,
992
+ body[data-link-icons~="external"] .docs-prose a[href^="//"]:not([data-variant], .not-prose, .not-prose *)::after {
993
+ content: var(--db-link-icon-external, "");
994
+ display: inline-block;
995
+ margin-inline-start: 0.15em;
996
+ font-size: 0.85em;
997
+ line-height: 1;
998
+ vertical-align: baseline;
999
+ opacity: 0.7;
1000
+ }
1001
+ body[data-link-icons~="internal"]
1002
+ .docs-prose
1003
+ a[href^="/"]:not([href^="//"]):not([data-variant], .not-prose, .not-prose *)::after,
1004
+ body[data-link-icons~="internal"] .docs-prose a[href^="./"]:not([data-variant], .not-prose, .not-prose *)::after,
1005
+ body[data-link-icons~="internal"] .docs-prose a[href^="../"]:not([data-variant], .not-prose, .not-prose *)::after {
1006
+ content: var(--db-link-icon-internal, "");
1007
+ display: inline-block;
1008
+ margin-inline-start: 0.15em;
1009
+ font-size: 0.85em;
1010
+ line-height: 1;
1011
+ vertical-align: baseline;
1012
+ opacity: 0.7;
1013
+ }
1014
+ </style>
1015
+
540
1016
  {metaDescription && <meta name="description" content={metaDescription} />}
541
- {favicon !== false && <link rel="icon" href={favicon} />}
1017
+ {favicon && <link rel="icon" href={favicon} />}
542
1018
  {themeColor && <meta name="theme-color" content={themeColor} />}
543
1019
  {/* External search engine directive — orthogonal to in-site
544
- Pagefind exclusion. */}
545
- {noindex && <meta name="robots" content="noindex, nofollow" />}
1020
+ Pagefind exclusion. `noindex` + `nofollow` are independent
1021
+ bits per the meta-robots spec; emit only the directives that
1022
+ are set. Combining them when both are set keeps the tag
1023
+ compact (`<meta name="robots" content="noindex, nofollow">`)
1024
+ instead of emitting two tags. */}
1025
+ {(noindex || nofollow) && (
1026
+ <meta
1027
+ name="robots"
1028
+ content={[noindex && "noindex", nofollow && "nofollow"]
1029
+ .filter(Boolean)
1030
+ .join(", ")}
1031
+ />
1032
+ )}
546
1033
 
547
1034
  {/* In-site Pagefind exclusion is wired via two coordinated
548
1035
  attributes on <body> and <main> below — see the prop docs
@@ -556,7 +1043,14 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
556
1043
  sidebar / header / TOC text from per-page excerpts. See main. */}
557
1044
 
558
1045
  {computedCanonical && <link rel="canonical" href={computedCanonical} />}
1046
+ {alternates.map((a) => <link rel="alternate" hreflang={a.hreflang} href={a.href} />)}
559
1047
  {mdMirrorHref && <link rel="alternate" type="text/markdown" href={mdMirrorHref} />}
1048
+ {/* Programmatic llms.txt discovery — agents that follow head
1049
+ link rels get the per-mount llms.txt without parsing HTML.
1050
+ Mirrors the existing _headers Link rel="describedby" used by
1051
+ Cloudflare Pages / Workers. */}
1052
+ <link rel="alternate" type="text/plain" title="llms.txt" href={llmsLinkHrefResolved} />
1053
+ <link rel="describedby" type="text/plain" href={llmsLinkHrefResolved} />
560
1054
 
561
1055
  {/* Open Graph */}
562
1056
  <meta property="og:type" content={ogType} />
@@ -571,13 +1065,36 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
571
1065
  {ogType === "article" && tagKeywords.map((keyword) => (
572
1066
  <meta property="article:tag" content={keyword} />
573
1067
  ))}
1068
+ {/* Article dates. `og:type="article"` was declared with no times
1069
+ at all, which is an incomplete article object — crawlers and
1070
+ social cards had no publish date to show even though the page
1071
+ renders one visibly.
1072
+
1073
+ `article:modified_time` falls back to `lastUpdated`, the prop
1074
+ the docs chrome already uses for "Last updated", so a docs page
1075
+ gets a modified time without the blog-only `updatedDate` being
1076
+ set. Only emitted when the value parses as a date: a
1077
+ frontmatter `lastUpdated: v2.1` is a version string, and a
1078
+ malformed datetime is worse than an absent one. */}
1079
+ {ogType === "article" && isoDate(publishedDate) && (
1080
+ <meta property="article:published_time" content={isoDate(publishedDate)} />
1081
+ )}
1082
+ {ogType === "article" && isoDate(updatedDate ?? lastUpdated) && (
1083
+ <meta
1084
+ property="article:modified_time"
1085
+ content={isoDate(updatedDate ?? lastUpdated)}
1086
+ />
1087
+ )}
574
1088
 
575
1089
  {/* JSON-LD primary block — Article / HowTo / TechArticle /
576
1090
  Course depending on `pageType`. Emits keywords as a
577
1091
  Schema.org keywords string; Google reads this for topical
578
1092
  categorization in rich results. */}
579
1093
  {articleJsonLd && (
580
- <script type="application/ld+json" set:html={JSON.stringify(articleJsonLd)} />
1094
+ <script type="application/ld+json" set:html={JSON.stringify(articleJsonLd).replace(/</g, "\\u003c")} />
1095
+ )}
1096
+ {breadcrumbJsonLd && (
1097
+ <script type="application/ld+json" set:html={JSON.stringify(breadcrumbJsonLd).replace(/</g, "\\u003c")} />
581
1098
  )}
582
1099
 
583
1100
  {/* Per-page / per-site custom structured data. Layered on
@@ -604,30 +1121,84 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
604
1121
  ></script>
605
1122
  )}
606
1123
 
607
- <script is:inline>
608
- if (localStorage.getItem("theme") === "dark") {
609
- document.documentElement.classList.add("dark");
610
- }
611
- </script>
1124
+ {/*
1125
+ Theme bootstrap. Inline and BLOCKING on purpose — it must run
1126
+ before first paint or the page flashes light before going dark.
1127
+
1128
+ An explicit choice wins in BOTH directions. Someone on a
1129
+ dark-mode OS who deliberately picked light must stay light, so
1130
+ "light" is checked rather than treated as "not dark". Only the
1131
+ absence of a stored value falls through to the OS preference.
1132
+
1133
+ That fallback is the point of this block. Previously the only
1134
+ condition was `=== "dark"`, so a visitor whose OS is in dark mode
1135
+ got a light page until they found the toggle — and nothing else
1136
+ in the CSS consulted prefers-color-scheme either. It also made
1137
+ dark mode untestable by any tool that emulates the media query
1138
+ (DevTools' Rendering panel, Playwright's colorScheme), because
1139
+ the page did not read it.
1140
+
1141
+ localStorage access throws in some privacy modes; a throw here
1142
+ would skip the class entirely, so it is guarded and degrades to
1143
+ the OS preference.
1144
+ */}
1145
+ {/*
1146
+ site.colorMode is the first-visit mode (system: the OS preference). @dogsbay/elements' fixed
1147
+ scripts, one per mode: dogsbay-ssg writes the same bytes, so the CSP hashes are shared.
1148
+ */}
1149
+ <script is:inline set:html={COLOR_MODE_HEAD_SCRIPTS[siteChrome?.colorMode ?? "system"] ?? COLOR_MODE_HEAD_SCRIPTS.system} />
1150
+ {/*
1151
+ A closed announcement bar never shows, not even for a frame: @dogsbay/elements' fixed head
1152
+ script (the same bytes dogsbay-ssg uses) reads the bar's id from the meta before it is drawn.
1153
+ */}
1154
+ {siteChrome?.announcement?.closeable && (
1155
+ <>
1156
+ <meta name="db-announcement" content={siteChrome.announcement.key ?? siteChrome.announcement.id} />
1157
+ <script is:inline set:html={ANNOUNCEMENT_HEAD_SCRIPT} />
1158
+ <style is:inline set:html={ANNOUNCEMENT_CSS} />
1159
+ </>
1160
+ )}
612
1161
  <slot name="head" />
613
1162
  </head>
614
1163
  <body
615
1164
  class="bg-background text-foreground antialiased"
616
1165
  data-pagefind-ignore={excludeFromSearch ? "" : undefined}
1166
+ data-link-icons={_linkIconTokens || undefined}
1167
+ style={_linkIconStyle || undefined}
617
1168
  >
618
1169
  <SidebarProvider>
619
- <Sidebar collapsible="icon">
1170
+ {/*
1171
+ chrome="blog" drops the sidebar COLUMN only. SidebarProvider and
1172
+ SidebarInset stay, so the content column, header offset and
1173
+ sticky contract are byte-identical to a docs page — which is what
1174
+ makes the blog read as the same site rather than a lookalike.
1175
+ With no <Sidebar> sibling the inset's peer-* selectors simply do
1176
+ not match and it fills the width.
1177
+ */}
1178
+ {chrome === "docs" && (
1179
+ <Sidebar collapsible="icon" label="Docs">
620
1180
  <SidebarHeader>
621
1181
  <SidebarMenu>
622
1182
  <SidebarMenuItem>
623
- <SidebarMenuButton size="lg" href={siteUrl} isActive={currentPath === siteUrl || currentPath === "/"}>
1183
+ <SidebarMenuButton size="lg" href={basePath || "/"} isActive={currentPath === basePath || currentPath === "/"}>
1184
+ {siteChrome?.logo ? (
1185
+ <>
1186
+ {/* Two images, one hidden by the theme class: no script, no flash */}
1187
+ <img src={siteChrome.logo.light} alt={siteChrome.logo.replacesName ? siteChrome.logo.alt || siteName : ""} class:list={["site-logo h-8 w-auto max-w-[10rem] object-contain object-left", siteChrome.logo.dark && "dark:hidden"]} />
1188
+ {siteChrome.logo.dark && <img src={siteChrome.logo.dark} alt={siteChrome.logo.replacesName ? siteChrome.logo.alt || siteName : ""} class="site-logo hidden h-8 w-auto max-w-[10rem] object-contain object-left dark:block" />}
1189
+ </>
1190
+ ) : (
624
1191
  <div class="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
625
1192
  <Fragment set:html={siteIcon} />
626
1193
  </div>
1194
+ )}
1195
+ {/* A wordmark logo is the name: its alt is the site name, the link's accessible name */}
1196
+ {!siteChrome?.logo?.replacesName && (
627
1197
  <div class="grid flex-1 text-left text-sm leading-tight">
628
1198
  <span class="truncate font-semibold">{siteName}</span>
629
- <span class="truncate text-xs text-sidebar-foreground/70">Documentation</span>
1199
+ <span class="truncate text-xs text-sidebar-foreground/70">{siteTagline || "Documentation"}</span>
630
1200
  </div>
1201
+ )}
631
1202
  </SidebarMenuButton>
632
1203
  </SidebarMenuItem>
633
1204
  </SidebarMenu>
@@ -636,7 +1207,52 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
636
1207
  <SidebarSeparator />
637
1208
 
638
1209
  <SidebarContent>
639
- {navGroups ? (
1210
+ {/* The header's links move here below lg, as Docusaurus moves navbar items into its drawer */}
1211
+ {siteChrome?.header?.links.length ? (
1212
+ <SidebarGroup class={LINKS_LIST_HIDDEN[linksFrom] || undefined}>
1213
+ <SidebarGroupContent>
1214
+ <HeaderLinks links={siteChrome.header.links} layout="list" currentPath={currentPath} />
1215
+ {/* The header's icons too, below md, where the header has no room for them beside the links */}
1216
+ {siteChrome.header.social.length > 0 && (
1217
+ <div class="mt-2 flex flex-wrap items-center gap-1 px-1 md:hidden">
1218
+ <SocialLinks links={siteChrome.header.social} />
1219
+ </div>
1220
+ )}
1221
+ </SidebarGroupContent>
1222
+ </SidebarGroup>
1223
+ ) : null}
1224
+ {navMode === "client" ? (
1225
+ // Client-render mode: emit one DocsNavClient placeholder
1226
+ // inside a single SidebarGroup, regardless of navGroups.
1227
+ // The group-label shape doesn't apply when the tree is
1228
+ // hydrated by JS — multi-group nav is reconstructed
1229
+ // client-side from the same /_dogsbay/nav.json shape.
1230
+ // See plans/client-rendered-nav.md.
1231
+ <SidebarGroup>
1232
+ <SidebarGroupContent>
1233
+ <DocsNavClient
1234
+ currentPath={currentPath}
1235
+ basePath={basePath ?? ""}
1236
+ namespace={multiSource?.namespace}
1237
+ version={navVersion}
1238
+ locale={multiSource?.locale}
1239
+ rootVersion={navRootVersion.rootVersion}
1240
+ versionSegments={navRootVersion.versionSegments}
1241
+ navScope={navScope}
1242
+ home={navHome}
1243
+ locatePath={navLocate}
1244
+ />
1245
+ </SidebarGroupContent>
1246
+ </SidebarGroup>
1247
+ ) : ssrSection ? (
1248
+ // One section's tree under its menu; group labels do not apply.
1249
+ <SidebarGroup>
1250
+ <SidebarGroupContent>
1251
+ <Fragment set:html={ssrSection.switcher} />
1252
+ <SidebarNavTree items={ssrSection.items} currentPath={currentPath} />
1253
+ </SidebarGroupContent>
1254
+ </SidebarGroup>
1255
+ ) : navGroups ? (
640
1256
  navGroups.map(group => (
641
1257
  <SidebarGroup>
642
1258
  <SidebarGroupLabel>{group.label}</SidebarGroupLabel>
@@ -644,8 +1260,10 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
644
1260
  <SidebarNavTree
645
1261
  items={filterNavByAxis(group.items, {
646
1262
  basePath: basePath ?? "/docs",
647
- version: multiSource?.version,
1263
+ namespace: multiSource?.namespace,
1264
+ version: navVersion,
648
1265
  locale: multiSource?.locale,
1266
+ ...navRootVersion,
649
1267
  })}
650
1268
  currentPath={currentPath}
651
1269
  />
@@ -658,8 +1276,10 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
658
1276
  <SidebarNavTree
659
1277
  items={filterNavByAxis(nav, {
660
1278
  basePath: basePath ?? "/docs",
661
- version: multiSource?.version,
1279
+ namespace: multiSource?.namespace,
1280
+ version: navVersion,
662
1281
  locale: multiSource?.locale,
1282
+ ...navRootVersion,
663
1283
  })}
664
1284
  currentPath={currentPath}
665
1285
  />
@@ -670,14 +1290,41 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
670
1290
 
671
1291
  <SidebarRail />
672
1292
  </Sidebar>
1293
+ )}
673
1294
 
674
1295
  <SidebarInset>
675
- <header class="sticky top-0 z-40 flex h-12 shrink-0 items-center gap-2 border-b bg-background/95 px-4 backdrop-blur-sm supports-[backdrop-filter]:bg-background/60">
676
- <SidebarTrigger class="-ml-1" />
1296
+ {/*
1297
+ Height comes from `--db-header-height` (declared on :root in
1298
+ <head>) — the CONTRACT any other sticky chrome offsets by, e.g.
1299
+ the release-comparison toolbar. One variable, so a change here
1300
+ can never leave another sticky bar overlapping or floating.
1301
+ */}
1302
+ {siteChrome?.announcement && <AnnouncementBar announcement={siteChrome.announcement} />}
1303
+ <header class:list={["sticky top-0 z-40 flex shrink-0 items-center gap-2 border-b bg-background/95 px-4 backdrop-blur-sm supports-[backdrop-filter]:bg-background/60", chrome !== "docs" && siteChrome?.header?.links.length ? "min-h-[var(--db-header-height)] flex-wrap py-1" : headerCrowded ? "h-[var(--db-header-height)] max-lg:h-auto max-lg:min-h-12 max-lg:py-1" : "h-[var(--db-header-height)]"]}>
1304
+ {chrome === "docs" && <SidebarTrigger class="-ml-1" />}
677
1305
  <Separator orientation="vertical" class="mr-2 h-4" />
678
- <span class="text-sm text-muted-foreground" data-page-title>{title}</span>
679
- <div class="ml-auto flex items-center gap-2">
1306
+ {/* With header links, the page title shows only below lg, where the links are in the sidebar;
1307
+ a layout with no sidebar keeps the links in the header (wrapping) and no title */}
1308
+ {!(chrome !== "docs" && siteChrome?.header?.links.length) && (
1309
+ <span class:list={["min-w-0 truncate text-sm text-muted-foreground", siteChrome?.header?.links.length && LINKS_LIST_HIDDEN[linksFrom], headerCrowded && "max-lg:hidden"]} data-page-title>{title}</span>
1310
+ )}
1311
+ {siteChrome?.header?.links.length ? <HeaderLinks links={siteChrome.header.links} currentPath={currentPath} wrap={chrome !== "docs"} from={linksFrom} /> : null}
1312
+ {/* The buttons keep their size and the page title truncates instead (squeezed, they widened a phone's
1313
+ page by 23–25px at 390px); a crowded header's menus wrap below lg, so they may shrink. As dogsbay-ssg */}
1314
+ <div class:list={["ml-auto flex min-w-0 items-center gap-2", headerCrowded ? "max-lg:flex-wrap max-lg:justify-end max-lg:gap-y-1" : "shrink-0"]}>
680
1315
  <slot name="header" />
1316
+ {tocPlacement.popoverToc && (
1317
+ <details class="dba-toc-popover relative" data-toc-popover>
1318
+ <summary class="cursor-pointer list-none rounded-md px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-foreground">
1319
+ On this page
1320
+ </summary>
1321
+ <div class="absolute right-0 z-50 mt-1 max-h-[70vh] w-64 overflow-y-auto rounded-md border bg-background p-3 shadow-md">
1322
+ <DocsToc headings={headings} title="" />
1323
+ </div>
1324
+ </details>
1325
+ )}
1326
+ {/* Products before languages and versions, as dogsbay-ssg; also on pages outside every product */}
1327
+ {switcherMap && <ProductSwitcher switcherMap={switcherMap} multiSource={multiSource} />}
681
1328
  {switcherMap && multiSource && (
682
1329
  <LocaleSwitcher
683
1330
  switcherMap={switcherMap}
@@ -699,15 +1346,23 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
699
1346
  providers={llmActions!.providers}
700
1347
  copyButton={llmActions!.copyButton}
701
1348
  promptTemplate={llmActions!.promptTemplate}
1349
+ compact={headerCrowded}
702
1350
  />
703
1351
  )}
704
1352
  {!hideSearch && (
705
1353
  <SearchDialog
706
1354
  pagefindUrl={pagefindUrl}
1355
+ pagefindBaseUrl={pagefindBaseUrl}
1356
+ navUrl={basePath ? `${basePath}/_dogsbay/nav.json` : "/_dogsbay/nav.json"}
707
1357
  taxonomyDisplay={taxonomyDisplay}
1358
+ scopeProduct={multiSource?.namespace}
1359
+ scopeVersion={multiSource?.version}
1360
+ compact={headerCrowded}
708
1361
  />
709
1362
  )}
710
- {repoUrl && (
1363
+ {siteChrome?.header ? (
1364
+ <SocialLinks links={siteChrome.header.social} class={chrome === "docs" && siteChrome.header.links.length ? "max-md:hidden" : undefined} />
1365
+ ) : repoUrl && /^https?:\/\//i.test(repoUrl) && (
711
1366
  <a href={repoUrl} target="_blank" rel="noopener" class="rounded-md p-2 text-muted-foreground hover:bg-accent hover:text-foreground" aria-label="Source repository">
712
1367
  <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/></svg>
713
1368
  </a>
@@ -720,6 +1375,7 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
720
1375
  <main
721
1376
  class="min-w-0 flex-1 px-6 py-8 lg:px-12"
722
1377
  data-pagefind-body={excludeFromSearch ? undefined : ""}
1378
+ data-link-previews={linkPreviews ? "" : undefined}
723
1379
  >
724
1380
  {/*
725
1381
  Pagefind facet filter elements. Placed inside the
@@ -737,30 +1393,18 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
737
1393
  the actual page content. Filter elements live in here
738
1394
  now to stay inside that scope.
739
1395
  */}
740
- {Array.isArray(tags) && tags.map((tag) => (
741
- <div hidden data-pagefind-filter={`tag:${tag}`}></div>
742
- ))}
743
- {Array.isArray(audience) && audience.map((value) => (
744
- <div hidden data-pagefind-filter={`audience:${value}`}></div>
745
- ))}
746
- {Array.isArray(category) && category.map((value) => (
747
- <div hidden data-pagefind-filter={`category:${value}`}></div>
748
- ))}
749
- {status && <div hidden data-pagefind-filter={`status:${status}`}></div>}
750
- {pageType && <div hidden data-pagefind-filter={`type:${pageType}`}></div>}
751
1396
  {/*
752
- Custom-taxonomy filters. Any taxonomy declared in
753
- `dogsbay.config.yml` that isn't one of the five built-ins
754
- flows through here, so `difficulty: intermediate` (etc.)
755
- becomes a real Pagefind facet checkbox automatically.
756
- See plans/beta-launch-followups.md for context.
1397
+ Search facets: one hidden Pagefind filter per facet value, from
1398
+ `pageFacets` (@dogsbay/site-files), the mapping dogsbay-ssg's
1399
+ search index uses too. A tag whose prefix is declared in
1400
+ `taxonomies.tags.prefixes` is a facet of its own (Difficulty,
1401
+ Topic, …); other tags pool under `tag`; audience, category,
1402
+ status and type always; product and version on a multi-product
1403
+ or versioned site; then every declared custom taxonomy. See
1404
+ plans/per-prefix-search-facets.md and plans/page-facets.md.
757
1405
  */}
758
- {taxonomies && Object.entries(taxonomies).flatMap(([name, values]) =>
759
- Array.isArray(values)
760
- ? values.map((value) => (
761
- <div hidden data-pagefind-filter={`${name}:${value}`}></div>
762
- ))
763
- : []
1406
+ {Object.entries(pageFacetValues).flatMap(([name, values]) =>
1407
+ values.map((value) => <div hidden data-pagefind-filter={`${name}:${value}`}></div>)
764
1408
  )}
765
1409
 
766
1410
  <div class:list={["mx-auto", wideLayout ? "max-w-7xl" : "max-w-3xl"]}>
@@ -796,17 +1440,79 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
796
1440
  gets context (title, summary) before classification
797
1441
  (chips), then content.
798
1442
  */}
1443
+ {bannerData && (
1444
+ <div class="not-prose mb-6 rounded-md border border-warning/50 bg-warning/5 px-4 py-2 text-sm text-foreground" role="status" data-version-banner>
1445
+ {bannerData.text}{bannerData.link && (
1446
+ <>{" "}<a href={bannerData.link.href} class="font-medium underline underline-offset-2" data-db-version-link>{bannerData.link.label}</a></>
1447
+ )}
1448
+ </div>
1449
+ )}
1450
+ {badgeText && (
1451
+ <div class="not-prose mb-3" data-version-badge>
1452
+ <span class="inline-flex items-center rounded-md border border-border bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground">{badgeText}</span>
1453
+ </div>
1454
+ )}
799
1455
  {autoH1 && (
800
1456
  <h1 class="text-3xl font-bold tracking-tight mb-2">
801
1457
  {title}
802
1458
  </h1>
803
1459
  )}
1460
+ {/*
1461
+ Byline — blog chrome only, and only when there is
1462
+ something to say. An absent author means NO byline row,
1463
+ never "Unknown": a placeholder byline is worse than none,
1464
+ because it reads as data rather than as a gap.
1465
+
1466
+ Sits between the H1 and the lede so the reader gets
1467
+ attribution before the summary, which is the order a
1468
+ post is scanned in.
1469
+ */}
1470
+ {chrome === "blog" && (author?.length || publishedDate || readingMinutes) && (
1471
+ <div
1472
+ class="not-prose mb-6 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground"
1473
+ data-post-byline
1474
+ data-pagefind-ignore
1475
+ >
1476
+ {author && author.length > 0 && (
1477
+ <span class="font-medium text-foreground">{author.join(", ")}</span>
1478
+ )}
1479
+ {author && author.length > 0 && publishedDate && (
1480
+ <span aria-hidden="true">&middot;</span>
1481
+ )}
1482
+ {publishedDate && (
1483
+ <time datetime={publishedDate}>{_formatPostDate(publishedDate)}</time>
1484
+ )}
1485
+ {publishedDate && readingMinutes && <span aria-hidden="true">&middot;</span>}
1486
+ {readingMinutes && <span>{readingMinutes} min read</span>}
1487
+ {updatedDate && updatedDate !== publishedDate && (
1488
+ <span>
1489
+ &middot; Updated <time datetime={updatedDate}>{_formatPostDate(updatedDate)}</time>
1490
+ </span>
1491
+ )}
1492
+ </div>
1493
+ )}
1494
+
804
1495
  {autoLede && description && (
805
1496
  <p class="text-lg text-muted-foreground mb-6">
806
1497
  {description}
807
1498
  </p>
808
1499
  )}
809
1500
 
1501
+ {/*
1502
+ Hero image. aspect-boxed on purpose — an unsized image
1503
+ above the fold is the classic layout-shift source, and it
1504
+ would shove the prose down after paint.
1505
+ */}
1506
+ {chrome === "blog" && heroImage && (
1507
+ <img
1508
+ src={heroImage}
1509
+ alt=""
1510
+ class="not-prose mb-8 w-full rounded-lg border border-border object-cover aspect-[2/1]"
1511
+ loading="eager"
1512
+ decoding="async"
1513
+ />
1514
+ )}
1515
+
810
1516
  {hasMetaStrip && (
811
1517
  <div
812
1518
  class="not-prose mb-6 flex flex-wrap items-center gap-2"
@@ -830,11 +1536,23 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
830
1536
  indexPath={tagsIndexPath}
831
1537
  prefixes={tagPrefixes}
832
1538
  labels={tagLabels}
1539
+ autoColor={tagAutoColor}
833
1540
  />
834
1541
  )}
835
1542
  </div>
836
1543
  )}
837
1544
 
1545
+ {tocPlacement.topToc && (
1546
+ <details class="dba-toc-top not-prose mb-6 rounded-md border" data-toc-top>
1547
+ <summary class="cursor-pointer list-none px-3 py-2 text-sm font-medium text-muted-foreground">
1548
+ On this page
1549
+ </summary>
1550
+ <div class="border-t px-3 py-2">
1551
+ <DocsToc headings={headings} title="" />
1552
+ </div>
1553
+ </details>
1554
+ )}
1555
+
838
1556
  <slot />
839
1557
 
840
1558
  <DocsFooter
@@ -842,24 +1560,59 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
842
1560
  lastUpdated={lastUpdated}
843
1561
  prev={prev}
844
1562
  next={next}
1563
+ {/*
1564
+ Blog adjacency is chronological, so "Previous/Next"
1565
+ describes the wrong axis. Left is older, right is newer —
1566
+ a timeline runs that way, and so does a series: the
1567
+ right-hand link is the next part.
1568
+ */}
1569
+ prevLabel={chrome === "blog" ? "Older" : undefined}
1570
+ nextLabel={chrome === "blog" ? "Newer" : undefined}
845
1571
  copyright={copyright}
846
1572
  llmsLink={llmFooterLink}
847
1573
  llmsLinkHref={llmsLinkHrefResolved}
1574
+ poweredBy={poweredBy}
1575
+ columns={siteChrome?.footer?.columns}
1576
+ social={siteChrome?.footer?.social}
848
1577
  />
849
1578
  </div>
850
1579
  </main>
851
1580
 
852
- {headings.length > 0 && !wideLayout && (
1581
+ {/* Classic right-hand TOC — only in `toc: rail` mode. */}
1582
+ {tocPlacement.railToc && (
853
1583
  <aside class="sticky top-12 hidden h-[calc(100vh-3rem)] w-56 shrink-0 overflow-y-auto border-l p-4 lg:block">
854
1584
  <DocsToc headings={headings} />
855
1585
  </aside>
856
1586
  )}
1587
+ {/* Right-rail plugin region — host for the `right-rail` named slot
1588
+ (e.g. an Ask AI panel). Rendered in every non-rail mode and not
1589
+ gated on headings, so a plugin can dock on heading-less pages.
1590
+ Hidden when nothing fills it (see the empty-rail style below). */}
1591
+ {tocPlacement.regionRail && (
1592
+ <aside
1593
+ 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"
1594
+ data-right-rail
1595
+ >
1596
+ <slot name="right-rail" />
1597
+ </aside>
1598
+ )}
857
1599
  </div>
858
1600
  </SidebarInset>
859
1601
  </SidebarProvider>
860
1602
  </body>
861
1603
  </html>
862
1604
 
1605
+ <style>
1606
+ /* The right-rail plugin region renders unconditionally in non-rail TOC
1607
+ modes so plugins (e.g. Ask AI) can dock into it. Until something fills
1608
+ the `right-rail` slot it has no element children — hide it so an empty
1609
+ bordered column doesn't show. (:has matches element children only; an
1610
+ unfilled Astro named slot renders none.) */
1611
+ aside[data-right-rail]:not(:has(*)) {
1612
+ display: none;
1613
+ }
1614
+ </style>
1615
+
863
1616
  <script>
864
1617
  import "@dogsbay/ui/sidebar/sidebar.ts";
865
1618
 
@@ -925,3 +1678,21 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
925
1678
  updateActiveNav();
926
1679
  });
927
1680
  </script>
1681
+
1682
+ <script>
1683
+ // Link previews (`linkPreviews: true`): the client is loaded only on a page that asks for it
1684
+ // (`<main data-link-previews>`), once for the visit; it listens on the document, so pages a
1685
+ // client router swaps in are covered. See docs/link-previews.md.
1686
+ let linkPreviewsStarted = false;
1687
+ function startLinkPreviews() {
1688
+ if (linkPreviewsStarted || !document.querySelector("main[data-link-previews]")) return;
1689
+ linkPreviewsStarted = true;
1690
+ import("@dogsbay/elements/link-previews")
1691
+ .then(({ initLinkPreviews }) => initLinkPreviews({ content: "main[data-link-previews] article.docs-prose" }))
1692
+ .catch(() => {
1693
+ linkPreviewsStarted = false;
1694
+ });
1695
+ }
1696
+ startLinkPreviews();
1697
+ document.addEventListener("astro:page-load", startLinkPreviews);
1698
+ </script>