@sarimarcus/content-sites-ui 0.60.5 → 0.61.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  All packages in the platform release in lockstep; entries are per release version.
4
4
 
5
+ ## 0.61.0 (2026-11-08)
6
+
7
+ Topic hub blocks (SLA-3969, SLA-3975, epic SLA-3968). Additive: no prop is removed or retyped. One markup change on every article page: FAQ items carry stable ids (below); everything else renders only where a site opts in.
8
+
9
+ - New `HubNumbers`, `HubSources`, `HubBridge` (editorial): a topic hub's key figures, primary sources and related hubs, promoted from curiosity-engineering-it. Each root carries `data-hub-block`; headings default to en/it labels and take props. `HubBridge` uses `ArrowLabel`.
10
+ - New `HubQuestions` (editorial): FAQ questions from a hub's articles as chips linking to their answers; links only, no FAQPage. Pick them with `hubQuestions()` (one per article, at most two per opening word, questions over 80 characters skipped for the chip cap).
11
+ - New helpers (editorial): `statFacts` (with `exclude`), `hubBridge` (shared tags), `hubLinkBridge` (cross-category `relatedContent` links), `sourceAuthorities` (citation count, or hub specificity with `siteArticles`: an authority every hub cites only fills leftover places), `resolveArticleLinks`.
12
+ - `ArticlePage`: each FAQ `<details>` gets an id from `faqAnchorIds()` (`faq-<question slug>`, exported from composed and editorial) plus the page's section scroll margin, and the page opens the item a `#faq-…` link targets. `FAQ` (composed): new optional `itemIds` and `itemScrollMarginClass`; without `itemIds` it renders as in 0.60.6 (`tests/fixtures/render-diff/sla-3975-faq-no-ids.json`).
13
+
14
+ ## 0.60.6 (2026-11-07)
15
+
16
+ Hub pages can drop the category row, and the Sotto Scocca audit's package fixes land (SLA-3942). Default markup is unchanged for the hub prop (`render-diff` against 0.60.5 is identical for the topic hub, the paged topic page and the tag page: `tests/fixtures/render-diff/hub-category-nav-default.json`, `article-nav-routes-default.json`); the markup changes below are intended.
17
+
18
+ - `ArticleTopicPage`, `ArticleTagPage`: new optional `showCategoryNav` (default `true`); `false` omits the category nav row, for a site whose header already lists the categories. `ArticleCategoryNav`: new optional `hidden`, which renders nothing.
19
+ - `BreadcrumbBand`, `AuthorPage`, `AuthorsIndexPage`, `StaticProsePage`: the header offset is `pt-[var(--site-header-offset,4rem)]` instead of `pt-16`; `TableOfContents` (fixed bar), `EraTimelineNav` and the `SiteHeader` mobile panel use `top-[var(--site-header-offset,4rem)]` instead of `top-16`. `SiteHeader` sets `--site-header-offset` to the nav plus the trending bar (`4rem + 2.75rem + 1px`) from md when `trendingTags` is set, so nothing under the header slides beneath the bar (SLA-3942 d). The classes live in `layout/headerOffset.ts`.
20
+ - `ArticlePage`: `<main>` is the outer element and `<article data-pagefind-body>` sits inside it; the breadcrumb band stays above `<main>` (e).
21
+ - `RelatedCard`: the title is an `h3` by default, new optional `headingLevel` (`3 | 4`) for the old `h4` (f).
22
+ - `MobileNavLink` rows are at least 44px (`min-h-11`); the trending bar is 44px tall (was 36px) and its links fill it (g).
23
+ - `SiteHeader` stamps `data-desktop-breakpoint`; the mobile-menu cleanup in `navigation.ts` follows each header's `desktopBreakpoint` (`lg` 64rem, `xl` 80rem) instead of always 64rem. `DocumentShell`: `#main-content` gets `tabindex="-1"`, so the skip link moves focus in every browser (h).
24
+
5
25
  ## 0.60.5 (2026-11-06)
6
26
 
7
27
  Markup change only where `SiteHeader` gets `trendingTags`: the 0.60.3 centring did not work, because the bar sat in a `max-w-content` Container that overflowed, which collapsed the auto margins.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarimarcus/content-sites-ui",
3
- "version": "0.60.5",
3
+ "version": "0.61.0",
4
4
  "description": "Universal Astro UI components, layout shell and design tokens shared by the content sites.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -51,6 +51,6 @@
51
51
  "@lucide/astro": "^1.23.0",
52
52
  "astro": "^7.0.6",
53
53
  "tailwindcss": "^4.1.18",
54
- "@sarimarcus/content-sites-core": "0.60.5"
54
+ "@sarimarcus/content-sites-core": "0.61.0"
55
55
  }
56
56
  }
@@ -23,6 +23,10 @@ interface Props {
23
23
  /** Replaces the title's classes. */
24
24
  headingClass?: string;
25
25
  id?: string;
26
+ /** One id per item, in order. The page opens the item a `#<id>` link targets (openFaqTarget from faq-target.ts). */
27
+ itemIds?: readonly string[];
28
+ /** Scroll offset under the sticky header for an item with an id (default: scroll-mt-28, ArticlePage's). */
29
+ itemScrollMarginClass?: string;
26
30
  locale?: string;
27
31
  class?: string;
28
32
  }
@@ -33,6 +37,8 @@ const {
33
37
  icon = true,
34
38
  headingClass = 'text-2xl sm:text-3xl font-normal mb-6 flex items-center gap-3 font-display',
35
39
  id,
40
+ itemIds,
41
+ itemScrollMarginClass = 'scroll-mt-28',
36
42
  class: className = '',
37
43
  } = Astro.props;
38
44
  ---
@@ -46,8 +52,12 @@ const {
46
52
  </h2>
47
53
  )}
48
54
  <div class="space-y-4">
49
- {items.map((item) => (
50
- <details class="group p-6 bg-card rounded-xl border border-border hover:border-primary/50 open:border-primary/50 transition-colors" data-faq-track>
55
+ {items.map((item, i) => (
56
+ <details
57
+ id={itemIds?.[i]}
58
+ class:list={['group p-6 bg-card rounded-xl border border-border hover:border-primary/50 open:border-primary/50 transition-colors', itemIds?.[i] && itemScrollMarginClass]}
59
+ data-faq-track
60
+ >
51
61
  <summary class="flex items-center justify-between cursor-pointer list-none">
52
62
  <h3 class="text-base font-medium group-hover:text-primary transition-colors pr-4" set:html={item.questionHtml} />
53
63
  <svg
@@ -7,6 +7,7 @@
7
7
  // empty heading on every caller that omits one (SLA-2340); `mb-2` sits behind `title` so an eyebrow-only header does
8
8
  // not double the gap.
9
9
  import Chip from '../primitives/Chip.astro';
10
+ import { HEADER_OFFSET_TOP } from '../layout/headerOffset.ts';
10
11
  import { getLabels } from '../internal/labels';
11
12
  import type { TableOfContentsItem } from './tocItem.ts';
12
13
 
@@ -78,7 +79,7 @@ const showMini = variant === 'card';
78
79
  data-toc-mini
79
80
  data-toc
80
81
  data-toc-section-selector={sectionSelector}
81
- class="invisible fixed top-16 left-0 right-0 z-40 translate-y-[-100%] opacity-0 pointer-events-none transition-[transform,opacity,visibility] duration-300 ease-out bg-background/95 backdrop-blur-sm border-b border-border shadow-sm"
82
+ class:list={['invisible fixed left-0 right-0 z-40 translate-y-[-100%] opacity-0 pointer-events-none transition-[transform,opacity,visibility] duration-300 ease-out bg-background/95 backdrop-blur-sm border-b border-border shadow-sm', HEADER_OFFSET_TOP]}
82
83
  aria-hidden="true"
83
84
  inert
84
85
  >
@@ -0,0 +1,16 @@
1
+ import { slugify, stripMarkdown } from '@sarimarcus/content-sites-core/text';
2
+
3
+ /**
4
+ * Stable ids for an article's FAQ items, in order: `faq-<question slug>`, a `-2`, `-3` suffix on a repeat. The article
5
+ * page and the topic hub both call this on the same list, so a hub link always lands on its question.
6
+ */
7
+ export function faqAnchorIds(questions: readonly string[]): string[] {
8
+ const issued = new Set<string>();
9
+ return questions.map((q, i) => {
10
+ const base = `faq-${slugify(stripMarkdown(q)).slice(0, 60).replace(/-+$/, '') || i + 1}`;
11
+ let id = base;
12
+ for (let n = 2; issued.has(id); n++) id = `${base}-${n}`;
13
+ issued.add(id);
14
+ return id;
15
+ });
16
+ }
@@ -0,0 +1,15 @@
1
+ /** Opens the FAQ `<details>` the URL hash names, so a hub link lands on an expanded answer. */
2
+ export function openFaqTarget(): void {
3
+ let id: string;
4
+ try {
5
+ id = decodeURIComponent(location.hash.slice(1));
6
+ } catch {
7
+ return;
8
+ }
9
+ if (!id) return;
10
+ const el = document.getElementById(id);
11
+ if (el instanceof HTMLDetailsElement && !el.open) {
12
+ el.open = true;
13
+ el.scrollIntoView({ block: 'start' });
14
+ }
15
+ }
@@ -4,6 +4,7 @@ export type { TableOfContentsItem } from './tocItem.ts';
4
4
  export { default as CardCarousel } from './CardCarousel.astro';
5
5
  export { default as QuickFacts } from './QuickFacts.astro';
6
6
  export { default as FAQ } from './FAQ.astro';
7
+ export { faqAnchorIds } from './faq-anchors';
7
8
  export { default as InlineImage } from './InlineImage.astro';
8
9
  export { default as Pagination } from './Pagination.astro';
9
10
  export { default as EntityCard } from './EntityCard.astro';
@@ -19,6 +19,8 @@ interface Props {
19
19
  routes?: SiteRoutes;
20
20
  locale?: string;
21
21
  class?: string;
22
+ /** Renders nothing, for a page whose site header already lists the categories. */
23
+ hidden?: boolean;
22
24
  }
23
25
 
24
26
  const defaultLabels = getLabels(Astro.props.locale ?? Astro.currentLocale).articleCategoryNav;
@@ -31,6 +33,7 @@ const {
31
33
  allLabel = defaultLabels.allLabel,
32
34
  routes,
33
35
  class: className,
36
+ hidden = false,
34
37
  } = Astro.props;
35
38
 
36
39
  const counts = new Map<string, number>();
@@ -50,7 +53,7 @@ const all = { href: url(routePath('articles', undefined, routes)), label: allLab
50
53
  const countClass = (active: boolean) => (active ? 'bg-overlay-foreground/20' : 'bg-muted');
51
54
  ---
52
55
 
53
- {categories.length > 0 && (
56
+ {!hidden && categories.length > 0 && (
54
57
  <nav aria-label={ariaLabel} class={className}>
55
58
  <div class="flex gap-2.5 overflow-x-auto flex-nowrap pb-2 scrollbar-hide md:flex-wrap md:overflow-visible md:pb-0">
56
59
  <Chip
@@ -19,6 +19,7 @@ import AuthoritativeSources from '../seo/AuthoritativeSources.astro';
19
19
  import type { ArticleAuthor, BreadcrumbItem, DomainClassifier, SourceInput } from '../seo/types';
20
20
  import TableOfContents from '../composed/TableOfContents.astro';
21
21
  import FAQ from '../composed/FAQ.astro';
22
+ import { faqAnchorIds } from '../composed/faq-anchors';
22
23
  import InlineImage from '../composed/InlineImage.astro';
23
24
  import RelatedContent from '../composed/RelatedContent.astro';
24
25
  import type { RelatedItem } from '../composed/related';
@@ -248,6 +249,7 @@ const faqItems = (article.faqs ?? []).map((f) => ({
248
249
  questionHtml: trustedHtml(parseMarkdownInline(f.question, basePath)),
249
250
  answerHtml: trustedHtml(parseMarkdownInline(f.answer, basePath, sourcesLen)),
250
251
  }));
252
+ const faqIds = faqAnchorIds((article.faqs ?? []).map((f) => f.question));
251
253
 
252
254
  type BodyBlock =
253
255
  | { kind: 'paragraph'; html: string }
@@ -330,11 +332,6 @@ const resolvedRelatedTitle = relatedProps.title ?? l.relatedTitle;
330
332
 
331
333
  <slot name="head" />
332
334
 
333
- <article data-pagefind-body data-pagefind-meta="type:article">
334
- {emitAudienceFacets && article.audiences?.map((a) => (
335
- <span class="sr-only" data-pagefind-filter={`audience:${a}`}>{a}</span>
336
- ))}
337
-
338
335
  {editorial && backLink ? (
339
336
  <BreadcrumbBand class={breadcrumbBandClass}>
340
337
  <a href={backLink.href} data-article-back class="inline-flex items-center gap-2 py-1 text-sm font-medium text-muted-foreground hover:text-primary sm:hidden">
@@ -349,6 +346,12 @@ const resolvedRelatedTitle = relatedProps.title ?? l.relatedTitle;
349
346
  </BreadcrumbBand>
350
347
  )}
351
348
 
349
+ <main>
350
+ <article data-pagefind-body data-pagefind-meta="type:article">
351
+ {emitAudienceFacets && article.audiences?.map((a) => (
352
+ <span class="sr-only" data-pagefind-filter={`audience:${a}`}>{a}</span>
353
+ ))}
354
+
352
355
  {heroImage ? (
353
356
  railHead ? (
354
357
  <ContentHero
@@ -410,7 +413,6 @@ const resolvedRelatedTitle = relatedProps.title ?? l.relatedTitle;
410
413
  </header>
411
414
  )}
412
415
 
413
- <main>
414
416
  <Container size="measure" class={editorial ? 'relative pt-6 pb-10 sm:pt-8 sm:pb-14' : 'py-10 sm:py-14'}>
415
417
  {!railHead && <ArticleMetadata
416
418
  author={author}
@@ -537,7 +539,7 @@ const resolvedRelatedTitle = relatedProps.title ?? l.relatedTitle;
537
539
 
538
540
  {faqItems.length > 0 && (
539
541
  <div class="mt-12 pt-8 border-t border-border">
540
- <FAQ items={faqItems} id="faq" locale={locale} />
542
+ <FAQ items={faqItems} id="faq" itemIds={faqIds} itemScrollMarginClass={sectionScrollMarginClass} locale={locale} />
541
543
  </div>
542
544
  )}
543
545
 
@@ -601,5 +603,13 @@ const resolvedRelatedTitle = relatedProps.title ?? l.relatedTitle;
601
603
  </footer>
602
604
  )}
603
605
  </Container>
604
- </main>
605
606
  </article>
607
+ </main>
608
+
609
+ <script>
610
+ import { openFaqTarget } from '../composed/faq-target.ts';
611
+
612
+ window.addEventListener('hashchange', openFaqTarget);
613
+ document.addEventListener('astro:page-load', openFaqTarget);
614
+ openFaqTarget();
615
+ </script>
@@ -36,6 +36,8 @@ interface Props {
36
36
  /** Chips shown in the tag row (all by default). */
37
37
  relatedTagsLimit?: number;
38
38
  showRelatedTags?: boolean;
39
+ /** Pass `false` where the site header already lists the categories. */
40
+ showCategoryNav?: boolean;
39
41
  locale?: string;
40
42
  /** Overrides of the article routes (`articles`, `articleTopic`), for the topic nav. */
41
43
  routes?: SiteRoutes;
@@ -52,6 +54,7 @@ const {
52
54
  relatedTags = [],
53
55
  relatedTagsLimit,
54
56
  showRelatedTags = true,
57
+ showCategoryNav = true,
55
58
  locale,
56
59
  routes,
57
60
  } = Astro.props;
@@ -68,7 +71,7 @@ const countWord = count === 1 ? l.countOne : l.countMany;
68
71
  </p>
69
72
 
70
73
  <Container>
71
- {categories && articles.length > 0 && (
74
+ {showCategoryNav && categories && articles.length > 0 && (
72
75
  <ArticleCategoryNav articles={articles} categories={categories} routes={routes} class="mb-8" />
73
76
  )}
74
77
 
@@ -38,11 +38,13 @@ interface Props {
38
38
  authors?: { heading: string; items: TopicAuthorCard[] };
39
39
  /** The site's prose theme modifier for the overview, added to `prose` (a dark site needs its own body colour). */
40
40
  proseClass?: string;
41
+ /** Pass `false` where the site header already lists the categories. */
42
+ showCategoryNav?: boolean;
41
43
  /** Overrides of the article routes (`articles`, `articleTopic`), for the topic nav. */
42
44
  routes?: SiteRoutes;
43
45
  }
44
46
 
45
- const { eyebrow, heading, lede, articles, categories, category, currentPage, listHeading, overview, authors, proseClass = 'prose-lg', routes } = Astro.props;
47
+ const { eyebrow, heading, lede, articles, categories, category, currentPage, listHeading, overview, authors, proseClass = 'prose-lg', showCategoryNav = true, routes } = Astro.props;
46
48
  const hub = currentPage === 1;
47
49
  // Astro.slots.has() is true for a slotted expression that evaluated to false, so test what it rendered.
48
50
  const faqHtml = hub && Astro.slots.has('faq') ? (await Astro.slots.render('faq')).trim() : '';
@@ -53,7 +55,7 @@ const faqHtml = hub && Astro.slots.has('faq') ? (await Astro.slots.render('faq')
53
55
  <slot name="breadcrumb" slot="breadcrumb" />
54
56
  <slot name="header-extra" slot="header-extra" />
55
57
  <Container>
56
- <ArticleCategoryNav articles={articles} categories={categories} current={category} routes={routes} class="mb-12" />
58
+ <ArticleCategoryNav articles={articles} categories={categories} current={category} routes={routes} hidden={!showCategoryNav} class="mb-12" />
57
59
  <slot name="start-here" /></Container>
58
60
 
59
61
  {overview && (
@@ -106,7 +108,7 @@ const faqHtml = hub && Astro.slots.has('faq') ? (await Astro.slots.render('faq')
106
108
  <ArticlesListingPage eyebrow={eyebrow} heading={heading} lede={lede}>
107
109
  <slot name="breadcrumb" slot="breadcrumb" />
108
110
  <Container>
109
- <ArticleCategoryNav articles={articles} categories={categories} current={category} routes={routes} class="mb-10" />
111
+ <ArticleCategoryNav articles={articles} categories={categories} current={category} routes={routes} hidden={!showCategoryNav} class="mb-10" />
110
112
  <slot name="grid" />
111
113
  <slot name="pagination" />
112
114
  </Container>
@@ -2,6 +2,7 @@
2
2
  import type { ImageMetadata } from 'astro';
3
3
  import Container from '../layout/Container.astro';
4
4
  import BreadcrumbBand from '../layout/BreadcrumbBand.astro';
5
+ import { HEADER_OFFSET_PT } from '../layout/headerOffset.ts';
5
6
  import ResponsiveImage from '../primitives/ResponsiveImage.astro';
6
7
  import Chip from '../primitives/Chip.astro';
7
8
  import RoleBadge from './RoleBadge.astro';
@@ -90,7 +91,7 @@ const hasWorksSlot = Astro.slots.has('works');
90
91
  ---
91
92
 
92
93
  <div class="bg-muted border-b border-border" data-pagefind-body>
93
- <BreadcrumbBand ignore={false} class="pt-16">
94
+ <BreadcrumbBand ignore={false} class={HEADER_OFFSET_PT}>
94
95
  <slot name="breadcrumb" />
95
96
  </BreadcrumbBand>
96
97
  <header class="pt-10 pb-12">
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  import Container from '../layout/Container.astro';
3
3
  import BreadcrumbBand from '../layout/BreadcrumbBand.astro';
4
+ import { HEADER_OFFSET_PT } from '../layout/headerOffset.ts';
4
5
  import Button from '../primitives/Button.astro';
5
6
  import { getLabels } from '../internal/labels';
6
7
 
@@ -52,7 +53,7 @@ const hasFaq = Astro.slots.has('faq');
52
53
  ---
53
54
 
54
55
  <div class="bg-muted border-b border-border" data-pagefind-body>
55
- <BreadcrumbBand ignore={false} class="pt-16">
56
+ <BreadcrumbBand ignore={false} class={HEADER_OFFSET_PT}>
56
57
  <slot name="breadcrumb" />
57
58
  </BreadcrumbBand>
58
59
  <header class="pt-12 pb-12">
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import type { EraDefinition } from '@sarimarcus/content-sites-core/eras';
10
10
  import { getLabels } from '../internal/labels';
11
+ import { HEADER_OFFSET_TOP } from '../layout/headerOffset.ts';
11
12
 
12
13
  interface Props {
13
14
  eras: readonly EraDefinition[];
@@ -26,7 +27,7 @@ const { eras, ariaLabel = getLabels(Astro.props.locale ?? Astro.currentLocale).e
26
27
  data-era-timeline-nav
27
28
  data-toc-section-selector={sectionSelector}
28
29
  aria-label={ariaLabel}
29
- class:list={['sticky top-16 z-30 hidden border-b border-border bg-background/95 backdrop-blur-sm md:block', className]}
30
+ class:list={['sticky z-30 hidden border-b border-border bg-background/95 backdrop-blur-sm md:block', HEADER_OFFSET_TOP, className]}
30
31
  >
31
32
  <ol class="mx-auto flex max-w-shell px-4 sm:px-6 lg:px-8">
32
33
  {eras.map((era) => (
@@ -0,0 +1,33 @@
1
+ ---
2
+ /**
3
+ * HubBridge — other topic hubs worth visiting from this one, each with a short reason. Pick them with hubBridge()
4
+ * (shared tags) or hubLinkBridge() (editorial links); the site writes the reason line.
5
+ */
6
+ import ArrowLabel from '../primitives/ArrowLabel.astro';
7
+
8
+ interface Props {
9
+ heading: string;
10
+ items: readonly { label: string; href: string; reason: string }[];
11
+ }
12
+
13
+ const { heading, items } = Astro.props;
14
+ ---
15
+
16
+ {items.length > 0 && (
17
+ <section class="mt-12" aria-labelledby="hub-bridge-h" data-hub-block="bridge">
18
+ <h2 id="hub-bridge-h" class="text-xl font-semibold font-display text-foreground mb-4">{heading}</h2>
19
+ <ul role="list" class="grid gap-4 sm:grid-cols-2">
20
+ {items.map((item) => (
21
+ <li>
22
+ <a
23
+ href={item.href}
24
+ class="group block rounded-xl border border-border bg-card p-5 hover:border-primary transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
25
+ >
26
+ <ArrowLabel class="font-semibold text-foreground">{item.label}</ArrowLabel>
27
+ <span class="mt-1 block text-sm text-muted-foreground">{item.reason}</span>
28
+ </a>
29
+ </li>
30
+ ))}
31
+ </ul>
32
+ </section>
33
+ )}
@@ -0,0 +1,38 @@
1
+ ---
2
+ /**
3
+ * HubNumbers — a topic hub's key figures, one per article, each linking to its article. Pick them with statFacts().
4
+ */
5
+ import { getLabels } from '../internal/labels';
6
+
7
+ interface Props {
8
+ facts: readonly { figure: string; label: string; href: string; title: string }[];
9
+ /** Renders nothing below this many facts (default 2). */
10
+ min?: number;
11
+ heading?: string;
12
+ locale?: string;
13
+ }
14
+
15
+ const { facts, min = 2 } = Astro.props;
16
+ const labels = getLabels(Astro.props.locale ?? Astro.currentLocale).hubNumbers;
17
+ const heading = Astro.props.heading ?? labels.heading(facts.length);
18
+ ---
19
+
20
+ {facts.length >= min && (
21
+ <section class="mb-12" aria-labelledby="hub-numbers-h" data-hub-block="numbers">
22
+ <h2 id="hub-numbers-h" class="text-xl font-semibold font-display text-foreground mb-4">{heading}</h2>
23
+ <ul role="list" class="grid gap-4 sm:grid-cols-3">
24
+ {facts.map((f) => (
25
+ <li>
26
+ <a
27
+ href={f.href}
28
+ class="block h-full rounded-xl border border-border bg-card p-5 hover:border-primary transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
29
+ >
30
+ <span class="block font-display text-3xl font-semibold text-foreground leading-none">{f.figure}</span>
31
+ <span class="mt-2 block text-sm text-foreground">{f.label}</span>
32
+ <span class="mt-3 block text-xs text-muted-foreground">{labels.fromArticle} {f.title}</span>
33
+ </a>
34
+ </li>
35
+ ))}
36
+ </ul>
37
+ </section>
38
+ )}
@@ -0,0 +1,38 @@
1
+ ---
2
+ /**
3
+ * HubQuestions — a topic hub's "Questions this topic answers": FAQ questions from its articles, each linking to its
4
+ * answer on the article page. Links only, never FAQPage markup (the hub's own FAQ keeps that schema). Pick the items
5
+ * with hubQuestions(); the site builds each href from the slug and anchor.
6
+ */
7
+ import Chip from '../primitives/Chip.astro';
8
+ import { getLabels } from '../internal/labels';
9
+
10
+ interface Props {
11
+ items: readonly { question: string; href: string }[];
12
+ heading?: string;
13
+ /** Renders nothing below this many items (default 3). */
14
+ min?: number;
15
+ locale?: string;
16
+ class?: string;
17
+ }
18
+
19
+ const {
20
+ items,
21
+ heading = getLabels(Astro.props.locale ?? Astro.currentLocale).hubQuestions.heading,
22
+ min = 3,
23
+ class: className = 'mt-12',
24
+ } = Astro.props;
25
+ ---
26
+
27
+ {items.length >= min && (
28
+ <section class={className} aria-labelledby="hub-questions-h" data-hub-block="questions">
29
+ <h2 id="hub-questions-h" class="text-xl font-semibold font-display text-foreground mb-4">{heading}</h2>
30
+ <ul role="list" class="flex flex-wrap gap-3">
31
+ {items.map((q) => (
32
+ <li>
33
+ <Chip href={q.href} size="md" tone="outline" accent="primary" text="inherit" weight="inherit">{q.question}</Chip>
34
+ </li>
35
+ ))}
36
+ </ul>
37
+ </section>
38
+ )}
@@ -0,0 +1,30 @@
1
+ ---
2
+ /**
3
+ * HubSources — the primary authorities a topic hub's articles cite. Pick them with sourceAuthorities().
4
+ */
5
+ import { getLabels } from '../internal/labels';
6
+
7
+ interface Props {
8
+ authorities: readonly { label: string; count: number }[];
9
+ heading?: string;
10
+ lead?: string;
11
+ locale?: string;
12
+ }
13
+
14
+ const { authorities } = Astro.props;
15
+ const labels = getLabels(Astro.props.locale ?? Astro.currentLocale).hubSources;
16
+ const heading = Astro.props.heading ?? labels.heading;
17
+ const lead = Astro.props.lead ?? labels.lead;
18
+ ---
19
+
20
+ {authorities.length > 0 && (
21
+ <section class="mt-12" aria-labelledby="hub-sources-h" data-hub-block="sources">
22
+ <h2 id="hub-sources-h" class="text-xl font-semibold font-display text-foreground mb-3">{heading}</h2>
23
+ <p class="text-base text-muted-foreground">
24
+ {lead}
25
+ {authorities.map((a, i) => (
26
+ <Fragment><span class="text-foreground font-medium">{a.label}</span>{i < authorities.length - 1 ? ' · ' : '.'}</Fragment>
27
+ ))}
28
+ </p>
29
+ </section>
30
+ )}
@@ -5,6 +5,7 @@
5
5
  * Not Pagefind-indexed: it carries no body marker.
6
6
  */
7
7
  import Container from '../layout/Container.astro';
8
+ import { HEADER_OFFSET_PT } from '../layout/headerOffset.ts';
8
9
  import Button from '../primitives/Button.astro';
9
10
 
10
11
  interface CtaLink {
@@ -25,7 +26,7 @@ interface Props {
25
26
  const { heading, eyebrow, cta, proseClass = 'prose-stone' } = Astro.props;
26
27
  ---
27
28
 
28
- <div class="pt-16 bg-gradient-to-b from-muted/60 via-background to-background border-b border-border">
29
+ <div class:list={[HEADER_OFFSET_PT, 'bg-gradient-to-b from-muted/60 via-background to-background border-b border-border']}>
29
30
  <Container size="measure" class="py-10 sm:py-14">
30
31
  {eyebrow && <p class="text-sm font-semibold uppercase tracking-[0.18em] text-primary">{eyebrow}</p>}
31
32
  <h1 class="mt-3 text-4xl sm:text-5xl font-bold font-display text-foreground leading-tight text-balance">{heading}</h1>
@@ -0,0 +1,158 @@
1
+ // Pure selection logic for the topic hub blocks (Numbers, Sources, Bridge). Structural types only, so it runs under
2
+ // plain Node for tests.
3
+ import { outboundHostKey } from '@sarimarcus/content-sites-core/url';
4
+
5
+ export interface HubFact {
6
+ figure: string;
7
+ label: string;
8
+ }
9
+
10
+ interface Source {
11
+ url?: string;
12
+ }
13
+
14
+ export interface HubArticle {
15
+ data: {
16
+ slug: string;
17
+ category?: string | null;
18
+ tags?: readonly string[];
19
+ keyFacts?: readonly HubFact[];
20
+ sources?: readonly (Source | string)[];
21
+ relatedContent?: readonly { type?: string; slug?: string }[];
22
+ };
23
+ }
24
+
25
+ /** Up to `limit` key facts from distinct articles, shortest figure first; `exclude` slugs are skipped. */
26
+ export function statFacts<A extends HubArticle>(
27
+ articles: readonly A[],
28
+ { limit = 3, exclude = [] as readonly string[] } = {},
29
+ ): { article: A; fact: HubFact }[] {
30
+ const skip = new Set(exclude);
31
+ return articles
32
+ .filter((a) => !skip.has(a.data.slug))
33
+ .flatMap((a) => {
34
+ const fact = [...(a.data.keyFacts ?? [])].sort((x, y) => x.figure.length - y.figure.length)[0];
35
+ return fact ? [{ article: a, fact }] : [];
36
+ })
37
+ .sort((x, y) => x.fact.figure.length - y.fact.figure.length)
38
+ .slice(0, limit);
39
+ }
40
+
41
+ /**
42
+ * Other topic hubs to suggest from `category`, ranked by tags shared with it, ignoring tags present in `maxSpread`
43
+ * or more categories (they link everything to everything). Each comes with the shared tags as its reason.
44
+ */
45
+ export function hubBridge(
46
+ articles: readonly HubArticle[],
47
+ category: string,
48
+ { maxSpread = 4, limit = 2 } = {},
49
+ ): { category: string; tags: string[] }[] {
50
+ const tagsByCategory = new Map<string, Set<string>>();
51
+ for (const a of articles) {
52
+ if (!a.data.category) continue;
53
+ const set = tagsByCategory.get(a.data.category) ?? new Set<string>();
54
+ for (const t of a.data.tags ?? []) set.add(t);
55
+ tagsByCategory.set(a.data.category, set);
56
+ }
57
+ const spread = new Map<string, number>();
58
+ for (const set of tagsByCategory.values()) for (const t of set) spread.set(t, (spread.get(t) ?? 0) + 1);
59
+ const own = tagsByCategory.get(category) ?? new Set<string>();
60
+ return [...tagsByCategory.entries()]
61
+ .filter(([c]) => c !== category)
62
+ .map(([c, set]) => ({ category: c, tags: [...set].filter((t) => own.has(t) && (spread.get(t) ?? 0) < maxSpread).sort() }))
63
+ .filter((b) => b.tags.length > 0)
64
+ .sort((x, y) => y.tags.length - x.tags.length || x.category.localeCompare(y.category))
65
+ .slice(0, limit);
66
+ }
67
+
68
+ /**
69
+ * Other topic hubs to suggest from `category`, ranked by editorial links between them: relatedContent article links
70
+ * from this hub's articles to theirs, and from theirs to this hub's. `links` counts distinct article pairs.
71
+ */
72
+ export function hubLinkBridge(
73
+ articles: readonly HubArticle[],
74
+ category: string,
75
+ { limit = 2, minLinks = 1 } = {},
76
+ ): { category: string; links: number }[] {
77
+ const categoryOf = new Map(articles.map((a) => [a.data.slug, a.data.category ?? null]));
78
+ const pairs = new Map<string, Set<string>>();
79
+ for (const a of articles) {
80
+ for (const r of a.data.relatedContent ?? []) {
81
+ if (r.type !== 'article' || !r.slug) continue;
82
+ const from = a.data.category;
83
+ const to = categoryOf.get(r.slug);
84
+ if (!from || !to || from === to || (from !== category && to !== category)) continue;
85
+ const other = from === category ? to : from;
86
+ const key = [a.data.slug, r.slug].sort().join('|');
87
+ const set = pairs.get(other) ?? new Set<string>();
88
+ set.add(key);
89
+ pairs.set(other, set);
90
+ }
91
+ }
92
+ return [...pairs.entries()]
93
+ .map(([c, set]) => ({ category: c, links: set.size }))
94
+ .filter((b) => b.links >= minLinks)
95
+ .sort((x, y) => y.links - x.links || x.category.localeCompare(y.category))
96
+ .slice(0, limit);
97
+ }
98
+
99
+ function sourceHost(s: Source | string): string | null {
100
+ try {
101
+ return outboundHostKey(new URL(typeof s === 'string' ? s : (s.url ?? '')).hostname);
102
+ } catch {
103
+ return null;
104
+ }
105
+ }
106
+
107
+ function labelCounts(articles: readonly HubArticle[], labels: Readonly<Record<string, string>>): Map<string, number> {
108
+ const byDomain = new Map(Object.entries(labels).map(([d, label]) => [outboundHostKey(d), label]));
109
+ const domains = [...byDomain.keys()].sort((a, b) => b.length - a.length);
110
+ const counts = new Map<string, number>();
111
+ for (const a of articles) {
112
+ for (const s of a.data.sources ?? []) {
113
+ const host = sourceHost(s);
114
+ const domain = host && domains.find((d) => host === d || host.endsWith(`.${d}`));
115
+ if (!domain) continue;
116
+ const label = byDomain.get(domain)!;
117
+ counts.set(label, (counts.get(label) ?? 0) + 1);
118
+ }
119
+ }
120
+ return counts;
121
+ }
122
+
123
+ /**
124
+ * Labelled primary authorities cited by a hub's `articles`; unlisted hosts are dropped. With `siteArticles`, ranked
125
+ * by how specific each is to this hub (citations here × log(categories / categories citing it)), so an authority every
126
+ * hub cites only fills leftover places; without it, by citation count. Ties fall back to citation count.
127
+ */
128
+ export function sourceAuthorities(
129
+ articles: readonly HubArticle[],
130
+ labels: Readonly<Record<string, string>>,
131
+ { limit = 6, siteArticles }: { limit?: number; siteArticles?: readonly HubArticle[] } = {},
132
+ ): { label: string; count: number }[] {
133
+ const counts = labelCounts(articles, labels);
134
+ let weight = (_label: string) => 1;
135
+ if (siteArticles) {
136
+ const byCategory = new Map<string, HubArticle[]>();
137
+ for (const a of siteArticles) {
138
+ if (!a.data.category) continue;
139
+ const group = byCategory.get(a.data.category);
140
+ if (group) group.push(a);
141
+ else byCategory.set(a.data.category, [a]);
142
+ }
143
+ const spread = new Map<string, number>();
144
+ for (const group of byCategory.values()) for (const label of labelCounts(group, labels).keys()) spread.set(label, (spread.get(label) ?? 0) + 1);
145
+ const total = Math.max(byCategory.size, 1);
146
+ weight = (label) => Math.log(total / Math.max(spread.get(label) ?? 1, 1));
147
+ }
148
+ return [...counts.entries()]
149
+ .map(([label, count]) => ({ label, count, score: count * weight(label) }))
150
+ .sort((x, y) => y.score - x.score || y.count - x.count || x.label.localeCompare(y.label))
151
+ .slice(0, limit)
152
+ .map(({ label, count }) => ({ label, count }));
153
+ }
154
+
155
+ /** Hub prose links articles as `href="article:<slug>"`, so the site's routes decide the URL; this resolves them. */
156
+ export function resolveArticleLinks(html: string, hrefOf: (slug: string) => string): string {
157
+ return html.replace(/href="article:([^"]+)"/g, (_, slug: string) => `href="${hrefOf(slug)}"`);
158
+ }
@@ -0,0 +1,63 @@
1
+ import { stripMarkdown } from '@sarimarcus/content-sites-core/text';
2
+ import { faqAnchorIds } from '../composed/faq-anchors.ts';
3
+
4
+ export interface HubQuestionSource {
5
+ slug: string;
6
+ faqs?: readonly { question: string }[];
7
+ }
8
+
9
+ export interface HubQuestion {
10
+ /** The article's slug; the site's routes build the URL. */
11
+ slug: string;
12
+ /** Plain text, markdown stripped. */
13
+ question: string;
14
+ /** The FAQ item's id on the article page, without '#'. */
15
+ anchor: string;
16
+ }
17
+
18
+ function opener(question: string): string {
19
+ return question.trim().split(/\s+/)[0].toLowerCase().replace(/[^\p{L}\p{N}]/gu, '');
20
+ }
21
+
22
+ /**
23
+ * Up to `limit` FAQ questions for a topic hub: at most one per article, in input order, and at most `maxPerOpener`
24
+ * sharing an opening word ("How", "What"...) until no article is left that would vary them. Questions over
25
+ * `maxLength` characters are skipped: they render as chips, which the badge-overflow push gate caps at 80.
26
+ */
27
+ export function hubQuestions(
28
+ articles: readonly HubQuestionSource[],
29
+ { limit = 6, maxPerOpener = 2, maxLength = 80, exclude = [] as readonly string[] } = {},
30
+ ): HubQuestion[] {
31
+ const skip = new Set(exclude);
32
+ const candidates = articles
33
+ .filter((a) => !skip.has(a.slug) && (a.faqs?.length ?? 0) > 0)
34
+ .map((a) => {
35
+ const questions = a.faqs!.map((f) => f.question);
36
+ const anchors = faqAnchorIds(questions);
37
+ const items = questions
38
+ .map((q, i) => ({ question: stripMarkdown(q).trim(), anchor: anchors[i] }))
39
+ .filter((it) => it.question && it.question.length <= maxLength);
40
+ return { slug: a.slug, items };
41
+ });
42
+
43
+ const picked: HubQuestion[] = [];
44
+ const used = new Set<string>();
45
+ const openers = new Map<string, number>();
46
+ const take = (slug: string, item: { question: string; anchor: string }) => {
47
+ picked.push({ slug, ...item });
48
+ used.add(slug);
49
+ const o = opener(item.question);
50
+ openers.set(o, (openers.get(o) ?? 0) + 1);
51
+ };
52
+
53
+ for (const c of candidates) {
54
+ if (picked.length >= limit) break;
55
+ const item = c.items.find((it) => (openers.get(opener(it.question)) ?? 0) < maxPerOpener);
56
+ if (item) take(c.slug, item);
57
+ }
58
+ for (const c of candidates) {
59
+ if (picked.length >= limit) break;
60
+ if (!used.has(c.slug) && c.items[0]) take(c.slug, c.items[0]);
61
+ }
62
+ return picked;
63
+ }
@@ -46,6 +46,13 @@ export { default as EraTimelineNav } from './EraTimelineNav.astro';
46
46
  export { default as PeopleTimeline } from './PeopleTimeline.astro';
47
47
  export { layoutPeopleTimeline, footstepLinks, type PeopleTimelineEntry, type PeopleTimelineDot, type PeopleTimelineSegment } from './people-timeline';
48
48
  export { monogram } from './monogram';
49
+ export { default as HubQuestions } from './HubQuestions.astro';
50
+ export { hubQuestions, type HubQuestion, type HubQuestionSource } from './hub-questions';
51
+ export { faqAnchorIds } from '../composed/faq-anchors';
52
+ export { default as HubNumbers } from './HubNumbers.astro';
53
+ export { default as HubSources } from './HubSources.astro';
54
+ export { default as HubBridge } from './HubBridge.astro';
55
+ export { statFacts, hubBridge, hubLinkBridge, sourceAuthorities, resolveArticleLinks, type HubArticle, type HubFact } from './hub-blocks';
49
56
  export type { AlsoExploreItem } from './AlsoExplore.astro';
50
57
  export type { VisitTimingData } from './VisitTiming.astro';
51
58
  export { default as AnswerBox } from './interludes/AnswerBox.astro';
@@ -17,8 +17,11 @@ interface Props {
17
17
  image?: ImageMetadata;
18
18
  imageAlt?: string;
19
19
  eyebrowClass?: string;
20
+ /** Heading level of the title: h3 by default, the level under an article's H2 sections. */
21
+ headingLevel?: 3 | 4;
20
22
  }
21
- const { href, eyebrow, title, description, variant = 'inline', image, imageAlt, eyebrowClass } = Astro.props;
23
+ const { href, eyebrow, title, description, variant = 'inline', image, imageAlt, eyebrowClass, headingLevel = 3 } = Astro.props;
24
+ const Heading = `h${headingLevel}` as 'h3' | 'h4';
22
25
  ---
23
26
 
24
27
  {variant === 'inline' ? (
@@ -30,9 +33,9 @@ const { href, eyebrow, title, description, variant = 'inline', image, imageAlt,
30
33
  <p class={eyebrowClass ?? 'text-xs font-semibold uppercase tracking-[0.16em] text-primary mb-1'}>
31
34
  {eyebrow}
32
35
  </p>
33
- <h4 class="text-base sm:text-lg font-semibold font-display text-foreground leading-snug group-hover:text-primary transition-colors">
36
+ <Heading class="text-base sm:text-lg font-semibold font-display text-foreground leading-snug group-hover:text-primary transition-colors">
34
37
  {title}
35
- </h4>
38
+ </Heading>
36
39
  {description && (
37
40
  <p class="mt-1 text-sm text-muted-foreground leading-relaxed line-clamp-2">{description}</p>
38
41
  )}
@@ -63,9 +66,9 @@ const { href, eyebrow, title, description, variant = 'inline', image, imageAlt,
63
66
  <p class={eyebrowClass ?? 'text-xs font-semibold uppercase tracking-[0.16em] text-primary mb-1'}>
64
67
  {eyebrow}
65
68
  </p>
66
- <h4 class="text-base sm:text-lg font-semibold font-display text-foreground leading-snug group-hover:text-primary transition-colors line-clamp-2">
69
+ <Heading class="text-base sm:text-lg font-semibold font-display text-foreground leading-snug group-hover:text-primary transition-colors line-clamp-2">
67
70
  {title}
68
- </h4>
71
+ </Heading>
69
72
  </div>
70
73
  <Icon
71
74
  name="arrow-right"
@@ -96,9 +99,9 @@ const { href, eyebrow, title, description, variant = 'inline', image, imageAlt,
96
99
  <p class={eyebrowClass ?? 'text-xs font-medium uppercase tracking-[0.16em] text-primary'}>
97
100
  {eyebrow}
98
101
  </p>
99
- <h4 class="text-lg font-semibold font-display text-foreground leading-snug group-hover:text-primary transition-colors">
102
+ <Heading class="text-lg font-semibold font-display text-foreground leading-snug group-hover:text-primary transition-colors">
100
103
  {title}
101
- </h4>
104
+ </Heading>
102
105
  {description && (
103
106
  <p class="text-sm text-muted-foreground leading-relaxed line-clamp-2">{description}</p>
104
107
  )}
@@ -66,6 +66,9 @@ export const LABELS = {
66
66
  nextLabel: (name: string | undefined) => `Next, ${name ?? 'carousel'}`,
67
67
  },
68
68
  faq: { title: 'Frequently asked questions' },
69
+ hubQuestions: { heading: 'Questions this topic answers' },
70
+ hubNumbers: { heading: (n: number) => (n === 1 ? 'In one number' : `In ${n} numbers`), fromArticle: 'From the article:' },
71
+ hubSources: { heading: 'Sources for this topic', lead: 'Based on primary sources: ' },
69
72
  pagination: {
70
73
  ariaLabel: 'Pagination',
71
74
  previousLabel: 'Previous',
@@ -322,6 +325,9 @@ export const LABELS_IT: typeof LABELS = {
322
325
  nextLabel: (name: string | undefined) => `Successivo, ${name ?? 'carosello'}`,
323
326
  },
324
327
  faq: { title: 'Domande frequenti' },
328
+ hubQuestions: { heading: 'Le domande di questa sezione' },
329
+ hubNumbers: { heading: (n: number) => (n === 1 ? 'In un numero' : `In ${n} numeri`), fromArticle: 'Dall’articolo:' },
330
+ hubSources: { heading: 'Fonti di questa sezione', lead: 'Basato su fonti primarie: ' },
325
331
  pagination: {
326
332
  ariaLabel: 'Paginazione',
327
333
  previousLabel: 'Precedente',
@@ -1,16 +1,17 @@
1
1
  ---
2
2
  /**
3
3
  * BreadcrumbBand — the muted strip under the fixed header that holds a page's breadcrumb trail (default slot).
4
- * `ignore` keeps it out of the Pagefind body. `class` replaces the band's own classes (keep `pt-16`, the header offset).
4
+ * `ignore` keeps it out of the Pagefind body. `class` replaces the band's own classes (keep `HEADER_OFFSET_PT` from `./headerOffset.ts`, the header offset).
5
5
  */
6
6
  import Container from './Container.astro';
7
+ import { HEADER_OFFSET_PT } from './headerOffset.ts';
7
8
 
8
9
  interface Props {
9
10
  ignore?: boolean;
10
11
  class?: string;
11
12
  }
12
13
 
13
- const { ignore = true, class: className = 'pt-16 bg-muted/50 border-b border-border' } = Astro.props;
14
+ const { ignore = true, class: className = `${HEADER_OFFSET_PT} bg-muted/50 border-b border-border` } = Astro.props;
14
15
  ---
15
16
 
16
17
  <div class={className} data-pagefind-ignore={ignore ? '' : undefined}>
@@ -169,7 +169,7 @@ const isArticleMeta = Boolean(articleAuthorUrl || publishedTime || modifiedTime
169
169
 
170
170
  {Astro.slots.has('nav') && <div data-pagefind-ignore><slot name="nav" /></div>}
171
171
 
172
- <div id="main-content" class:list={[mainClass, 'flex-1']}>
172
+ <div id="main-content" tabindex="-1" class:list={[mainClass, 'flex-1 focus:outline-none']}>
173
173
  <slot />
174
174
  </div>
175
175
 
@@ -0,0 +1,3 @@
1
+ /** Classes that clear the fixed site header: 4rem, or the nav plus its trending bar where `SiteHeader` sets `--site-header-offset`. */
2
+ export const HEADER_OFFSET_PT = 'pt-[var(--site-header-offset,4rem)]';
3
+ export const HEADER_OFFSET_TOP = 'top-[var(--site-header-offset,4rem)]';
@@ -28,7 +28,7 @@ const look = emphasis
28
28
  href={link.href}
29
29
  aria-current={active ? 'page' : undefined}
30
30
  class:list={[
31
- `flex items-center gap-3 px-4 py-2.5 text-sm ${look} hover:bg-muted transition-colors focus-visible:ring-2 ${t.ring} focus-visible:ring-offset-2`,
31
+ `flex min-h-11 items-center gap-3 px-4 py-2.5 text-sm ${look} hover:bg-muted transition-colors focus-visible:ring-2 ${t.ring} focus-visible:ring-offset-2`,
32
32
  active && !emphasis && `${t.text} font-medium`,
33
33
  className,
34
34
  ]}
@@ -13,6 +13,7 @@
13
13
  */
14
14
  import { Icon } from '../primitives/index.ts';
15
15
  import { getLabels } from '../internal/labels';
16
+ import { HEADER_OFFSET_TOP } from '../layout/headerOffset.ts';
16
17
 
17
18
  export interface TrendingTopicLink {
18
19
  label: string;
@@ -64,6 +65,7 @@ const xl = desktopBreakpoint === 'xl';
64
65
  id={id}
65
66
  class:list={['site-header', className]}
66
67
  data-site-nav
68
+ data-desktop-breakpoint={desktopBreakpoint}
67
69
  data-search-path={searchPath}
68
70
  data-search-base={searchPath ? import.meta.env.BASE_URL : undefined}
69
71
  >
@@ -93,14 +95,14 @@ const xl = desktopBreakpoint === 'xl';
93
95
  </div>
94
96
  </div>
95
97
  </nav>{trendingTags.length > 0 && (
96
- <div class="hidden md:block border-t border-border/60 bg-muted/40">
97
- <div class="mx-auto max-w-shell px-4 sm:px-6 lg:px-8 flex items-center justify-center gap-3 h-9 text-xs">
98
+ <div class="hidden md:block border-t border-border/60 bg-muted/40" data-site-trending>
99
+ <div class="mx-auto max-w-shell px-4 sm:px-6 lg:px-8 flex items-center justify-center gap-3 h-11 text-xs">
98
100
  <span class="font-semibold uppercase tracking-widest text-primary shrink-0">{trendingLabel}</span>
99
101
  <span class="text-border shrink-0" aria-hidden="true">|</span>
100
102
  <ul class="flex items-center gap-4 min-w-0 overflow-x-auto">
101
103
  {trendingTags.map((tag) => (
102
104
  <li>
103
- <a href={tag.href} class="text-muted-foreground hover:text-foreground transition-colors font-medium whitespace-nowrap">
105
+ <a href={tag.href} class="flex h-11 items-center text-muted-foreground hover:text-foreground transition-colors font-medium whitespace-nowrap">
104
106
  #{tag.label}
105
107
  </a>
106
108
  </li>
@@ -111,7 +113,7 @@ const xl = desktopBreakpoint === 'xl';
111
113
  )}
112
114
  </header>
113
115
 
114
- <div id={panelId} class:list={[xl ? 'xl:hidden' : 'lg:hidden', 'hidden fixed inset-x-0 top-16 bottom-0 z-50 overflow-y-auto overscroll-contain', surfaceClass]} data-pagefind-ignore>
116
+ <div id={panelId} class:list={[xl ? 'xl:hidden' : 'lg:hidden', 'hidden fixed inset-x-0 bottom-0 z-50 overflow-y-auto overscroll-contain', HEADER_OFFSET_TOP, surfaceClass]} data-pagefind-ignore>
115
117
  <div class="flex flex-col pt-2 pb-12 border-t border-border relative">
116
118
  <slot name="mobile" />
117
119
  </div>
@@ -130,6 +132,13 @@ const xl = desktopBreakpoint === 'xl';
130
132
  overflow: hidden;
131
133
  }
132
134
 
135
+ /* The fixed header is the 4rem nav plus, from md, the 2.75rem trending bar and its 1px rule: `--site-header-offset` is what a band under it clears. */
136
+ @media (min-width: 768px) {
137
+ :global(:root:has([data-site-trending])) {
138
+ --site-header-offset: calc(4rem + 2.75rem + 1px);
139
+ }
140
+ }
141
+
133
142
  /* The icons are Icon components, which scoped selectors do not reach. */
134
143
  .site-header-toggle :global(.menu-close-icon),
135
144
  .site-header-toggle[aria-expanded='true'] :global(.menu-open-icon) {
@@ -113,8 +113,13 @@ function searchPathOf(root: HTMLElement): string | null {
113
113
  return (window.location.pathname.indexOf(compiled) === 0 ? compiled : '') + path;
114
114
  }
115
115
 
116
- function closeOpenMobileMenus(refocus: boolean): void {
116
+ const DESKTOP_MIN_WIDTH = { lg: '64rem', xl: '80rem' } as const;
117
+ type DesktopBreakpoint = keyof typeof DESKTOP_MIN_WIDTH;
118
+ const breakpointOf = (root: HTMLElement): DesktopBreakpoint => (root.dataset.desktopBreakpoint === 'xl' ? 'xl' : 'lg');
119
+
120
+ function closeOpenMobileMenus(refocus: boolean, breakpoint?: DesktopBreakpoint): void {
117
121
  roots().forEach((root) => {
122
+ if (breakpoint && breakpointOf(root) !== breakpoint) return;
118
123
  const toggle = root.querySelector<HTMLButtonElement>('[data-mobile-menu-toggle]');
119
124
  if (toggle?.getAttribute('aria-expanded') === 'true') setMobileMenu(root, toggle, false, refocus);
120
125
  });
@@ -145,9 +150,11 @@ function bindDocument(): void {
145
150
  window.location.assign(`${searchPath}?focus=1`);
146
151
  });
147
152
 
148
- // Tailwind's lg: the panel hides itself past it, so the body scroll lock must go with it.
149
- window.matchMedia('(min-width: 64rem)').addEventListener('change', (event) => {
150
- if (event.matches) closeOpenMobileMenus(false);
153
+ // Past its breakpoint (Tailwind lg: or xl:) a header's panel hides itself, so the body scroll lock must go with it.
154
+ (Object.keys(DESKTOP_MIN_WIDTH) as DesktopBreakpoint[]).forEach((breakpoint) => {
155
+ window.matchMedia(`(min-width: ${DESKTOP_MIN_WIDTH[breakpoint]})`).addEventListener('change', (event) => {
156
+ if (event.matches) closeOpenMobileMenus(false, breakpoint);
157
+ });
151
158
  });
152
159
  }
153
160