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

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
@@ -531,18 +805,133 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
531
805
  ---
532
806
 
533
807
  <!doctype html>
534
- <html lang="en">
808
+ <html lang="en" class:list={[siteChrome?.colorMode === "dark" && "dark"]}>
535
809
  <head>
810
+ {/* 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
811
  <meta charset="UTF-8" />
537
812
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
538
813
  <title>{title} | {siteName}</title>
539
814
 
815
+ <style is:global>
816
+ /*
817
+ The sticky-chrome contract. This header is exactly this tall, and
818
+ anything else that sticks (the release-comparison toolbar) offsets
819
+ by the same variable — so they cannot drift apart.
820
+ */
821
+ :root {
822
+ --db-header-height: 3rem;
823
+ }
824
+
825
+ /*
826
+ Diagrams drawn by Pele (`content.diagrams: pele`, plans/pele-diagrams.md).
827
+ Pele colours its SVGs from these variables, so a diagram takes the theme
828
+ and .dark switches them. Here rather than in Diagram.astro or global.css:
829
+ those are copied into a site once, this package is re-pinned on every
830
+ build. Borders are thin, so the theme's --border alone is too faint for
831
+ node outlines. The base mapping is the same as dogsbay-ssg's ssg.css.
832
+ */
833
+ .pele {
834
+ --pele-bg: var(--background);
835
+ --pele-fg: var(--foreground);
836
+ --pele-muted: var(--muted-foreground);
837
+ --pele-line: var(--foreground);
838
+ --pele-surface: var(--muted);
839
+ --pele-surface-alt: color-mix(in oklab, var(--muted), var(--foreground) 7%);
840
+ --pele-border: color-mix(in oklab, var(--border), var(--muted-foreground) 45%);
841
+ --pele-accent: var(--primary);
842
+ --pele-font: var(--font-sans);
843
+ --pele-font-mono: var(--font-code, monospace);
844
+ --pele-radius: calc(var(--radius) - 4px);
845
+ /*
846
+ Series colours (pie, xy, git, timeline, treemap, …; gantt's critical
847
+ tasks). Pele writes labels in --pele-bg on these fills, so they are
848
+ darker in light mode and lighter in dark mode. Its own palette is
849
+ fixed, and put white text on yellow (1.6:1). Same hues, in Pele's
850
+ order. dogsbay-ssg's ssg.css does not map these yet.
851
+ */
852
+ --pele-series-1: oklch(0.5 0.13 250);
853
+ --pele-series-2: oklch(0.5 0.15 55);
854
+ --pele-series-3: oklch(0.5 0.13 145);
855
+ --pele-series-4: oklch(0.5 0.16 25);
856
+ --pele-series-5: oklch(0.5 0.09 195);
857
+ --pele-series-6: oklch(0.5 0.12 95);
858
+ --pele-series-7: oklch(0.5 0.12 320);
859
+ --pele-series-8: oklch(0.5 0.06 60);
860
+ --pele-critical: var(--pele-series-4);
861
+ --pele-error: var(--pele-series-4);
862
+ }
863
+ .dark .pele {
864
+ --pele-series-1: oklch(0.78 0.13 250);
865
+ --pele-series-2: oklch(0.78 0.15 55);
866
+ --pele-series-3: oklch(0.78 0.13 145);
867
+ --pele-series-4: oklch(0.78 0.16 25);
868
+ --pele-series-5: oklch(0.78 0.09 195);
869
+ --pele-series-6: oklch(0.78 0.12 95);
870
+ --pele-series-7: oklch(0.78 0.12 320);
871
+ --pele-series-8: oklch(0.78 0.06 60);
872
+ }
873
+ /*
874
+ Diagram.astro inverts diagrams in dark mode, for Mermaid's fixed colours;
875
+ Pele's are already dark. Unlayered, so this wins over the dark:invert and
876
+ dark:hue-rotate utilities.
877
+ */
878
+ .diagram-content:has(> svg.pele),
879
+ .diagram-content > svg.pele {
880
+ filter: none;
881
+ }
882
+
883
+ /*
884
+ Internal/external link icons. Opt-in via `content.linkIcons`,
885
+ which sets `data-link-icons` (which kinds are active) and the
886
+ `--db-link-icon-*` custom props (the glyphs) on <body>. Links are
887
+ classified purely by href shape, so it covers both structured
888
+ links and raw-HTML anchors from imported content. Scoped to
889
+ `.docs-prose` so nav/header/footer links are untouched; buttons
890
+ (`<a data-variant>`, from Button.astro) carry no icon.
891
+ */
892
+ body[data-link-icons~="external"] .docs-prose a[href^="http://" i]:not([data-variant])::after,
893
+ body[data-link-icons~="external"] .docs-prose a[href^="https://" i]:not([data-variant])::after,
894
+ body[data-link-icons~="external"] .docs-prose a[href^="//"]:not([data-variant])::after {
895
+ content: var(--db-link-icon-external, "");
896
+ display: inline-block;
897
+ margin-inline-start: 0.15em;
898
+ font-size: 0.85em;
899
+ line-height: 1;
900
+ vertical-align: baseline;
901
+ opacity: 0.7;
902
+ }
903
+ body[data-link-icons~="internal"]
904
+ .docs-prose
905
+ a[href^="/"]:not([href^="//"]):not([data-variant])::after,
906
+ body[data-link-icons~="internal"] .docs-prose a[href^="./"]:not([data-variant])::after,
907
+ body[data-link-icons~="internal"] .docs-prose a[href^="../"]:not([data-variant])::after {
908
+ content: var(--db-link-icon-internal, "");
909
+ display: inline-block;
910
+ margin-inline-start: 0.15em;
911
+ font-size: 0.85em;
912
+ line-height: 1;
913
+ vertical-align: baseline;
914
+ opacity: 0.7;
915
+ }
916
+ </style>
917
+
540
918
  {metaDescription && <meta name="description" content={metaDescription} />}
541
- {favicon !== false && <link rel="icon" href={favicon} />}
919
+ {favicon && <link rel="icon" href={favicon} />}
542
920
  {themeColor && <meta name="theme-color" content={themeColor} />}
543
921
  {/* External search engine directive — orthogonal to in-site
544
- Pagefind exclusion. */}
545
- {noindex && <meta name="robots" content="noindex, nofollow" />}
922
+ Pagefind exclusion. `noindex` + `nofollow` are independent
923
+ bits per the meta-robots spec; emit only the directives that
924
+ are set. Combining them when both are set keeps the tag
925
+ compact (`<meta name="robots" content="noindex, nofollow">`)
926
+ instead of emitting two tags. */}
927
+ {(noindex || nofollow) && (
928
+ <meta
929
+ name="robots"
930
+ content={[noindex && "noindex", nofollow && "nofollow"]
931
+ .filter(Boolean)
932
+ .join(", ")}
933
+ />
934
+ )}
546
935
 
547
936
  {/* In-site Pagefind exclusion is wired via two coordinated
548
937
  attributes on <body> and <main> below — see the prop docs
@@ -556,7 +945,14 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
556
945
  sidebar / header / TOC text from per-page excerpts. See main. */}
557
946
 
558
947
  {computedCanonical && <link rel="canonical" href={computedCanonical} />}
948
+ {alternates.map((a) => <link rel="alternate" hreflang={a.hreflang} href={a.href} />)}
559
949
  {mdMirrorHref && <link rel="alternate" type="text/markdown" href={mdMirrorHref} />}
950
+ {/* Programmatic llms.txt discovery — agents that follow head
951
+ link rels get the per-mount llms.txt without parsing HTML.
952
+ Mirrors the existing _headers Link rel="describedby" used by
953
+ Cloudflare Pages / Workers. */}
954
+ <link rel="alternate" type="text/plain" title="llms.txt" href={llmsLinkHrefResolved} />
955
+ <link rel="describedby" type="text/plain" href={llmsLinkHrefResolved} />
560
956
 
561
957
  {/* Open Graph */}
562
958
  <meta property="og:type" content={ogType} />
@@ -571,13 +967,36 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
571
967
  {ogType === "article" && tagKeywords.map((keyword) => (
572
968
  <meta property="article:tag" content={keyword} />
573
969
  ))}
970
+ {/* Article dates. `og:type="article"` was declared with no times
971
+ at all, which is an incomplete article object — crawlers and
972
+ social cards had no publish date to show even though the page
973
+ renders one visibly.
974
+
975
+ `article:modified_time` falls back to `lastUpdated`, the prop
976
+ the docs chrome already uses for "Last updated", so a docs page
977
+ gets a modified time without the blog-only `updatedDate` being
978
+ set. Only emitted when the value parses as a date: a
979
+ frontmatter `lastUpdated: v2.1` is a version string, and a
980
+ malformed datetime is worse than an absent one. */}
981
+ {ogType === "article" && isoDate(publishedDate) && (
982
+ <meta property="article:published_time" content={isoDate(publishedDate)} />
983
+ )}
984
+ {ogType === "article" && isoDate(updatedDate ?? lastUpdated) && (
985
+ <meta
986
+ property="article:modified_time"
987
+ content={isoDate(updatedDate ?? lastUpdated)}
988
+ />
989
+ )}
574
990
 
575
991
  {/* JSON-LD primary block — Article / HowTo / TechArticle /
576
992
  Course depending on `pageType`. Emits keywords as a
577
993
  Schema.org keywords string; Google reads this for topical
578
994
  categorization in rich results. */}
579
995
  {articleJsonLd && (
580
- <script type="application/ld+json" set:html={JSON.stringify(articleJsonLd)} />
996
+ <script type="application/ld+json" set:html={JSON.stringify(articleJsonLd).replace(/</g, "\\u003c")} />
997
+ )}
998
+ {breadcrumbJsonLd && (
999
+ <script type="application/ld+json" set:html={JSON.stringify(breadcrumbJsonLd).replace(/</g, "\\u003c")} />
581
1000
  )}
582
1001
 
583
1002
  {/* Per-page / per-site custom structured data. Layered on
@@ -604,30 +1023,84 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
604
1023
  ></script>
605
1024
  )}
606
1025
 
607
- <script is:inline>
608
- if (localStorage.getItem("theme") === "dark") {
609
- document.documentElement.classList.add("dark");
610
- }
611
- </script>
1026
+ {/*
1027
+ Theme bootstrap. Inline and BLOCKING on purpose — it must run
1028
+ before first paint or the page flashes light before going dark.
1029
+
1030
+ An explicit choice wins in BOTH directions. Someone on a
1031
+ dark-mode OS who deliberately picked light must stay light, so
1032
+ "light" is checked rather than treated as "not dark". Only the
1033
+ absence of a stored value falls through to the OS preference.
1034
+
1035
+ That fallback is the point of this block. Previously the only
1036
+ condition was `=== "dark"`, so a visitor whose OS is in dark mode
1037
+ got a light page until they found the toggle — and nothing else
1038
+ in the CSS consulted prefers-color-scheme either. It also made
1039
+ dark mode untestable by any tool that emulates the media query
1040
+ (DevTools' Rendering panel, Playwright's colorScheme), because
1041
+ the page did not read it.
1042
+
1043
+ localStorage access throws in some privacy modes; a throw here
1044
+ would skip the class entirely, so it is guarded and degrades to
1045
+ the OS preference.
1046
+ */}
1047
+ {/*
1048
+ site.colorMode is the first-visit mode (system: the OS preference). @dogsbay/elements' fixed
1049
+ scripts, one per mode: dogsbay-ssg writes the same bytes, so the CSP hashes are shared.
1050
+ */}
1051
+ <script is:inline set:html={COLOR_MODE_HEAD_SCRIPTS[siteChrome?.colorMode ?? "system"] ?? COLOR_MODE_HEAD_SCRIPTS.system} />
1052
+ {/*
1053
+ A closed announcement bar never shows, not even for a frame: @dogsbay/elements' fixed head
1054
+ script (the same bytes dogsbay-ssg uses) reads the bar's id from the meta before it is drawn.
1055
+ */}
1056
+ {siteChrome?.announcement?.closeable && (
1057
+ <>
1058
+ <meta name="db-announcement" content={siteChrome.announcement.key ?? siteChrome.announcement.id} />
1059
+ <script is:inline set:html={ANNOUNCEMENT_HEAD_SCRIPT} />
1060
+ <style is:inline set:html={ANNOUNCEMENT_CSS} />
1061
+ </>
1062
+ )}
612
1063
  <slot name="head" />
613
1064
  </head>
614
1065
  <body
615
1066
  class="bg-background text-foreground antialiased"
616
1067
  data-pagefind-ignore={excludeFromSearch ? "" : undefined}
1068
+ data-link-icons={_linkIconTokens || undefined}
1069
+ style={_linkIconStyle || undefined}
617
1070
  >
618
1071
  <SidebarProvider>
1072
+ {/*
1073
+ chrome="blog" drops the sidebar COLUMN only. SidebarProvider and
1074
+ SidebarInset stay, so the content column, header offset and
1075
+ sticky contract are byte-identical to a docs page — which is what
1076
+ makes the blog read as the same site rather than a lookalike.
1077
+ With no <Sidebar> sibling the inset's peer-* selectors simply do
1078
+ not match and it fills the width.
1079
+ */}
1080
+ {chrome === "docs" && (
619
1081
  <Sidebar collapsible="icon">
620
1082
  <SidebarHeader>
621
1083
  <SidebarMenu>
622
1084
  <SidebarMenuItem>
623
- <SidebarMenuButton size="lg" href={siteUrl} isActive={currentPath === siteUrl || currentPath === "/"}>
1085
+ <SidebarMenuButton size="lg" href={basePath || "/"} isActive={currentPath === basePath || currentPath === "/"}>
1086
+ {siteChrome?.logo ? (
1087
+ <>
1088
+ {/* Two images, one hidden by the theme class: no script, no flash */}
1089
+ <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"]} />
1090
+ {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" />}
1091
+ </>
1092
+ ) : (
624
1093
  <div class="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
625
1094
  <Fragment set:html={siteIcon} />
626
1095
  </div>
1096
+ )}
1097
+ {/* A wordmark logo is the name: its alt is the site name, the link's accessible name */}
1098
+ {!siteChrome?.logo?.replacesName && (
627
1099
  <div class="grid flex-1 text-left text-sm leading-tight">
628
1100
  <span class="truncate font-semibold">{siteName}</span>
629
- <span class="truncate text-xs text-sidebar-foreground/70">Documentation</span>
1101
+ <span class="truncate text-xs text-sidebar-foreground/70">{siteTagline || "Documentation"}</span>
630
1102
  </div>
1103
+ )}
631
1104
  </SidebarMenuButton>
632
1105
  </SidebarMenuItem>
633
1106
  </SidebarMenu>
@@ -636,7 +1109,41 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
636
1109
  <SidebarSeparator />
637
1110
 
638
1111
  <SidebarContent>
639
- {navGroups ? (
1112
+ {/* The header's links move here below lg, as Docusaurus moves navbar items into its drawer */}
1113
+ {siteChrome?.header?.links.length ? (
1114
+ <SidebarGroup class="lg:hidden">
1115
+ <SidebarGroupContent>
1116
+ <HeaderLinks links={siteChrome.header.links} layout="list" currentPath={currentPath} />
1117
+ {/* The header's icons too, below md, where the header has no room for them beside the links */}
1118
+ {siteChrome.header.social.length > 0 && (
1119
+ <div class="mt-2 flex flex-wrap items-center gap-1 px-1 md:hidden">
1120
+ <SocialLinks links={siteChrome.header.social} />
1121
+ </div>
1122
+ )}
1123
+ </SidebarGroupContent>
1124
+ </SidebarGroup>
1125
+ ) : null}
1126
+ {navMode === "client" ? (
1127
+ // Client-render mode: emit one DocsNavClient placeholder
1128
+ // inside a single SidebarGroup, regardless of navGroups.
1129
+ // The group-label shape doesn't apply when the tree is
1130
+ // hydrated by JS — multi-group nav is reconstructed
1131
+ // client-side from the same /_dogsbay/nav.json shape.
1132
+ // See plans/client-rendered-nav.md.
1133
+ <SidebarGroup>
1134
+ <SidebarGroupContent>
1135
+ <DocsNavClient
1136
+ currentPath={currentPath}
1137
+ basePath={basePath ?? ""}
1138
+ namespace={multiSource?.namespace}
1139
+ version={navVersion}
1140
+ locale={multiSource?.locale}
1141
+ rootVersion={navRootVersion.rootVersion}
1142
+ versionSegments={navRootVersion.versionSegments}
1143
+ />
1144
+ </SidebarGroupContent>
1145
+ </SidebarGroup>
1146
+ ) : navGroups ? (
640
1147
  navGroups.map(group => (
641
1148
  <SidebarGroup>
642
1149
  <SidebarGroupLabel>{group.label}</SidebarGroupLabel>
@@ -644,8 +1151,10 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
644
1151
  <SidebarNavTree
645
1152
  items={filterNavByAxis(group.items, {
646
1153
  basePath: basePath ?? "/docs",
647
- version: multiSource?.version,
1154
+ namespace: multiSource?.namespace,
1155
+ version: navVersion,
648
1156
  locale: multiSource?.locale,
1157
+ ...navRootVersion,
649
1158
  })}
650
1159
  currentPath={currentPath}
651
1160
  />
@@ -658,8 +1167,10 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
658
1167
  <SidebarNavTree
659
1168
  items={filterNavByAxis(nav, {
660
1169
  basePath: basePath ?? "/docs",
661
- version: multiSource?.version,
1170
+ namespace: multiSource?.namespace,
1171
+ version: navVersion,
662
1172
  locale: multiSource?.locale,
1173
+ ...navRootVersion,
663
1174
  })}
664
1175
  currentPath={currentPath}
665
1176
  />
@@ -670,14 +1181,39 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
670
1181
 
671
1182
  <SidebarRail />
672
1183
  </Sidebar>
1184
+ )}
673
1185
 
674
1186
  <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" />
1187
+ {/*
1188
+ Height comes from `--db-header-height` (declared on :root in
1189
+ <head>) — the CONTRACT any other sticky chrome offsets by, e.g.
1190
+ the release-comparison toolbar. One variable, so a change here
1191
+ can never leave another sticky bar overlapping or floating.
1192
+ */}
1193
+ {siteChrome?.announcement && <AnnouncementBar announcement={siteChrome.announcement} />}
1194
+ <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" : "h-[var(--db-header-height)]"]}>
1195
+ {chrome === "docs" && <SidebarTrigger class="-ml-1" />}
677
1196
  <Separator orientation="vertical" class="mr-2 h-4" />
678
- <span class="text-sm text-muted-foreground" data-page-title>{title}</span>
1197
+ {/* With header links, the page title shows only below lg, where the links are in the sidebar;
1198
+ a layout with no sidebar keeps the links in the header (wrapping) and no title */}
1199
+ {!(chrome !== "docs" && siteChrome?.header?.links.length) && (
1200
+ <span class:list={["text-sm text-muted-foreground", siteChrome?.header?.links.length && "lg:hidden"]} data-page-title>{title}</span>
1201
+ )}
1202
+ {siteChrome?.header?.links.length ? <HeaderLinks links={siteChrome.header.links} currentPath={currentPath} wrap={chrome !== "docs"} /> : null}
679
1203
  <div class="ml-auto flex items-center gap-2">
680
1204
  <slot name="header" />
1205
+ {tocPlacement.popoverToc && (
1206
+ <details class="dba-toc-popover relative" data-toc-popover>
1207
+ <summary class="cursor-pointer list-none rounded-md px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-foreground">
1208
+ On this page
1209
+ </summary>
1210
+ <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">
1211
+ <DocsToc headings={headings} title="" />
1212
+ </div>
1213
+ </details>
1214
+ )}
1215
+ {/* Products before languages and versions, as dogsbay-ssg; also on pages outside every product */}
1216
+ {switcherMap && <ProductSwitcher switcherMap={switcherMap} multiSource={multiSource} />}
681
1217
  {switcherMap && multiSource && (
682
1218
  <LocaleSwitcher
683
1219
  switcherMap={switcherMap}
@@ -704,10 +1240,16 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
704
1240
  {!hideSearch && (
705
1241
  <SearchDialog
706
1242
  pagefindUrl={pagefindUrl}
1243
+ pagefindBaseUrl={pagefindBaseUrl}
1244
+ navUrl={basePath ? `${basePath}/_dogsbay/nav.json` : "/_dogsbay/nav.json"}
707
1245
  taxonomyDisplay={taxonomyDisplay}
1246
+ scopeProduct={multiSource?.namespace}
1247
+ scopeVersion={multiSource?.version}
708
1248
  />
709
1249
  )}
710
- {repoUrl && (
1250
+ {siteChrome?.header ? (
1251
+ <SocialLinks links={siteChrome.header.social} class={chrome === "docs" && siteChrome.header.links.length ? "max-md:hidden" : undefined} />
1252
+ ) : repoUrl && /^https?:\/\//i.test(repoUrl) && (
711
1253
  <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
1254
  <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
1255
  </a>
@@ -737,9 +1279,30 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
737
1279
  the actual page content. Filter elements live in here
738
1280
  now to stay inside that scope.
739
1281
  */}
740
- {Array.isArray(tags) && tags.map((tag) => (
741
- <div hidden data-pagefind-filter={`tag:${tag}`}></div>
742
- ))}
1282
+ {/*
1283
+ Slash-nested tags whose prefix is declared in
1284
+ `taxonomies.tags.prefixes` emit as per-prefix filter
1285
+ divs so each prefix becomes its own Pagefind facet
1286
+ column (Difficulty, Topic, Persona, …) instead of
1287
+ pooling under a single "Tag" column.
1288
+
1289
+ Plain tags and tags whose prefix isn't declared fall
1290
+ back to the pooled `tag:` filter — backward-compatible
1291
+ for sites that haven't declared prefixes.
1292
+
1293
+ See plans/per-prefix-search-facets.md.
1294
+ */}
1295
+ {Array.isArray(tags) && tags.map((tag) => {
1296
+ const slash = tag.indexOf("/");
1297
+ if (slash > 0) {
1298
+ const prefix = tag.slice(0, slash);
1299
+ const leaf = tag.slice(slash + 1);
1300
+ if (tagPrefixes && tagPrefixes[prefix]) {
1301
+ return <div hidden data-pagefind-filter={`${prefix}:${leaf}`}></div>;
1302
+ }
1303
+ }
1304
+ return <div hidden data-pagefind-filter={`tag:${tag}`}></div>;
1305
+ })}
743
1306
  {Array.isArray(audience) && audience.map((value) => (
744
1307
  <div hidden data-pagefind-filter={`audience:${value}`}></div>
745
1308
  ))}
@@ -748,6 +1311,18 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
748
1311
  ))}
749
1312
  {status && <div hidden data-pagefind-filter={`status:${status}`}></div>}
750
1313
  {pageType && <div hidden data-pagefind-filter={`type:${pageType}`}></div>}
1314
+ {/*
1315
+ Multi-source axis filters — so search on a versioned/multi-
1316
+ product site can be scoped to (or faceted by) the current
1317
+ product and version. `product` = namespace, `version` = the
1318
+ version segment. Only emitted when the axis is active.
1319
+ */}
1320
+ {multiSource?.namespace && (
1321
+ <div hidden data-pagefind-filter={`product:${multiSource.namespace}`}></div>
1322
+ )}
1323
+ {multiSource?.version && (
1324
+ <div hidden data-pagefind-filter={`version:${multiSource.version}`}></div>
1325
+ )}
751
1326
  {/*
752
1327
  Custom-taxonomy filters. Any taxonomy declared in
753
1328
  `dogsbay.config.yml` that isn't one of the five built-ins
@@ -796,17 +1371,72 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
796
1371
  gets context (title, summary) before classification
797
1372
  (chips), then content.
798
1373
  */}
1374
+ {badgeText && (
1375
+ <div class="not-prose mb-3" data-version-badge>
1376
+ <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>
1377
+ </div>
1378
+ )}
799
1379
  {autoH1 && (
800
1380
  <h1 class="text-3xl font-bold tracking-tight mb-2">
801
1381
  {title}
802
1382
  </h1>
803
1383
  )}
1384
+ {/*
1385
+ Byline — blog chrome only, and only when there is
1386
+ something to say. An absent author means NO byline row,
1387
+ never "Unknown": a placeholder byline is worse than none,
1388
+ because it reads as data rather than as a gap.
1389
+
1390
+ Sits between the H1 and the lede so the reader gets
1391
+ attribution before the summary, which is the order a
1392
+ post is scanned in.
1393
+ */}
1394
+ {chrome === "blog" && (author?.length || publishedDate || readingMinutes) && (
1395
+ <div
1396
+ class="not-prose mb-6 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground"
1397
+ data-post-byline
1398
+ data-pagefind-ignore
1399
+ >
1400
+ {author && author.length > 0 && (
1401
+ <span class="font-medium text-foreground">{author.join(", ")}</span>
1402
+ )}
1403
+ {author && author.length > 0 && publishedDate && (
1404
+ <span aria-hidden="true">&middot;</span>
1405
+ )}
1406
+ {publishedDate && (
1407
+ <time datetime={publishedDate}>{_formatPostDate(publishedDate)}</time>
1408
+ )}
1409
+ {publishedDate && readingMinutes && <span aria-hidden="true">&middot;</span>}
1410
+ {readingMinutes && <span>{readingMinutes} min read</span>}
1411
+ {updatedDate && updatedDate !== publishedDate && (
1412
+ <span>
1413
+ &middot; Updated <time datetime={updatedDate}>{_formatPostDate(updatedDate)}</time>
1414
+ </span>
1415
+ )}
1416
+ </div>
1417
+ )}
1418
+
804
1419
  {autoLede && description && (
805
1420
  <p class="text-lg text-muted-foreground mb-6">
806
1421
  {description}
807
1422
  </p>
808
1423
  )}
809
1424
 
1425
+ {/*
1426
+ Hero image. aspect-boxed on purpose — an unsized image
1427
+ above the fold is the classic layout-shift source, and it
1428
+ would shove the prose down after paint.
1429
+ */}
1430
+ {chrome === "blog" && heroImage && (
1431
+ <img
1432
+ src={heroImage}
1433
+ alt=""
1434
+ class="not-prose mb-8 w-full rounded-lg border border-border object-cover aspect-[2/1]"
1435
+ loading="eager"
1436
+ decoding="async"
1437
+ />
1438
+ )}
1439
+
810
1440
  {hasMetaStrip && (
811
1441
  <div
812
1442
  class="not-prose mb-6 flex flex-wrap items-center gap-2"
@@ -830,11 +1460,23 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
830
1460
  indexPath={tagsIndexPath}
831
1461
  prefixes={tagPrefixes}
832
1462
  labels={tagLabels}
1463
+ autoColor={tagAutoColor}
833
1464
  />
834
1465
  )}
835
1466
  </div>
836
1467
  )}
837
1468
 
1469
+ {tocPlacement.topToc && (
1470
+ <details class="dba-toc-top not-prose mb-6 rounded-md border" data-toc-top>
1471
+ <summary class="cursor-pointer list-none px-3 py-2 text-sm font-medium text-muted-foreground">
1472
+ On this page
1473
+ </summary>
1474
+ <div class="border-t px-3 py-2">
1475
+ <DocsToc headings={headings} title="" />
1476
+ </div>
1477
+ </details>
1478
+ )}
1479
+
838
1480
  <slot />
839
1481
 
840
1482
  <DocsFooter
@@ -842,24 +1484,59 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
842
1484
  lastUpdated={lastUpdated}
843
1485
  prev={prev}
844
1486
  next={next}
1487
+ {/*
1488
+ Blog adjacency is chronological, so "Previous/Next"
1489
+ describes the wrong axis. Left is older, right is newer —
1490
+ a timeline runs that way, and so does a series: the
1491
+ right-hand link is the next part.
1492
+ */}
1493
+ prevLabel={chrome === "blog" ? "Older" : undefined}
1494
+ nextLabel={chrome === "blog" ? "Newer" : undefined}
845
1495
  copyright={copyright}
846
1496
  llmsLink={llmFooterLink}
847
1497
  llmsLinkHref={llmsLinkHrefResolved}
1498
+ poweredBy={poweredBy}
1499
+ columns={siteChrome?.footer?.columns}
1500
+ social={siteChrome?.footer?.social}
848
1501
  />
849
1502
  </div>
850
1503
  </main>
851
1504
 
852
- {headings.length > 0 && !wideLayout && (
1505
+ {/* Classic right-hand TOC — only in `toc: rail` mode. */}
1506
+ {tocPlacement.railToc && (
853
1507
  <aside class="sticky top-12 hidden h-[calc(100vh-3rem)] w-56 shrink-0 overflow-y-auto border-l p-4 lg:block">
854
1508
  <DocsToc headings={headings} />
855
1509
  </aside>
856
1510
  )}
1511
+ {/* Right-rail plugin region — host for the `right-rail` named slot
1512
+ (e.g. an Ask AI panel). Rendered in every non-rail mode and not
1513
+ gated on headings, so a plugin can dock on heading-less pages.
1514
+ Hidden when nothing fills it (see the empty-rail style below). */}
1515
+ {tocPlacement.regionRail && (
1516
+ <aside
1517
+ 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"
1518
+ data-right-rail
1519
+ >
1520
+ <slot name="right-rail" />
1521
+ </aside>
1522
+ )}
857
1523
  </div>
858
1524
  </SidebarInset>
859
1525
  </SidebarProvider>
860
1526
  </body>
861
1527
  </html>
862
1528
 
1529
+ <style>
1530
+ /* The right-rail plugin region renders unconditionally in non-rail TOC
1531
+ modes so plugins (e.g. Ask AI) can dock into it. Until something fills
1532
+ the `right-rail` slot it has no element children — hide it so an empty
1533
+ bordered column doesn't show. (:has matches element children only; an
1534
+ unfilled Astro named slot renders none.) */
1535
+ aside[data-right-rail]:not(:has(*)) {
1536
+ display: none;
1537
+ }
1538
+ </style>
1539
+
863
1540
  <script>
864
1541
  import "@dogsbay/ui/sidebar/sidebar.ts";
865
1542