@dogsbay/docs-layout 0.2.0-beta.15 → 0.2.0-beta.150

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,12 @@ 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 { resolveTocPlacement, hasDisplayableToc, type TocMode } from "./toc-placement.js";
39
+ import { linkIconAttrs } from "./link-icons.js";
37
40
  import DocsFooter from "./DocsFooter.astro";
38
41
  import SearchDialog from "./SearchDialog.astro";
39
42
  import TagList from "./TagList.astro";
@@ -41,10 +44,18 @@ import StatusBadge from "./StatusBadge.astro";
41
44
  import TypeBadge from "./TypeBadge.astro";
42
45
  import PageActions from "./PageActions.astro";
43
46
  import VersionSwitcher from "./VersionSwitcher.astro";
47
+ import ProductSwitcher from "./ProductSwitcher.astro";
48
+ import AnnouncementBar from "./AnnouncementBar.astro";
49
+ import HeaderLinks from "./HeaderLinks.astro";
50
+ import SocialLinks from "./SocialLinks.astro";
51
+ import type { SiteChromeData } from "./site-chrome.js";
52
+ import { COLOR_MODE_HEAD_SCRIPTS } from "@dogsbay/elements/color-mode-head";
53
+ import { ANNOUNCEMENT_CSS, ANNOUNCEMENT_HEAD_SCRIPT } from "@dogsbay/elements/announcement-head";
44
54
  import LocaleSwitcher from "./LocaleSwitcher.astro";
45
- import { filterNavByAxis } from "./nav-filter.js";
55
+ import { filterNavByAxis, rootVersionFilter } from "./nav-filter.js";
56
+ import { versionBadge } from "./switcher.js";
46
57
  import type { LlmProviderName } from "./llm-actions.js";
47
- import { jsonLdTypeFor, normalizeCustomJsonLd } from "./json-ld.js";
58
+ import { jsonLdTypeFor, normalizeCustomJsonLd, buildArticleJsonLd, buildWebSiteJsonLd } from "./json-ld.js";
48
59
  import { resolveTagKeywords } from "./tag-list-data.js";
49
60
 
50
61
  interface NavItem {
@@ -86,6 +97,8 @@ type TagPaletteName =
86
97
  interface Props {
87
98
  /** Site name shown in header and sidebar logo */
88
99
  siteName: string;
100
+ /** The line under the site name in the sidebar header (`site.tagline`). Default "Documentation". */
101
+ siteTagline?: string;
89
102
  /** Page title for <title> tag */
90
103
  title: string;
91
104
  /** Home URL — also used as the base for the canonical link if absolute */
@@ -112,7 +125,13 @@ interface Props {
112
125
  siteDescription?: string;
113
126
  /** Copyright text (HTML allowed) */
114
127
  copyright?: string;
115
- /** Favicon path (default: "/favicon.ico"). Set to false to disable. */
128
+ /**
129
+ * Favicon path. No host-root default — that 404s on subpath
130
+ * deploys. The format-astro emitter passes a combined-prefix
131
+ * path (e.g. `/<repo>/favicon.ico`) computed from site.url +
132
+ * basePath. Pass an empty string or `false` to disable. When
133
+ * undefined, no `<link rel="icon">` is emitted.
134
+ */
116
135
  favicon?: string | false;
117
136
  /** Per-page OG image URL. Overrides defaultOgImage. */
118
137
  ogImage?: string;
@@ -122,21 +141,34 @@ interface Props {
122
141
  ogType?: "article" | "website";
123
142
  /** Canonical URL for this page. Auto-computed from siteUrl + pathname when absolute siteUrl is provided. */
124
143
  canonicalUrl?: string;
144
+ /** `hreflang` alternates for this page's copies in other languages (absolute URLs), written after the canonical link. */
145
+ alternates?: { hreflang: string; href: string }[];
146
+ /** JSON-LD `BreadcrumbList` for this page, written after its own JSON-LD block. */
147
+ breadcrumbJsonLd?: Record<string, unknown>;
125
148
  /** Twitter / X handle including the leading "@" */
126
149
  twitterHandle?: string;
127
150
  /** Theme color hint for browsers (hex string) */
128
151
  themeColor?: string;
129
152
  /**
130
- * Emit `<meta name="robots" content="noindex, nofollow">` when
153
+ * Emit `noindex` in the `<meta name="robots">` directive when
131
154
  * 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.
155
+ * indexing this page. Independent of `nofollow` — common pattern
156
+ * for tag / index pages is noindex + follow (don't list this
157
+ * page in results, but do crawl through to the real content).
158
+ *
159
+ * Has NO effect on in-site Pagefind search — for that, use
160
+ * `excludeFromSearch`. The two are independent: a page can be
161
+ * excluded from external SEs but still appear in Pagefind (e.g.
162
+ * duplicate / old content readers might still want to find when
163
+ * they're already on the site), or vice versa.
138
164
  */
139
165
  noindex?: boolean;
166
+ /**
167
+ * Emit `nofollow` in the `<meta name="robots">` directive when
168
+ * true. Tells crawlers not to follow outbound links from this
169
+ * page. Independent of `noindex`. Default false.
170
+ */
171
+ nofollow?: boolean;
140
172
  /**
141
173
  * Exclude this page from in-site Pagefind search results.
142
174
  *
@@ -179,6 +211,12 @@ interface Props {
179
211
  * a non-root base path (e.g. "/docs/pagefind/").
180
212
  */
181
213
  pagefindUrl?: string;
214
+ /**
215
+ * Base Pagefind prefixes result URLs with. Forwarded to SearchDialog;
216
+ * format-astro passes the right value for the deploy layout. See
217
+ * `pagefind-base-url.ts` for why no constant works.
218
+ */
219
+ pagefindBaseUrl?: string;
182
220
  /**
183
221
  * Whether the site emits per-page `.md` mirror endpoints. When true,
184
222
  * the page advertises `<link rel="alternate" type="text/markdown">`
@@ -213,6 +251,12 @@ interface Props {
213
251
  * `taxonomies.tags.labels`.
214
252
  */
215
253
  tagLabels?: Record<string, string>;
254
+ /**
255
+ * Color chips whose prefix has no color automatically (a stable
256
+ * palette color per first segment). Sourced from
257
+ * `taxonomies.tags.autoColor`.
258
+ */
259
+ tagAutoColor?: boolean;
216
260
  /**
217
261
  * Page lifecycle status. Renders a StatusBadge for non-stable
218
262
  * states. Drafts/deprecated get strong colors.
@@ -302,6 +346,12 @@ interface Props {
302
346
  * opt in. See plans/auto-lede.md.
303
347
  */
304
348
  autoH1?: boolean;
349
+ /**
350
+ * The version badge's wording on a page whose version has `badge: true`
351
+ * (`{label}` is the version's label). Default "Version: {label}", as
352
+ * dogsbay-ssg's English `versionBadge` string.
353
+ */
354
+ versionBadgeWording?: string;
305
355
  /**
306
356
  * When `true`, render `<p>{description}</p>` below the auto H1
307
357
  * (or above the meta strip when there's no H1) — used when the
@@ -324,6 +374,10 @@ interface Props {
324
374
  version?: string;
325
375
  locale?: string;
326
376
  originalSlug: string;
377
+ /** With a `products:` block: the version's URL segment (`latest`, or `""` at the product's root). */
378
+ versionPath?: string;
379
+ /** With a `products:` block: the product's other versions' URL segments. */
380
+ siblingVersionPaths?: string[];
327
381
  };
328
382
  /**
329
383
  * Switcher data emitted by format-astro's `emitSwitcherMap`.
@@ -333,7 +387,7 @@ interface Props {
333
387
  * `@/data/switcherMap.json`.
334
388
  */
335
389
  switcherMap?: {
336
- versions: Array<{ id: string; label?: string; eol?: boolean; default?: boolean }>;
390
+ versions: Array<{ id: string; label?: string; eol?: boolean; default?: boolean; root?: boolean }>;
337
391
  byLogicalKey: Record<string, Record<string, string>>;
338
392
  };
339
393
  /**
@@ -341,6 +395,19 @@ interface Props {
341
395
  * (`<basePath>/<version>/`). Defaults to "/docs".
342
396
  */
343
397
  basePath?: string;
398
+ /**
399
+ * Sidebar navigation render mode.
400
+ *
401
+ * - `"client"` (default): emit the small `<DocsNavClient />` placeholder;
402
+ * the tree is hydrated from `/_dogsbay/nav.json` once per session.
403
+ * Page HTML shrinks dramatically at scale (~50 KB vs ~1.2 MB on a
404
+ * 2k-page site). No-JS users see a sitemap fallback link.
405
+ * - `"ssr-full"`: render the full nav tree into every page's HTML.
406
+ * Best for very small sites or strict no-JS / SEO contexts.
407
+ *
408
+ * See plans/client-rendered-nav.md.
409
+ */
410
+ navMode?: "client" | "ssr-full";
344
411
  /**
345
412
  * Per-page LLM action UI. When set and `enabled !== false`, renders
346
413
  * the PageActions cluster (Copy markdown + Open in Claude/ChatGPT/
@@ -375,16 +442,82 @@ interface Props {
375
442
  * in per-page.
376
443
  */
377
444
  wideLayout?: boolean;
445
+
446
+ /**
447
+ * Which chrome this page wears.
448
+ *
449
+ * `"docs"` (default) is the full documentation shell. `"blog"` drops
450
+ * the sidebar and its nav fetch, and turns on the byline row — the
451
+ * blog is the same SITE, not a second design system, so the header,
452
+ * footer, search, page actions, TOC and every theme token stay
453
+ * identical. See plans/blog-capability.md Phase 3.
454
+ */
455
+ chrome?: "docs" | "blog";
456
+
457
+ /** Post authors. No byline is rendered when absent — never a placeholder. */
458
+ author?: string[];
459
+ /** ISO publish date for the byline. */
460
+ publishedDate?: string;
461
+ /** ISO updated date; shown only when it differs from publishedDate. */
462
+ updatedDate?: string;
463
+ /**
464
+ * Reading estimate in whole minutes. Computed at EMIT time from the
465
+ * TreeNode word count — a browser-side count would re-walk the DOM on
466
+ * every load for a number that cannot change.
467
+ */
468
+ readingMinutes?: number;
469
+ /** Optional hero image URL, rendered above the prose. */
470
+ heroImage?: string;
471
+ /**
472
+ * Table-of-contents placement. Default `"top"`.
473
+ * - `"top"` — expandable "On this page" disclosure at the top of the
474
+ * article, identical on desktop and mobile; frees the right rail for the
475
+ * `right-rail` named slot (e.g. an Ask AI panel).
476
+ * - `"popover"` — an "On this page" dropdown in the header.
477
+ * - `"rail"` — the classic right-hand TOC sidebar (pre-`toc` behaviour).
478
+ * - `"off"` — no table of contents.
479
+ * See plans/ask-branch1-placement-toc.md.
480
+ */
481
+ toc?: TocMode;
482
+ /**
483
+ * Internal/external link-icon glyphs. When set, a small trailing icon
484
+ * marks links in the prose — external (absolute / protocol-relative
485
+ * href) vs internal (root / relative) — classified purely by href
486
+ * shape in CSS. Either side may be absent to mark only that link kind.
487
+ * Sourced from `content.linkIcons` in `dogsbay.config.yml`.
488
+ * See plans/link-resolution-and-icons.md.
489
+ */
490
+ linkIcons?: {
491
+ external?: string;
492
+ internal?: string;
493
+ };
494
+ /**
495
+ * "Powered by DogsBay" footer attribution. Generated sites pass
496
+ * `siteConfig.poweredBy`, which defaults to true and is turned off with
497
+ * `poweredBy: false` in dogsbay.config.yml. See docs/powered-by.md.
498
+ */
499
+ poweredBy?: boolean;
500
+ /**
501
+ * The site's chrome (`chrome` in site.json, format-astro's `chromeData`): logo, colour mode,
502
+ * announcement bar, header links, social icons, footer columns. With it, the header's
503
+ * repository icon is `siteChrome.header.social` (site.repoUrl is its default there), not
504
+ * `repoUrl`. See plans/site-chrome.md.
505
+ */
506
+ siteChrome?: SiteChromeData;
378
507
  class?: string;
379
508
  }
380
509
 
381
510
  const {
511
+ poweredBy = false,
512
+ siteChrome,
382
513
  siteName,
514
+ siteTagline,
383
515
  title,
384
516
  siteUrl = "/",
385
517
  nav,
386
518
  navGroups,
387
519
  headings = [],
520
+ toc = "top",
388
521
  prev,
389
522
  next,
390
523
  repoUrl,
@@ -393,24 +526,35 @@ const {
393
526
  editUrl,
394
527
  lastUpdated,
395
528
  copyright,
396
- favicon = "/favicon.ico",
529
+ favicon,
397
530
  ogImage,
398
531
  defaultOgImage,
399
532
  ogType = "article",
400
533
  canonicalUrl,
534
+ alternates = [],
535
+ breadcrumbJsonLd,
401
536
  twitterHandle,
402
537
  themeColor,
403
538
  noindex,
539
+ nofollow,
404
540
  excludeFromSearch,
405
541
  plausibleDomain,
406
542
  plausibleScriptUrl,
407
543
  hideSearch = false,
408
- pagefindUrl = "/pagefind/",
544
+ // No default for pagefindUrl — host-root absolute paths break on
545
+ // subpath-mounted deploys (GH Pages project pages, multi-mount
546
+ // Cloudflare). format-astro's emitter always passes the
547
+ // combined-prefix-aware URL; manual instantiation must too.
548
+ // Undefined here propagates to SearchDialog where the JS loader
549
+ // throws on first open instead of silently 404'ing the bundle.
550
+ pagefindUrl,
551
+ pagefindBaseUrl,
409
552
  mdMirror = false,
410
553
  tags,
411
554
  tagsIndexPath = "/tags",
412
555
  tagPrefixes,
413
556
  tagLabels,
557
+ tagAutoColor = false,
414
558
  status,
415
559
  pageType,
416
560
  audience,
@@ -419,16 +563,45 @@ const {
419
563
  taxonomyIndexPaths,
420
564
  taxonomyDisplay,
421
565
  autoH1,
566
+ versionBadgeWording,
422
567
  autoLede,
423
568
  llmActions,
424
569
  customJsonLd,
425
570
  multiSource,
426
571
  switcherMap,
427
572
  basePath,
573
+ navMode = "client",
428
574
  wideLayout = false,
575
+ chrome = "docs",
576
+ author,
577
+ publishedDate,
578
+ updatedDate,
579
+ readingMinutes,
580
+ heroImage,
581
+ linkIcons,
429
582
  class: className,
430
583
  } = Astro.props;
431
584
 
585
+ // The version served at the site root (`path: ""`), if any: the sidebar
586
+ // keeps its pages by leaving out the other versions' folders.
587
+ // With a products: block the page carries its version's URL segment, which may
588
+ // differ from its id (`latest`); at the product's root (`""`) its menu leaves
589
+ // out the product's other versions' folders.
590
+ const navRootVersion = multiSource?.versionPath !== undefined
591
+ ? multiSource.versionPath === ""
592
+ ? { rootVersion: multiSource.version, versionSegments: multiSource.siblingVersionPaths ?? [] }
593
+ : {}
594
+ : rootVersionFilter(switcherMap?.versions);
595
+ // "Version: 3.33" above the title, on a version with `badge: true` (Docusaurus's version badge)
596
+ const badgeText = versionBadge(switcherMap as never, multiSource as never, versionBadgeWording);
597
+ const navVersion = multiSource?.versionPath ? multiSource.versionPath : multiSource?.version;
598
+
599
+ // Link icons — classified in CSS by href shape. `data-link-icons`
600
+ // lists which kinds are active; the glyphs ride in CSS custom props
601
+ // (single-quoted so they're valid `content:` string values).
602
+ const { tokens: _linkIconTokens, style: _linkIconStyle } =
603
+ linkIconAttrs(linkIcons);
604
+
432
605
  // Resolve LLM action visibility + placement once. The component
433
606
  // guards against missing markdownBody / mdUrl internally, but we
434
607
  // also gate at the layout level so the slots stay empty when
@@ -475,20 +648,108 @@ const hasMetaStrip = (
475
648
  (typeof pageType === "string" && pageType.length > 0)
476
649
  );
477
650
 
651
+ // TOC placement: which container(s) + the right-rail plugin region render.
652
+ // Logic lives in toc-placement.ts so it's unit-tested; this file just consumes.
653
+ const tocPlacement = resolveTocPlacement(toc, {
654
+ // Only show a TOC when the page has 2+ displayable headings (depth 2–3);
655
+ // the H1 doesn't count and a one-item TOC is noise. Keeps "On this page"
656
+ // off landing/welcome pages that are just an H1 + prose.
657
+ hasHeadings: hasDisplayableToc(headings),
658
+ wideLayout: !!wideLayout,
659
+ });
660
+
478
661
  const currentPath = Astro.url.pathname.replace(/\/$/, "") || "/";
479
662
 
480
663
  // SEO computation
481
664
  const metaDescription = description ?? siteDescription;
482
665
  const metaOgImage = ogImage ?? defaultOgImage;
483
666
  const isAbsoluteSiteUrl = /^https?:\/\//.test(siteUrl);
667
+ // Compose canonical from ORIGIN + pathname. siteUrl may carry a
668
+ // path component (the urlBase that drives Astro's `base` — see
669
+ // plans/astro-base-from-site-url.md), and Astro.url.pathname
670
+ // already includes that prefix. Naively concatenating siteUrl +
671
+ // pathname double-counts the urlBase (e.g. .../repo/repo/page).
672
+ // Strip path off siteUrl by reparsing as a URL.
673
+ let canonicalOrigin: string | undefined;
674
+ if (isAbsoluteSiteUrl) {
675
+ try {
676
+ const u = new URL(siteUrl);
677
+ canonicalOrigin = `${u.protocol}//${u.host}`;
678
+ } catch {
679
+ // Malformed siteUrl — fall back to the original (no path) behavior.
680
+ canonicalOrigin = siteUrl.replace(/\/$/, "");
681
+ }
682
+ }
484
683
  const computedCanonical = canonicalUrl
485
- ?? (isAbsoluteSiteUrl
486
- ? siteUrl.replace(/\/$/, "") + Astro.url.pathname
684
+ ?? (canonicalOrigin
685
+ ? canonicalOrigin + Astro.url.pathname
487
686
  : undefined);
488
687
 
489
- // Markdown mirror — append `.md` to the current path for the alternate link
688
+ /**
689
+ * Format an ISO date for a byline.
690
+ *
691
+ * Runs at BUILD time, so the output is baked into the HTML and every
692
+ * reader sees the same string — no hydration flash, and no dependence on
693
+ * the visitor's locale for a date the author wrote. Falls back to the
694
+ * raw value if it will not parse, so a typo shows up as itself rather
695
+ * than as "Invalid Date".
696
+ */
697
+ /**
698
+ * A value as a machine-readable ISO 8601 datetime, or "" when it is
699
+ * not a date at all.
700
+ *
701
+ * Unlike `_formatPostDate`, an unparseable value must NOT pass
702
+ * through: this feeds `article:published_time` / `modified_time`,
703
+ * where a malformed datetime is worse than an absent one — a consumer
704
+ * either ignores the whole article object or shows garbage.
705
+ * `lastUpdated` is documented as also accepting a version/tag string
706
+ * ("v2.1"), which must never reach these tags.
707
+ */
708
+ function isoDate(value: string | undefined): string {
709
+ if (!value) return "";
710
+ const d = new Date(value);
711
+ return Number.isNaN(d.getTime()) ? "" : d.toISOString();
712
+ }
713
+
714
+ function _formatPostDate(iso: string): string {
715
+ const d = new Date(iso);
716
+ if (Number.isNaN(d.getTime())) return iso;
717
+ // timeZone: "UTC" is load-bearing. parseMeta normalizes `created:
718
+ // 2026-01-01` to "2026-01-01T00:00:00.000Z", so a build host in any
719
+ // negative-offset zone (the default on many CI runners) would render
720
+ // "31 December 2025". DocsFooter already carries this fix; these
721
+ // copies dropped it.
722
+ return d.toLocaleDateString("en-GB", {
723
+ year: "numeric",
724
+ month: "long",
725
+ day: "numeric",
726
+ timeZone: "UTC",
727
+ });
728
+ }
729
+
730
+ // Markdown mirror for the alternate link.
731
+ //
732
+ // Leaf pages append `.md` to the trimmed path (`/getting-started/` →
733
+ // `/getting-started.md`), matching the emitted `<slug>.md.ts` endpoint.
734
+ // The SITE INDEX is the exception: it is emitted as `index.md.ts`, so
735
+ // its mirror is `<base>/index.md`. Appending `.md` there produced
736
+ // `/.md` (root-served) or `/blog.md` (mounted) — neither exists, and on
737
+ // a mounted site `/blog.md` also falls outside the `/blog/*` route.
738
+ // Both leaf and index URLs carry a trailing slash under Astro's
739
+ // directory build format, so only "is this the site root" distinguishes
740
+ // them. Kept in step with `shouldRewriteToMarkdown`, which is handed the
741
+ // same combined prefix.
742
+ // Use the `basePath` PROP, not import.meta.env.BASE_URL. Astro's `base`
743
+ // carries only site.url's path (urlBase); the prop carries the COMBINED
744
+ // urlBase + site.basePath prefix — the same value the middleware gets —
745
+ // so on a `site.basePath: /docs` deploy the two would otherwise disagree
746
+ // about which page is the index.
747
+ const mdMirrorBase = (basePath ?? "").replace(/\/+$/, "");
748
+ const mdMirrorPath = Astro.url.pathname.replace(/\/$/, "");
490
749
  const mdMirrorHref = mdMirror
491
- ? (Astro.url.pathname.replace(/\/$/, "") || "") + ".md"
750
+ ? mdMirrorPath === mdMirrorBase
751
+ ? `${mdMirrorBase}/index.md`
752
+ : `${mdMirrorPath}.md`
492
753
  : undefined;
493
754
 
494
755
  // Tag keywords for HTML meta + JSON-LD. Slug-based identifiers
@@ -509,17 +770,30 @@ const tagKeywords = resolveTagKeywords(tags, tagLabels);
509
770
  // Course; everything else → Article. Matches the conventions
510
771
  // search engines key off for educational / tutorial / reference
511
772
  // 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;
773
+ // Structured data is emitted for EVERY page, not only tagged articles.
774
+ // This used to also require `tagKeywords.length > 0`, so an untagged
775
+ // page — a homepage, a landing page, a section index — emitted none at
776
+ // all. An external agent audit reported "No JSON-LD structured data
777
+ // found on homepage" and it was right: the page most likely to be an
778
+ // agent's entry point was the one describing itself the least.
779
+ // Keywords are enrichment, not a precondition for identity.
780
+ const articleJsonLd = ogType === "article"
781
+ ? buildArticleJsonLd({
782
+ type: jsonLdTypeFor(pageType),
783
+ title,
784
+ siteName,
785
+ keywords: tagKeywords,
786
+ description: metaDescription,
787
+ image: metaOgImage,
788
+ url: computedCanonical,
789
+ headings,
790
+ })
791
+ : buildWebSiteJsonLd({
792
+ siteName,
793
+ title,
794
+ description: metaDescription,
795
+ url: computedCanonical,
796
+ });
523
797
 
524
798
  // `customJsonLd` accepts either a single object or an array.
525
799
  // Normalize to an array so we can iterate uniformly. Empty array
@@ -537,12 +811,126 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
537
811
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
538
812
  <title>{title} | {siteName}</title>
539
813
 
814
+ <style is:global>
815
+ /*
816
+ The sticky-chrome contract. This header is exactly this tall, and
817
+ anything else that sticks (the release-comparison toolbar) offsets
818
+ by the same variable — so they cannot drift apart.
819
+ */
820
+ :root {
821
+ --db-header-height: 3rem;
822
+ }
823
+
824
+ /*
825
+ Diagrams drawn by Pele (`content.diagrams: pele`, plans/pele-diagrams.md).
826
+ Pele colours its SVGs from these variables, so a diagram takes the theme
827
+ and .dark switches them. Here rather than in Diagram.astro or global.css:
828
+ those are copied into a site once, this package is re-pinned on every
829
+ build. Borders are thin, so the theme's --border alone is too faint for
830
+ node outlines. The base mapping is the same as dogsbay-ssg's ssg.css.
831
+ */
832
+ .pele {
833
+ --pele-bg: var(--background);
834
+ --pele-fg: var(--foreground);
835
+ --pele-muted: var(--muted-foreground);
836
+ --pele-line: var(--foreground);
837
+ --pele-surface: var(--muted);
838
+ --pele-surface-alt: color-mix(in oklab, var(--muted), var(--foreground) 7%);
839
+ --pele-border: color-mix(in oklab, var(--border), var(--muted-foreground) 45%);
840
+ --pele-accent: var(--primary);
841
+ --pele-font: var(--font-sans);
842
+ --pele-font-mono: var(--font-code, monospace);
843
+ --pele-radius: calc(var(--radius) - 4px);
844
+ /*
845
+ Series colours (pie, xy, git, timeline, treemap, …; gantt's critical
846
+ tasks). Pele writes labels in --pele-bg on these fills, so they are
847
+ darker in light mode and lighter in dark mode. Its own palette is
848
+ fixed, and put white text on yellow (1.6:1). Same hues, in Pele's
849
+ order. dogsbay-ssg's ssg.css does not map these yet.
850
+ */
851
+ --pele-series-1: oklch(0.5 0.13 250);
852
+ --pele-series-2: oklch(0.5 0.15 55);
853
+ --pele-series-3: oklch(0.5 0.13 145);
854
+ --pele-series-4: oklch(0.5 0.16 25);
855
+ --pele-series-5: oklch(0.5 0.09 195);
856
+ --pele-series-6: oklch(0.5 0.12 95);
857
+ --pele-series-7: oklch(0.5 0.12 320);
858
+ --pele-series-8: oklch(0.5 0.06 60);
859
+ --pele-critical: var(--pele-series-4);
860
+ --pele-error: var(--pele-series-4);
861
+ }
862
+ .dark .pele {
863
+ --pele-series-1: oklch(0.78 0.13 250);
864
+ --pele-series-2: oklch(0.78 0.15 55);
865
+ --pele-series-3: oklch(0.78 0.13 145);
866
+ --pele-series-4: oklch(0.78 0.16 25);
867
+ --pele-series-5: oklch(0.78 0.09 195);
868
+ --pele-series-6: oklch(0.78 0.12 95);
869
+ --pele-series-7: oklch(0.78 0.12 320);
870
+ --pele-series-8: oklch(0.78 0.06 60);
871
+ }
872
+ /*
873
+ Diagram.astro inverts diagrams in dark mode, for Mermaid's fixed colours;
874
+ Pele's are already dark. Unlayered, so this wins over the dark:invert and
875
+ dark:hue-rotate utilities.
876
+ */
877
+ .diagram-content:has(> svg.pele),
878
+ .diagram-content > svg.pele {
879
+ filter: none;
880
+ }
881
+
882
+ /*
883
+ Internal/external link icons. Opt-in via `content.linkIcons`,
884
+ which sets `data-link-icons` (which kinds are active) and the
885
+ `--db-link-icon-*` custom props (the glyphs) on <body>. Links are
886
+ classified purely by href shape, so it covers both structured
887
+ links and raw-HTML anchors from imported content. Scoped to
888
+ `.docs-prose` so nav/header/footer links are untouched; buttons
889
+ (`<a data-variant>`, from Button.astro) carry no icon.
890
+ */
891
+ body[data-link-icons~="external"] .docs-prose a[href^="http://" i]:not([data-variant])::after,
892
+ body[data-link-icons~="external"] .docs-prose a[href^="https://" i]:not([data-variant])::after,
893
+ body[data-link-icons~="external"] .docs-prose a[href^="//"]:not([data-variant])::after {
894
+ content: var(--db-link-icon-external, "");
895
+ display: inline-block;
896
+ margin-inline-start: 0.15em;
897
+ font-size: 0.85em;
898
+ line-height: 1;
899
+ vertical-align: baseline;
900
+ opacity: 0.7;
901
+ }
902
+ body[data-link-icons~="internal"]
903
+ .docs-prose
904
+ a[href^="/"]:not([href^="//"]):not([data-variant])::after,
905
+ body[data-link-icons~="internal"] .docs-prose a[href^="./"]:not([data-variant])::after,
906
+ body[data-link-icons~="internal"] .docs-prose a[href^="../"]:not([data-variant])::after {
907
+ content: var(--db-link-icon-internal, "");
908
+ display: inline-block;
909
+ margin-inline-start: 0.15em;
910
+ font-size: 0.85em;
911
+ line-height: 1;
912
+ vertical-align: baseline;
913
+ opacity: 0.7;
914
+ }
915
+ </style>
916
+
540
917
  {metaDescription && <meta name="description" content={metaDescription} />}
541
- {favicon !== false && <link rel="icon" href={favicon} />}
918
+ {favicon && <link rel="icon" href={favicon} />}
542
919
  {themeColor && <meta name="theme-color" content={themeColor} />}
543
920
  {/* External search engine directive — orthogonal to in-site
544
- Pagefind exclusion. */}
545
- {noindex && <meta name="robots" content="noindex, nofollow" />}
921
+ Pagefind exclusion. `noindex` + `nofollow` are independent
922
+ bits per the meta-robots spec; emit only the directives that
923
+ are set. Combining them when both are set keeps the tag
924
+ compact (`<meta name="robots" content="noindex, nofollow">`)
925
+ instead of emitting two tags. */}
926
+ {(noindex || nofollow) && (
927
+ <meta
928
+ name="robots"
929
+ content={[noindex && "noindex", nofollow && "nofollow"]
930
+ .filter(Boolean)
931
+ .join(", ")}
932
+ />
933
+ )}
546
934
 
547
935
  {/* In-site Pagefind exclusion is wired via two coordinated
548
936
  attributes on <body> and <main> below — see the prop docs
@@ -556,7 +944,14 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
556
944
  sidebar / header / TOC text from per-page excerpts. See main. */}
557
945
 
558
946
  {computedCanonical && <link rel="canonical" href={computedCanonical} />}
947
+ {alternates.map((a) => <link rel="alternate" hreflang={a.hreflang} href={a.href} />)}
559
948
  {mdMirrorHref && <link rel="alternate" type="text/markdown" href={mdMirrorHref} />}
949
+ {/* Programmatic llms.txt discovery — agents that follow head
950
+ link rels get the per-mount llms.txt without parsing HTML.
951
+ Mirrors the existing _headers Link rel="describedby" used by
952
+ Cloudflare Pages / Workers. */}
953
+ <link rel="alternate" type="text/plain" title="llms.txt" href={llmsLinkHrefResolved} />
954
+ <link rel="describedby" type="text/plain" href={llmsLinkHrefResolved} />
560
955
 
561
956
  {/* Open Graph */}
562
957
  <meta property="og:type" content={ogType} />
@@ -571,13 +966,36 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
571
966
  {ogType === "article" && tagKeywords.map((keyword) => (
572
967
  <meta property="article:tag" content={keyword} />
573
968
  ))}
969
+ {/* Article dates. `og:type="article"` was declared with no times
970
+ at all, which is an incomplete article object — crawlers and
971
+ social cards had no publish date to show even though the page
972
+ renders one visibly.
973
+
974
+ `article:modified_time` falls back to `lastUpdated`, the prop
975
+ the docs chrome already uses for "Last updated", so a docs page
976
+ gets a modified time without the blog-only `updatedDate` being
977
+ set. Only emitted when the value parses as a date: a
978
+ frontmatter `lastUpdated: v2.1` is a version string, and a
979
+ malformed datetime is worse than an absent one. */}
980
+ {ogType === "article" && isoDate(publishedDate) && (
981
+ <meta property="article:published_time" content={isoDate(publishedDate)} />
982
+ )}
983
+ {ogType === "article" && isoDate(updatedDate ?? lastUpdated) && (
984
+ <meta
985
+ property="article:modified_time"
986
+ content={isoDate(updatedDate ?? lastUpdated)}
987
+ />
988
+ )}
574
989
 
575
990
  {/* JSON-LD primary block — Article / HowTo / TechArticle /
576
991
  Course depending on `pageType`. Emits keywords as a
577
992
  Schema.org keywords string; Google reads this for topical
578
993
  categorization in rich results. */}
579
994
  {articleJsonLd && (
580
- <script type="application/ld+json" set:html={JSON.stringify(articleJsonLd)} />
995
+ <script type="application/ld+json" set:html={JSON.stringify(articleJsonLd).replace(/</g, "\\u003c")} />
996
+ )}
997
+ {breadcrumbJsonLd && (
998
+ <script type="application/ld+json" set:html={JSON.stringify(breadcrumbJsonLd).replace(/</g, "\\u003c")} />
581
999
  )}
582
1000
 
583
1001
  {/* Per-page / per-site custom structured data. Layered on
@@ -604,30 +1022,84 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
604
1022
  ></script>
605
1023
  )}
606
1024
 
607
- <script is:inline>
608
- if (localStorage.getItem("theme") === "dark") {
609
- document.documentElement.classList.add("dark");
610
- }
611
- </script>
1025
+ {/*
1026
+ Theme bootstrap. Inline and BLOCKING on purpose — it must run
1027
+ before first paint or the page flashes light before going dark.
1028
+
1029
+ An explicit choice wins in BOTH directions. Someone on a
1030
+ dark-mode OS who deliberately picked light must stay light, so
1031
+ "light" is checked rather than treated as "not dark". Only the
1032
+ absence of a stored value falls through to the OS preference.
1033
+
1034
+ That fallback is the point of this block. Previously the only
1035
+ condition was `=== "dark"`, so a visitor whose OS is in dark mode
1036
+ got a light page until they found the toggle — and nothing else
1037
+ in the CSS consulted prefers-color-scheme either. It also made
1038
+ dark mode untestable by any tool that emulates the media query
1039
+ (DevTools' Rendering panel, Playwright's colorScheme), because
1040
+ the page did not read it.
1041
+
1042
+ localStorage access throws in some privacy modes; a throw here
1043
+ would skip the class entirely, so it is guarded and degrades to
1044
+ the OS preference.
1045
+ */}
1046
+ {/*
1047
+ site.colorMode is the first-visit mode (system: the OS preference). @dogsbay/elements' fixed
1048
+ scripts, one per mode: dogsbay-ssg writes the same bytes, so the CSP hashes are shared.
1049
+ */}
1050
+ <script is:inline set:html={COLOR_MODE_HEAD_SCRIPTS[siteChrome?.colorMode ?? "system"] ?? COLOR_MODE_HEAD_SCRIPTS.system} />
1051
+ {/*
1052
+ A closed announcement bar never shows, not even for a frame: @dogsbay/elements' fixed head
1053
+ script (the same bytes dogsbay-ssg uses) reads the bar's id from the meta before it is drawn.
1054
+ */}
1055
+ {siteChrome?.announcement?.closeable && (
1056
+ <>
1057
+ <meta name="db-announcement" content={siteChrome.announcement.id} />
1058
+ <script is:inline set:html={ANNOUNCEMENT_HEAD_SCRIPT} />
1059
+ <style is:inline set:html={ANNOUNCEMENT_CSS} />
1060
+ </>
1061
+ )}
612
1062
  <slot name="head" />
613
1063
  </head>
614
1064
  <body
615
1065
  class="bg-background text-foreground antialiased"
616
1066
  data-pagefind-ignore={excludeFromSearch ? "" : undefined}
1067
+ data-link-icons={_linkIconTokens || undefined}
1068
+ style={_linkIconStyle || undefined}
617
1069
  >
618
1070
  <SidebarProvider>
1071
+ {/*
1072
+ chrome="blog" drops the sidebar COLUMN only. SidebarProvider and
1073
+ SidebarInset stay, so the content column, header offset and
1074
+ sticky contract are byte-identical to a docs page — which is what
1075
+ makes the blog read as the same site rather than a lookalike.
1076
+ With no <Sidebar> sibling the inset's peer-* selectors simply do
1077
+ not match and it fills the width.
1078
+ */}
1079
+ {chrome === "docs" && (
619
1080
  <Sidebar collapsible="icon">
620
1081
  <SidebarHeader>
621
1082
  <SidebarMenu>
622
1083
  <SidebarMenuItem>
623
- <SidebarMenuButton size="lg" href={siteUrl} isActive={currentPath === siteUrl || currentPath === "/"}>
1084
+ <SidebarMenuButton size="lg" href={basePath || "/"} isActive={currentPath === basePath || currentPath === "/"}>
1085
+ {siteChrome?.logo ? (
1086
+ <>
1087
+ {/* Two images, one hidden by the theme class: no script, no flash */}
1088
+ <img src={siteChrome.logo.light} alt={siteChrome.logo.replacesName ? siteName : ""} class:list={["site-logo h-8 w-auto max-w-[10rem] object-contain object-left", siteChrome.logo.dark && "dark:hidden"]} />
1089
+ {siteChrome.logo.dark && <img src={siteChrome.logo.dark} alt={siteChrome.logo.replacesName ? siteName : ""} class="site-logo hidden h-8 w-auto max-w-[10rem] object-contain object-left dark:block" />}
1090
+ </>
1091
+ ) : (
624
1092
  <div class="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
625
1093
  <Fragment set:html={siteIcon} />
626
1094
  </div>
1095
+ )}
1096
+ {/* A wordmark logo is the name: its alt is the site name, the link's accessible name */}
1097
+ {!siteChrome?.logo?.replacesName && (
627
1098
  <div class="grid flex-1 text-left text-sm leading-tight">
628
1099
  <span class="truncate font-semibold">{siteName}</span>
629
- <span class="truncate text-xs text-sidebar-foreground/70">Documentation</span>
1100
+ <span class="truncate text-xs text-sidebar-foreground/70">{siteTagline || "Documentation"}</span>
630
1101
  </div>
1102
+ )}
631
1103
  </SidebarMenuButton>
632
1104
  </SidebarMenuItem>
633
1105
  </SidebarMenu>
@@ -636,7 +1108,41 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
636
1108
  <SidebarSeparator />
637
1109
 
638
1110
  <SidebarContent>
639
- {navGroups ? (
1111
+ {/* The header's links move here below lg, as Docusaurus moves navbar items into its drawer */}
1112
+ {siteChrome?.header?.links.length ? (
1113
+ <SidebarGroup class="lg:hidden">
1114
+ <SidebarGroupContent>
1115
+ <HeaderLinks links={siteChrome.header.links} layout="list" currentPath={currentPath} />
1116
+ {/* The header's icons too, below md, where the header has no room for them beside the links */}
1117
+ {siteChrome.header.social.length > 0 && (
1118
+ <div class="mt-2 flex flex-wrap items-center gap-1 px-1 md:hidden">
1119
+ <SocialLinks links={siteChrome.header.social} />
1120
+ </div>
1121
+ )}
1122
+ </SidebarGroupContent>
1123
+ </SidebarGroup>
1124
+ ) : null}
1125
+ {navMode === "client" ? (
1126
+ // Client-render mode: emit one DocsNavClient placeholder
1127
+ // inside a single SidebarGroup, regardless of navGroups.
1128
+ // The group-label shape doesn't apply when the tree is
1129
+ // hydrated by JS — multi-group nav is reconstructed
1130
+ // client-side from the same /_dogsbay/nav.json shape.
1131
+ // See plans/client-rendered-nav.md.
1132
+ <SidebarGroup>
1133
+ <SidebarGroupContent>
1134
+ <DocsNavClient
1135
+ currentPath={currentPath}
1136
+ basePath={basePath ?? ""}
1137
+ namespace={multiSource?.namespace}
1138
+ version={navVersion}
1139
+ locale={multiSource?.locale}
1140
+ rootVersion={navRootVersion.rootVersion}
1141
+ versionSegments={navRootVersion.versionSegments}
1142
+ />
1143
+ </SidebarGroupContent>
1144
+ </SidebarGroup>
1145
+ ) : navGroups ? (
640
1146
  navGroups.map(group => (
641
1147
  <SidebarGroup>
642
1148
  <SidebarGroupLabel>{group.label}</SidebarGroupLabel>
@@ -644,8 +1150,10 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
644
1150
  <SidebarNavTree
645
1151
  items={filterNavByAxis(group.items, {
646
1152
  basePath: basePath ?? "/docs",
647
- version: multiSource?.version,
1153
+ namespace: multiSource?.namespace,
1154
+ version: navVersion,
648
1155
  locale: multiSource?.locale,
1156
+ ...navRootVersion,
649
1157
  })}
650
1158
  currentPath={currentPath}
651
1159
  />
@@ -658,8 +1166,10 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
658
1166
  <SidebarNavTree
659
1167
  items={filterNavByAxis(nav, {
660
1168
  basePath: basePath ?? "/docs",
661
- version: multiSource?.version,
1169
+ namespace: multiSource?.namespace,
1170
+ version: navVersion,
662
1171
  locale: multiSource?.locale,
1172
+ ...navRootVersion,
663
1173
  })}
664
1174
  currentPath={currentPath}
665
1175
  />
@@ -670,14 +1180,36 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
670
1180
 
671
1181
  <SidebarRail />
672
1182
  </Sidebar>
1183
+ )}
673
1184
 
674
1185
  <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" />
1186
+ {/*
1187
+ Height comes from `--db-header-height` (declared on :root in
1188
+ <head>) — the CONTRACT any other sticky chrome offsets by, e.g.
1189
+ the release-comparison toolbar. One variable, so a change here
1190
+ can never leave another sticky bar overlapping or floating.
1191
+ */}
1192
+ {siteChrome?.announcement && <AnnouncementBar announcement={siteChrome.announcement} />}
1193
+ <header class="sticky top-0 z-40 flex h-[var(--db-header-height)] shrink-0 items-center gap-2 border-b bg-background/95 px-4 backdrop-blur-sm supports-[backdrop-filter]:bg-background/60">
1194
+ {chrome === "docs" && <SidebarTrigger class="-ml-1" />}
677
1195
  <Separator orientation="vertical" class="mr-2 h-4" />
678
- <span class="text-sm text-muted-foreground" data-page-title>{title}</span>
1196
+ {/* With header links, the page title shows only below lg, where the links are in the sidebar */}
1197
+ <span class:list={["text-sm text-muted-foreground", siteChrome?.header?.links.length && "lg:hidden"]} data-page-title>{title}</span>
1198
+ {siteChrome?.header?.links.length ? <HeaderLinks links={siteChrome.header.links} currentPath={currentPath} /> : null}
679
1199
  <div class="ml-auto flex items-center gap-2">
680
1200
  <slot name="header" />
1201
+ {tocPlacement.popoverToc && (
1202
+ <details class="dba-toc-popover relative" data-toc-popover>
1203
+ <summary class="cursor-pointer list-none rounded-md px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-foreground">
1204
+ On this page
1205
+ </summary>
1206
+ <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">
1207
+ <DocsToc headings={headings} title="" />
1208
+ </div>
1209
+ </details>
1210
+ )}
1211
+ {/* Products before languages and versions, as dogsbay-ssg; also on pages outside every product */}
1212
+ {switcherMap && <ProductSwitcher switcherMap={switcherMap} multiSource={multiSource} />}
681
1213
  {switcherMap && multiSource && (
682
1214
  <LocaleSwitcher
683
1215
  switcherMap={switcherMap}
@@ -704,10 +1236,16 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
704
1236
  {!hideSearch && (
705
1237
  <SearchDialog
706
1238
  pagefindUrl={pagefindUrl}
1239
+ pagefindBaseUrl={pagefindBaseUrl}
1240
+ navUrl={basePath ? `${basePath}/_dogsbay/nav.json` : "/_dogsbay/nav.json"}
707
1241
  taxonomyDisplay={taxonomyDisplay}
1242
+ scopeProduct={multiSource?.namespace}
1243
+ scopeVersion={multiSource?.version}
708
1244
  />
709
1245
  )}
710
- {repoUrl && (
1246
+ {siteChrome?.header ? (
1247
+ <SocialLinks links={siteChrome.header.social} class={siteChrome.header.links.length ? "max-md:hidden" : undefined} />
1248
+ ) : repoUrl && (
711
1249
  <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
1250
  <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
1251
  </a>
@@ -737,9 +1275,30 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
737
1275
  the actual page content. Filter elements live in here
738
1276
  now to stay inside that scope.
739
1277
  */}
740
- {Array.isArray(tags) && tags.map((tag) => (
741
- <div hidden data-pagefind-filter={`tag:${tag}`}></div>
742
- ))}
1278
+ {/*
1279
+ Slash-nested tags whose prefix is declared in
1280
+ `taxonomies.tags.prefixes` emit as per-prefix filter
1281
+ divs so each prefix becomes its own Pagefind facet
1282
+ column (Difficulty, Topic, Persona, …) instead of
1283
+ pooling under a single "Tag" column.
1284
+
1285
+ Plain tags and tags whose prefix isn't declared fall
1286
+ back to the pooled `tag:` filter — backward-compatible
1287
+ for sites that haven't declared prefixes.
1288
+
1289
+ See plans/per-prefix-search-facets.md.
1290
+ */}
1291
+ {Array.isArray(tags) && tags.map((tag) => {
1292
+ const slash = tag.indexOf("/");
1293
+ if (slash > 0) {
1294
+ const prefix = tag.slice(0, slash);
1295
+ const leaf = tag.slice(slash + 1);
1296
+ if (tagPrefixes && tagPrefixes[prefix]) {
1297
+ return <div hidden data-pagefind-filter={`${prefix}:${leaf}`}></div>;
1298
+ }
1299
+ }
1300
+ return <div hidden data-pagefind-filter={`tag:${tag}`}></div>;
1301
+ })}
743
1302
  {Array.isArray(audience) && audience.map((value) => (
744
1303
  <div hidden data-pagefind-filter={`audience:${value}`}></div>
745
1304
  ))}
@@ -748,6 +1307,18 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
748
1307
  ))}
749
1308
  {status && <div hidden data-pagefind-filter={`status:${status}`}></div>}
750
1309
  {pageType && <div hidden data-pagefind-filter={`type:${pageType}`}></div>}
1310
+ {/*
1311
+ Multi-source axis filters — so search on a versioned/multi-
1312
+ product site can be scoped to (or faceted by) the current
1313
+ product and version. `product` = namespace, `version` = the
1314
+ version segment. Only emitted when the axis is active.
1315
+ */}
1316
+ {multiSource?.namespace && (
1317
+ <div hidden data-pagefind-filter={`product:${multiSource.namespace}`}></div>
1318
+ )}
1319
+ {multiSource?.version && (
1320
+ <div hidden data-pagefind-filter={`version:${multiSource.version}`}></div>
1321
+ )}
751
1322
  {/*
752
1323
  Custom-taxonomy filters. Any taxonomy declared in
753
1324
  `dogsbay.config.yml` that isn't one of the five built-ins
@@ -796,17 +1367,72 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
796
1367
  gets context (title, summary) before classification
797
1368
  (chips), then content.
798
1369
  */}
1370
+ {badgeText && (
1371
+ <div class="not-prose mb-3" data-version-badge>
1372
+ <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>
1373
+ </div>
1374
+ )}
799
1375
  {autoH1 && (
800
1376
  <h1 class="text-3xl font-bold tracking-tight mb-2">
801
1377
  {title}
802
1378
  </h1>
803
1379
  )}
1380
+ {/*
1381
+ Byline — blog chrome only, and only when there is
1382
+ something to say. An absent author means NO byline row,
1383
+ never "Unknown": a placeholder byline is worse than none,
1384
+ because it reads as data rather than as a gap.
1385
+
1386
+ Sits between the H1 and the lede so the reader gets
1387
+ attribution before the summary, which is the order a
1388
+ post is scanned in.
1389
+ */}
1390
+ {chrome === "blog" && (author?.length || publishedDate || readingMinutes) && (
1391
+ <div
1392
+ class="not-prose mb-6 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground"
1393
+ data-post-byline
1394
+ data-pagefind-ignore
1395
+ >
1396
+ {author && author.length > 0 && (
1397
+ <span class="font-medium text-foreground">{author.join(", ")}</span>
1398
+ )}
1399
+ {author && author.length > 0 && publishedDate && (
1400
+ <span aria-hidden="true">&middot;</span>
1401
+ )}
1402
+ {publishedDate && (
1403
+ <time datetime={publishedDate}>{_formatPostDate(publishedDate)}</time>
1404
+ )}
1405
+ {publishedDate && readingMinutes && <span aria-hidden="true">&middot;</span>}
1406
+ {readingMinutes && <span>{readingMinutes} min read</span>}
1407
+ {updatedDate && updatedDate !== publishedDate && (
1408
+ <span>
1409
+ &middot; Updated <time datetime={updatedDate}>{_formatPostDate(updatedDate)}</time>
1410
+ </span>
1411
+ )}
1412
+ </div>
1413
+ )}
1414
+
804
1415
  {autoLede && description && (
805
1416
  <p class="text-lg text-muted-foreground mb-6">
806
1417
  {description}
807
1418
  </p>
808
1419
  )}
809
1420
 
1421
+ {/*
1422
+ Hero image. aspect-boxed on purpose — an unsized image
1423
+ above the fold is the classic layout-shift source, and it
1424
+ would shove the prose down after paint.
1425
+ */}
1426
+ {chrome === "blog" && heroImage && (
1427
+ <img
1428
+ src={heroImage}
1429
+ alt=""
1430
+ class="not-prose mb-8 w-full rounded-lg border border-border object-cover aspect-[2/1]"
1431
+ loading="eager"
1432
+ decoding="async"
1433
+ />
1434
+ )}
1435
+
810
1436
  {hasMetaStrip && (
811
1437
  <div
812
1438
  class="not-prose mb-6 flex flex-wrap items-center gap-2"
@@ -830,11 +1456,23 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
830
1456
  indexPath={tagsIndexPath}
831
1457
  prefixes={tagPrefixes}
832
1458
  labels={tagLabels}
1459
+ autoColor={tagAutoColor}
833
1460
  />
834
1461
  )}
835
1462
  </div>
836
1463
  )}
837
1464
 
1465
+ {tocPlacement.topToc && (
1466
+ <details class="dba-toc-top not-prose mb-6 rounded-md border" data-toc-top>
1467
+ <summary class="cursor-pointer list-none px-3 py-2 text-sm font-medium text-muted-foreground">
1468
+ On this page
1469
+ </summary>
1470
+ <div class="border-t px-3 py-2">
1471
+ <DocsToc headings={headings} title="" />
1472
+ </div>
1473
+ </details>
1474
+ )}
1475
+
838
1476
  <slot />
839
1477
 
840
1478
  <DocsFooter
@@ -842,24 +1480,59 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
842
1480
  lastUpdated={lastUpdated}
843
1481
  prev={prev}
844
1482
  next={next}
1483
+ {/*
1484
+ Blog adjacency is chronological, so "Previous/Next"
1485
+ describes the wrong axis. Left is older, right is newer —
1486
+ a timeline runs that way, and so does a series: the
1487
+ right-hand link is the next part.
1488
+ */}
1489
+ prevLabel={chrome === "blog" ? "Older" : undefined}
1490
+ nextLabel={chrome === "blog" ? "Newer" : undefined}
845
1491
  copyright={copyright}
846
1492
  llmsLink={llmFooterLink}
847
1493
  llmsLinkHref={llmsLinkHrefResolved}
1494
+ poweredBy={poweredBy}
1495
+ columns={siteChrome?.footer?.columns}
1496
+ social={siteChrome?.footer?.social}
848
1497
  />
849
1498
  </div>
850
1499
  </main>
851
1500
 
852
- {headings.length > 0 && !wideLayout && (
1501
+ {/* Classic right-hand TOC — only in `toc: rail` mode. */}
1502
+ {tocPlacement.railToc && (
853
1503
  <aside class="sticky top-12 hidden h-[calc(100vh-3rem)] w-56 shrink-0 overflow-y-auto border-l p-4 lg:block">
854
1504
  <DocsToc headings={headings} />
855
1505
  </aside>
856
1506
  )}
1507
+ {/* Right-rail plugin region — host for the `right-rail` named slot
1508
+ (e.g. an Ask AI panel). Rendered in every non-rail mode and not
1509
+ gated on headings, so a plugin can dock on heading-less pages.
1510
+ Hidden when nothing fills it (see the empty-rail style below). */}
1511
+ {tocPlacement.regionRail && (
1512
+ <aside
1513
+ 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"
1514
+ data-right-rail
1515
+ >
1516
+ <slot name="right-rail" />
1517
+ </aside>
1518
+ )}
857
1519
  </div>
858
1520
  </SidebarInset>
859
1521
  </SidebarProvider>
860
1522
  </body>
861
1523
  </html>
862
1524
 
1525
+ <style>
1526
+ /* The right-rail plugin region renders unconditionally in non-rail TOC
1527
+ modes so plugins (e.g. Ask AI) can dock into it. Until something fills
1528
+ the `right-rail` slot it has no element children — hide it so an empty
1529
+ bordered column doesn't show. (:has matches element children only; an
1530
+ unfilled Astro named slot renders none.) */
1531
+ aside[data-right-rail]:not(:has(*)) {
1532
+ display: none;
1533
+ }
1534
+ </style>
1535
+
863
1536
  <script>
864
1537
  import "@dogsbay/ui/sidebar/sidebar.ts";
865
1538