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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dogsbay/docs-layout",
3
- "version": "0.2.0-beta.151",
3
+ "version": "0.2.0-beta.153",
4
4
  "description": "Standard documentation layout components for Dogsbay",
5
5
  "type": "module",
6
6
  "exports": {
@@ -35,10 +35,11 @@
35
35
  "./site-chrome": "./src/site-chrome.ts"
36
36
  },
37
37
  "dependencies": {
38
- "@dogsbay/elements": "0.2.0-beta.151",
39
- "@dogsbay/primitives": "0.2.0-beta.151",
40
- "@dogsbay/site-files": "0.2.0-beta.151",
41
- "@dogsbay/ui": "0.2.0-beta.151"
38
+ "@dogsbay/elements": "0.2.0-beta.153",
39
+ "@dogsbay/search": "0.2.0-beta.153",
40
+ "@dogsbay/primitives": "0.2.0-beta.153",
41
+ "@dogsbay/site-files": "0.2.0-beta.153",
42
+ "@dogsbay/ui": "0.2.0-beta.153"
42
43
  },
43
44
  "devDependencies": {
44
45
  "happy-dom": "^20.10.6",
@@ -48,14 +48,15 @@ import ProductSwitcher from "./ProductSwitcher.astro";
48
48
  import AnnouncementBar from "./AnnouncementBar.astro";
49
49
  import HeaderLinks from "./HeaderLinks.astro";
50
50
  import SocialLinks from "./SocialLinks.astro";
51
- import type { SiteChromeData } from "./site-chrome.js";
51
+ import { headerLinksFrom, type LinksFrom, type SiteChromeData } from "./site-chrome.js";
52
52
  import { COLOR_MODE_HEAD_SCRIPTS } from "@dogsbay/elements/color-mode-head";
53
53
  import { ANNOUNCEMENT_CSS, ANNOUNCEMENT_HEAD_SCRIPT } from "@dogsbay/elements/announcement-head";
54
54
  import LocaleSwitcher from "./LocaleSwitcher.astro";
55
55
  import { filterNavByAxis, rootVersionFilter } from "./nav-filter.js";
56
- import { versionBadge } from "./switcher.js";
56
+ import { versionBadge, versionBanner, type VersionBannerWording } from "./switcher.js";
57
57
  import type { LlmProviderName } from "./llm-actions.js";
58
58
  import { jsonLdTypeFor, normalizeCustomJsonLd, buildArticleJsonLd, buildWebSiteJsonLd } from "./json-ld.js";
59
+ import { pageFacets, type PageFacets } from "@dogsbay/site-files";
59
60
  import { resolveTagKeywords } from "./tag-list-data.js";
60
61
 
61
62
  interface NavItem {
@@ -317,6 +318,16 @@ interface Props {
317
318
  * chip rendering elsewhere). When unset, raw slugs are shown.
318
319
  */
319
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;
320
331
  /**
321
332
  * Map of taxonomy name → index path for declared taxonomies.
322
333
  * Used to wire links from built-in field badges (TypeBadge,
@@ -352,6 +363,11 @@ interface Props {
352
363
  * dogsbay-ssg's English `versionBadge` string.
353
364
  */
354
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>;
355
371
  /**
356
372
  * When `true`, render `<p>{description}</p>` below the auto H1
357
373
  * (or above the meta strip when there's no H1) — used when the
@@ -560,10 +576,12 @@ const {
560
576
  audience,
561
577
  category,
562
578
  taxonomies,
579
+ facets,
563
580
  taxonomyIndexPaths,
564
581
  taxonomyDisplay,
565
582
  autoH1,
566
583
  versionBadgeWording,
584
+ versionBannerWording,
567
585
  autoLede,
568
586
  llmActions,
569
587
  customJsonLd,
@@ -582,6 +600,15 @@ const {
582
600
  class: className,
583
601
  } = Astro.props;
584
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
+
585
612
  // The version served at the site root (`path: ""`), if any: the sidebar
586
613
  // keeps its pages by leaving out the other versions' folders.
587
614
  // With a products: block the page carries its version's URL segment, which may
@@ -594,6 +621,8 @@ const navRootVersion = multiSource?.versionPath !== undefined
594
621
  : rootVersionFilter(switcherMap?.versions);
595
622
  // "Version: 3.33" above the title, on a version with `badge: true` (Docusaurus's version badge)
596
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);
597
626
  const navVersion = multiSource?.versionPath ? multiSource.versionPath : multiSource?.version;
598
627
 
599
628
  // Link icons — classified in CSS by href shape. `data-link-icons`
@@ -619,6 +648,14 @@ const showLlmActionsInline =
619
648
  llmActionsEnabled
620
649
  && (llmActionsPlacement === "inline" || llmActionsPlacement === "both");
621
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: "" };
622
659
  // Per-mount llms.txt URL — Dogsbay emits `<basePath>/llms.txt`
623
660
  // (sitemap-index pattern), so the footer link must be basePath-
624
661
  // prefixed too. Falls back to `/llms.txt` when basePath is empty
@@ -805,7 +842,7 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
805
842
  ---
806
843
 
807
844
  <!doctype html>
808
- <html lang="en" class:list={[siteChrome?.colorMode === "dark" && "dark"]}>
845
+ <html lang="en" class:list={[siteChrome?.colorMode === "dark" && "dark"]} data-header={headerCrowded ? "crowded" : undefined}>
809
846
  <head>
810
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" */}
811
848
  <meta charset="UTF-8" />
@@ -821,6 +858,19 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
821
858
  :root {
822
859
  --db-header-height: 3rem;
823
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
+ }
824
874
 
825
875
  /*
826
876
  Diagrams drawn by Pele (`content.diagrams: pele`, plans/pele-diagrams.md).
@@ -887,11 +937,11 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
887
937
  classified purely by href shape, so it covers both structured
888
938
  links and raw-HTML anchors from imported content. Scoped to
889
939
  `.docs-prose` so nav/header/footer links are untouched; buttons
890
- (`<a data-variant>`, from Button.astro) carry no icon.
940
+ (`<a data-variant>`, from Button.astro) and anything inside `.not-prose` carry no icon.
891
941
  */
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 {
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 {
895
945
  content: var(--db-link-icon-external, "");
896
946
  display: inline-block;
897
947
  margin-inline-start: 0.15em;
@@ -902,9 +952,9 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
902
952
  }
903
953
  body[data-link-icons~="internal"]
904
954
  .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 {
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 {
908
958
  content: var(--db-link-icon-internal, "");
909
959
  display: inline-block;
910
960
  margin-inline-start: 0.15em;
@@ -1078,7 +1128,7 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
1078
1128
  not match and it fills the width.
1079
1129
  */}
1080
1130
  {chrome === "docs" && (
1081
- <Sidebar collapsible="icon">
1131
+ <Sidebar collapsible="icon" label="Docs">
1082
1132
  <SidebarHeader>
1083
1133
  <SidebarMenu>
1084
1134
  <SidebarMenuItem>
@@ -1111,7 +1161,7 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
1111
1161
  <SidebarContent>
1112
1162
  {/* The header's links move here below lg, as Docusaurus moves navbar items into its drawer */}
1113
1163
  {siteChrome?.header?.links.length ? (
1114
- <SidebarGroup class="lg:hidden">
1164
+ <SidebarGroup class={LINKS_LIST_HIDDEN[linksFrom] || undefined}>
1115
1165
  <SidebarGroupContent>
1116
1166
  <HeaderLinks links={siteChrome.header.links} layout="list" currentPath={currentPath} />
1117
1167
  {/* The header's icons too, below md, where the header has no room for them beside the links */}
@@ -1191,16 +1241,16 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
1191
1241
  can never leave another sticky bar overlapping or floating.
1192
1242
  */}
1193
1243
  {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)]"]}>
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)]"]}>
1195
1245
  {chrome === "docs" && <SidebarTrigger class="-ml-1" />}
1196
1246
  <Separator orientation="vertical" class="mr-2 h-4" />
1197
1247
  {/* With header links, the page title shows only below lg, where the links are in the sidebar;
1198
1248
  a layout with no sidebar keeps the links in the header (wrapping) and no title */}
1199
1249
  {!(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>
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>
1201
1251
  )}
1202
- {siteChrome?.header?.links.length ? <HeaderLinks links={siteChrome.header.links} currentPath={currentPath} wrap={chrome !== "docs"} /> : null}
1203
- <div class="ml-auto flex items-center gap-2">
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"]}>
1204
1254
  <slot name="header" />
1205
1255
  {tocPlacement.popoverToc && (
1206
1256
  <details class="dba-toc-popover relative" data-toc-popover>
@@ -1235,6 +1285,7 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
1235
1285
  providers={llmActions!.providers}
1236
1286
  copyButton={llmActions!.copyButton}
1237
1287
  promptTemplate={llmActions!.promptTemplate}
1288
+ compact={headerCrowded}
1238
1289
  />
1239
1290
  )}
1240
1291
  {!hideSearch && (
@@ -1245,6 +1296,7 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
1245
1296
  taxonomyDisplay={taxonomyDisplay}
1246
1297
  scopeProduct={multiSource?.namespace}
1247
1298
  scopeVersion={multiSource?.version}
1299
+ compact={headerCrowded}
1248
1300
  />
1249
1301
  )}
1250
1302
  {siteChrome?.header ? (
@@ -1280,62 +1332,17 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
1280
1332
  now to stay inside that scope.
1281
1333
  */}
1282
1334
  {/*
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
- })}
1306
- {Array.isArray(audience) && audience.map((value) => (
1307
- <div hidden data-pagefind-filter={`audience:${value}`}></div>
1308
- ))}
1309
- {Array.isArray(category) && category.map((value) => (
1310
- <div hidden data-pagefind-filter={`category:${value}`}></div>
1311
- ))}
1312
- {status && <div hidden data-pagefind-filter={`status:${status}`}></div>}
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
- )}
1326
- {/*
1327
- Custom-taxonomy filters. Any taxonomy declared in
1328
- `dogsbay.config.yml` that isn't one of the five built-ins
1329
- flows through here, so `difficulty: intermediate` (etc.)
1330
- becomes a real Pagefind facet checkbox automatically.
1331
- 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.
1332
1343
  */}
1333
- {taxonomies && Object.entries(taxonomies).flatMap(([name, values]) =>
1334
- Array.isArray(values)
1335
- ? values.map((value) => (
1336
- <div hidden data-pagefind-filter={`${name}:${value}`}></div>
1337
- ))
1338
- : []
1344
+ {Object.entries(pageFacetValues).flatMap(([name, values]) =>
1345
+ values.map((value) => <div hidden data-pagefind-filter={`${name}:${value}`}></div>)
1339
1346
  )}
1340
1347
 
1341
1348
  <div class:list={["mx-auto", wideLayout ? "max-w-7xl" : "max-w-3xl"]}>
@@ -1371,6 +1378,13 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
1371
1378
  gets context (title, summary) before classification
1372
1379
  (chips), then content.
1373
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
+ )}
1374
1388
  {badgeText && (
1375
1389
  <div class="not-prose mb-3" data-version-badge>
1376
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>
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * The header's links (`header.links`): links, and one-level dropdowns as `<details>` lists like
4
4
  * the version and product menus, so every link is in the HTML (crawlers, readers without
5
- * JavaScript). `layout="bar"` for the header (from `lg`), `layout="list"` for the sidebar below it.
5
+ * JavaScript). `layout="bar"` for the header (from `lg`, or `xl`), `layout="list"` for the sidebar below it.
6
6
  */
7
- import { isExternal, isMenu, type SiteChromeLink, type SiteChromeMenu } from "./site-chrome.js";
7
+ import { isExternal, isMenu, type LinksFrom, type SiteChromeLink, type SiteChromeMenu } from "./site-chrome.js";
8
8
 
9
9
  interface Props {
10
10
  links: Array<SiteChromeLink | SiteChromeMenu>;
@@ -12,8 +12,10 @@ interface Props {
12
12
  currentPath?: string;
13
13
  /** A layout with no sidebar to move them into: shown at every width, wrapping. */
14
14
  wrap?: boolean;
15
+ /** The width the bar shows from (the sidebar's list below it); `never`: the sidebar's list only. */
16
+ from?: LinksFrom;
15
17
  }
16
- const { links, layout = "bar", currentPath, wrap = false } = Astro.props;
18
+ const { links, layout = "bar", currentPath, wrap = false, from = "lg" } = Astro.props;
17
19
  // The page, or a page under the link's section; a link to the site's root only on the root itself
18
20
  const current = (href: string) => {
19
21
  if (!currentPath || isExternal(href)) return undefined;
@@ -25,11 +27,11 @@ const current = (href: string) => {
25
27
  ---
26
28
 
27
29
  {layout === "bar" ? (
28
- <nav aria-label="Site" class:list={["site-header-links items-center gap-1", wrap ? "flex min-w-0 flex-wrap" : "hidden lg:flex"]}>
30
+ <nav aria-label="Site" class:list={["site-header-links items-center gap-1", wrap ? "flex min-w-0 flex-wrap" : { lg: "hidden lg:flex", xl: "hidden xl:flex", "2xl": "hidden 2xl:flex", never: "hidden" }[from]]}>
29
31
  {links.map((l) =>
30
32
  isMenu(l) ? (
31
33
  <details class="site-header-menu relative">
32
- <summary class="flex cursor-pointer items-center gap-1 rounded-md px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-foreground">
34
+ <summary class="flex cursor-pointer items-center gap-1 whitespace-nowrap rounded-md px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-foreground">
33
35
  {l.label}
34
36
  <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>
35
37
  </summary>
@@ -40,7 +42,7 @@ const current = (href: string) => {
40
42
  </ul>
41
43
  </details>
42
44
  ) : (
43
- <a href={l.href} aria-current={current(l.href)} class="rounded-md px-2 py-1.5 text-sm text-muted-foreground no-underline hover:bg-accent hover:text-foreground aria-[current=page]:text-foreground">{l.label}</a>
45
+ <a href={l.href} aria-current={current(l.href)} class="whitespace-nowrap rounded-md px-2 py-1.5 text-sm text-muted-foreground no-underline hover:bg-accent hover:text-foreground aria-[current=page]:text-foreground">{l.label}</a>
44
46
  ),
45
47
  )}
46
48
  </nav>
@@ -35,11 +35,11 @@ const currentLabel = currentRow?.entry.label ?? currentRow?.entry.id ?? "Locale"
35
35
  {visible && (
36
36
  <details class="locale-switcher relative">
37
37
  <summary
38
- class="flex cursor-pointer items-center gap-1 rounded-md border border-border px-3 py-1.5 text-sm hover:bg-accent"
38
+ class="flex cursor-pointer items-center gap-1 whitespace-nowrap rounded-md border border-border px-3 py-1.5 text-sm hover:bg-accent max-md:px-2"
39
39
  aria-label="Switch language"
40
40
  >
41
41
  <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>
42
- <span class="font-medium">{currentLabel}</span>
42
+ <span class="max-w-[10rem] truncate font-medium max-md:max-w-[6rem]">{currentLabel}</span>
43
43
  <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="ml-1 transition-transform"><polyline points="6 9 12 15 18 9"/></svg>
44
44
  </summary>
45
45
  <ul class="absolute right-0 z-50 mt-1 min-w-[10rem] rounded-md border border-border bg-popover p-1 text-sm shadow-md">
@@ -68,6 +68,8 @@ interface Props {
68
68
  promptTemplate?: string;
69
69
  /** Optional class for layout-side styling. */
70
70
  class?: string;
71
+ /** A crowded header: below 2xl the button is an icon (its aria-label names it). */
72
+ compact?: boolean;
71
73
  }
72
74
 
73
75
  const {
@@ -77,6 +79,7 @@ const {
77
79
  copyButton = true,
78
80
  promptTemplate = DEFAULT_PROMPT_TEMPLATE,
79
81
  class: className,
82
+ compact = false,
80
83
  } = Astro.props;
81
84
 
82
85
  const resolvedProviders = resolveProviders(providers);
@@ -101,10 +104,13 @@ const itemClass =
101
104
  >
102
105
  <DropdownMenu>
103
106
  <DropdownMenuTrigger
104
- class="inline-flex h-8 items-center gap-1 rounded-md border border-border bg-background px-3 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
107
+ class={["inline-flex h-8 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border border-border bg-background text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", compact ? "px-3 max-2xl:px-2" : "px-3"].join(" ")}
105
108
  aria-label="Copy or open page actions"
106
109
  >
107
- <span>Copy or open</span>
110
+ {compact && (
111
+ <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="2xl:hidden"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>
112
+ )}
113
+ <span class:list={[compact && "max-2xl:hidden"]}>Copy or open</span>
108
114
  <svg
109
115
  xmlns="http://www.w3.org/2000/svg"
110
116
  width="14"
@@ -23,9 +23,9 @@ const menu = productMenu(switcherMap, multiSource);
23
23
 
24
24
  {menu && (
25
25
  <details class="product-switcher relative" data-product-switcher>
26
- <summary class="flex cursor-pointer items-center gap-1 rounded-md border border-border px-3 py-1.5 text-sm hover:bg-accent">
26
+ <summary class="flex cursor-pointer items-center gap-1 whitespace-nowrap rounded-md border border-border px-3 py-1.5 text-sm hover:bg-accent max-md:px-2">
27
27
  {menu.current && <span class="sr-only">{placeholder}: </span>}
28
- <span class:list={["font-medium", !menu.current && "text-muted-foreground"]}>{menu.current?.label ?? placeholder}</span>
28
+ <span class:list={["max-w-[12rem] truncate font-medium max-md:max-w-[7rem]", !menu.current && "text-muted-foreground"]}>{menu.current?.label ?? placeholder}</span>
29
29
  <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="ml-1 transition-transform" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>
30
30
  </summary>
31
31
  <ul class="absolute right-0 z-50 mt-1 min-w-[10rem] rounded-md border border-border bg-popover p-1 text-sm shadow-md">
@@ -74,6 +74,8 @@ interface Props {
74
74
  */
75
75
  scopeProduct?: string;
76
76
  scopeVersion?: string;
77
+ /** A crowded header: the button's "Search ⌘K" text only from 1536 px, an icon below. */
78
+ compact?: boolean;
77
79
  }
78
80
 
79
81
  const {
@@ -84,6 +86,7 @@ const {
84
86
  taxonomyDisplay,
85
87
  scopeProduct,
86
88
  scopeVersion,
89
+ compact = false,
87
90
  } = Astro.props;
88
91
  ---
89
92
 
@@ -162,7 +165,7 @@ const {
162
165
  <button
163
166
  type="button"
164
167
  data-search-trigger
165
- class="inline-flex h-9 items-center gap-2 rounded-md border border-border bg-background px-3 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
168
+ class="inline-flex h-9 shrink-0 items-center gap-2 whitespace-nowrap rounded-md border border-border bg-background px-3 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
166
169
  aria-label="Open search"
167
170
  >
168
171
  <svg
@@ -180,8 +183,8 @@ const {
180
183
  <circle cx="11" cy="11" r="8" />
181
184
  <path d="m21 21-4.3-4.3" />
182
185
  </svg>
183
- <span class="hidden sm:inline">Search</span>
184
- <kbd class="hidden rounded border border-border px-1.5 py-0.5 font-mono text-[10px] sm:inline">
186
+ <span class:list={["hidden", compact ? "2xl:inline" : "sm:inline"]}>Search</span>
187
+ <kbd class:list={["hidden rounded border border-border px-1.5 py-0.5 font-mono text-[10px]", compact ? "2xl:inline" : "sm:inline"]}>
185
188
  ⌘K
186
189
  </kbd>
187
190
  </button>
@@ -38,8 +38,8 @@ const currentLabel = currentRow?.entry.label ?? currentRow?.entry.id ?? "Version
38
38
 
39
39
  {visible && (
40
40
  <details class="version-switcher relative">
41
- <summary class="flex cursor-pointer items-center gap-1 rounded-md border border-border px-3 py-1.5 text-sm hover:bg-accent">
42
- <span class="font-medium">{currentLabel}</span>
41
+ <summary class="flex cursor-pointer items-center gap-1 whitespace-nowrap rounded-md border border-border px-3 py-1.5 text-sm hover:bg-accent max-md:px-2">
42
+ <span class="max-w-[10rem] truncate font-medium max-md:max-w-[6rem]">{currentLabel}</span>
43
43
  {currentRow?.entry.eol && (
44
44
  <span class="ml-1 rounded bg-muted px-1 text-[10px] uppercase text-muted-foreground">EOL</span>
45
45
  )}