@dogsbay/docs-layout 0.2.0-beta.16 → 0.2.0-beta.160

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