@sarimarcus/content-sites-ui 0.61.0 → 0.62.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,13 @@
2
2
 
3
3
  All packages in the platform release in lockstep; entries are per release version.
4
4
 
5
+ ## 0.62.0 (2026-11-08)
6
+
7
+ Additive (SLA-3977); output of existing pages is unchanged except three new utility classes in the CSS bundle.
8
+
9
+ - `ArticlePage`: renders `sections[].embeds[]` through the new `ArticleEmbed`, a click-to-load facade (thumbnail from `i.ytimg.com`, a `youtube-nocookie.com` iframe only after the click). Sites need `https://www.youtube-nocookie.com` in `frame-src`; all five already have it.
10
+ - Labels: `articleEmbed.playLabel` and `privacyNote` (en, it).
11
+
5
12
  ## 0.61.0 (2026-11-08)
6
13
 
7
14
  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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarimarcus/content-sites-ui",
3
- "version": "0.61.0",
3
+ "version": "0.62.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.61.0"
54
+ "@sarimarcus/content-sites-core": "0.62.0"
55
55
  }
56
56
  }
@@ -0,0 +1,70 @@
1
+ ---
2
+ /**
3
+ * ArticleEmbed — a YouTube video placed between article paragraphs (SLA-3977). Renders a click-to-load facade: a
4
+ * thumbnail link that costs no iframe, no cookie and no layout shift until the reader plays it, then swaps in a
5
+ * youtube-nocookie.com iframe. Without JS the facade is a plain link to the video.
6
+ */
7
+ import type { TrustedHtml } from '../types/index.ts';
8
+ import Icon from '../primitives/Icon.astro';
9
+ import { getLabels } from '../internal/labels';
10
+
11
+ interface Props {
12
+ /** The 11-character YouTube video id. */
13
+ id: string;
14
+ /** Names the video: the iframe title and the facade's accessible label. */
15
+ title: string;
16
+ /** Caption below the video, already rendered by the site (inline HTML, it sits inside a <p>). */
17
+ captionHtml?: TrustedHtml;
18
+ locale?: string;
19
+ class?: string;
20
+ }
21
+
22
+ const { id, title, captionHtml, locale, class: className } = Astro.props;
23
+ const l = getLabels(locale ?? Astro.currentLocale).articleEmbed;
24
+ const watchUrl = `https://www.youtube.com/watch?v=${id}`;
25
+ const thumbUrl = `https://i.ytimg.com/vi/${id}/hqdefault.jpg`;
26
+ ---
27
+
28
+ <figure data-article-embed data-embed-id={id} data-embed-title={title} class:list={['not-prose my-8 overflow-hidden rounded-2xl border border-border/50', className]}>
29
+ <div class="relative aspect-video bg-black">
30
+ <a
31
+ href={watchUrl}
32
+ data-article-embed-play
33
+ aria-label={`${l.playLabel}: ${title}`}
34
+ class="group absolute inset-0 block focus:outline-none focus-visible:ring-2 focus-visible:ring-primary"
35
+ >
36
+ <img src={thumbUrl} alt="" width="480" height="360" loading="lazy" decoding="async" class="absolute inset-0 h-full w-full object-cover" />
37
+ <span class="absolute inset-0 flex items-center justify-center">
38
+ <span class="flex h-16 w-16 items-center justify-center rounded-full bg-black/70 text-white motion-safe:transition-transform motion-safe:group-hover:scale-110">
39
+ <Icon name="play" class="h-7 w-7" filled />
40
+ </span>
41
+ </span>
42
+ <span class="absolute inset-x-0 bottom-0 bg-black/70 px-4 py-2 text-xs text-white">{l.privacyNote}</span>
43
+ </a>
44
+ </div>
45
+ {captionHtml && (
46
+ <figcaption class="bg-muted/30 px-4 py-3">
47
+ <p class="font-display text-sm font-medium text-foreground/80" set:html={captionHtml} />
48
+ </figcaption>
49
+ )}
50
+ </figure>
51
+
52
+ <script>
53
+ document.addEventListener('click', (event) => {
54
+ const link = (event.target as Element | null)?.closest<HTMLAnchorElement>('[data-article-embed-play]');
55
+ if (!link || event.metaKey || event.ctrlKey || event.shiftKey) return;
56
+ const figure = link.closest<HTMLElement>('[data-article-embed]');
57
+ const id = figure?.dataset.embedId;
58
+ if (!figure || !id) return;
59
+ event.preventDefault();
60
+ const iframe = document.createElement('iframe');
61
+ iframe.src = `https://www.youtube-nocookie.com/embed/${id}?autoplay=1&rel=0&playsinline=1`;
62
+ iframe.title = figure.dataset.embedTitle ?? '';
63
+ iframe.allow = 'autoplay; encrypted-media; picture-in-picture; fullscreen';
64
+ iframe.allowFullscreen = true;
65
+ iframe.referrerPolicy = 'strict-origin-when-cross-origin';
66
+ iframe.className = 'absolute inset-0 h-full w-full border-0';
67
+ link.replaceWith(iframe);
68
+ iframe.focus();
69
+ });
70
+ </script>
@@ -8,6 +8,7 @@
8
8
  import type { ImageMetadata } from 'astro';
9
9
  import type { EraDefinition } from '@sarimarcus/content-sites-core/eras';
10
10
  import { splitParagraphs, renderInlineMarkdown } from '@sarimarcus/content-sites-core/articles';
11
+ import type { ArticleEmbedProvider } from '@sarimarcus/content-sites-core/articles';
11
12
  import { slugify, parseMarkdownInline } from '@sarimarcus/content-sites-core/text';
12
13
  import { routePath, type SiteRoutes } from '@sarimarcus/content-sites-core/url';
13
14
  import Container from '../layout/Container.astro';
@@ -18,6 +19,7 @@ import ArticleMetadata from '../seo/ArticleMetadata.astro';
18
19
  import AuthoritativeSources from '../seo/AuthoritativeSources.astro';
19
20
  import type { ArticleAuthor, BreadcrumbItem, DomainClassifier, SourceInput } from '../seo/types';
20
21
  import TableOfContents from '../composed/TableOfContents.astro';
22
+ import ArticleEmbed from './ArticleEmbed.astro';
21
23
  import FAQ from '../composed/FAQ.astro';
22
24
  import { faqAnchorIds } from '../composed/faq-anchors';
23
25
  import InlineImage from '../composed/InlineImage.astro';
@@ -61,6 +63,7 @@ export interface ArticlePageSection {
61
63
  interludes?: readonly any[];
62
64
  inlineImages?: readonly { slug: string; alt: string; caption?: string; afterParagraph: number }[];
63
65
  affiliateCarousels?: readonly { ids?: number[]; afterParagraph: number; heading?: string }[];
66
+ embeds?: readonly { provider: ArticleEmbedProvider; id: string; title: string; caption?: string; afterParagraph: number }[];
64
67
  }
65
68
 
66
69
  export interface ArticlePageData {
@@ -256,7 +259,8 @@ type BodyBlock =
256
259
  | { kind: 'interlude'; data: InterludeData }
257
260
  | { kind: 'entity'; card: ArticlePageResolvedCard }
258
261
  | { kind: 'image'; image: { slug: string; alt: string; caption?: string; afterParagraph: number }; meta: ImageMetadata }
259
- | { kind: 'affiliate-carousel'; carousel: { ids?: number[]; afterParagraph: number; heading?: string } };
262
+ | { kind: 'affiliate-carousel'; carousel: { ids?: number[]; afterParagraph: number; heading?: string } }
263
+ | { kind: 'embed'; embed: { id: string; title: string; caption?: string; afterParagraph: number } };
260
264
 
261
265
  function buildSectionBlocks(section: ArticlePageSection): BodyBlock[] {
262
266
  const paragraphs = splitParagraphs(section.body, basePath, sourcesLen);
@@ -264,6 +268,7 @@ function buildSectionBlocks(section: ArticlePageSection): BodyBlock[] {
264
268
  const interludes = section.interludes ?? [];
265
269
  const images = section.inlineImages ?? [];
266
270
  const carousels = section.affiliateCarousels ?? [];
271
+ const embeds = section.embeds ?? [];
267
272
 
268
273
  const pushInterlude = (il: any) => {
269
274
  if (il.type === 'related-card' || il.type === 'monument-feature' || il.type === 'article-feature') {
@@ -295,6 +300,10 @@ function buildSectionBlocks(section: ArticlePageSection): BodyBlock[] {
295
300
  blocks.push({ kind: 'affiliate-carousel', carousel: c });
296
301
  }
297
302
  }
303
+
304
+ for (const e of embeds) {
305
+ if (e.afterParagraph === idx) blocks.push({ kind: 'embed', embed: e });
306
+ }
298
307
  });
299
308
 
300
309
  for (const il of interludes) {
@@ -316,6 +325,10 @@ function buildSectionBlocks(section: ArticlePageSection): BodyBlock[] {
316
325
  }
317
326
  }
318
327
 
328
+ for (const e of embeds) {
329
+ if (e.afterParagraph >= paragraphs.length) blocks.push({ kind: 'embed', embed: e });
330
+ }
331
+
319
332
  for (const il of interludes) {
320
333
  if (il.type === 'tldr' || ('position' in il && il.position === 'end')) {
321
334
  pushInterlude(il);
@@ -519,6 +532,16 @@ const resolvedRelatedTitle = relatedProps.title ?? l.relatedTitle;
519
532
  </div>
520
533
  );
521
534
  }
535
+ if (block.kind === 'embed') {
536
+ return (
537
+ <ArticleEmbed
538
+ id={block.embed.id}
539
+ title={block.embed.title}
540
+ captionHtml={block.embed.caption ? md(block.embed.caption) : undefined}
541
+ locale={locale}
542
+ />
543
+ );
544
+ }
522
545
  return null;
523
546
  })}
524
547
 
@@ -84,6 +84,7 @@ export const LABELS = {
84
84
  alsoExplore: { eyebrow: 'Also explore' },
85
85
  articleCategoryNav: { ariaLabel: 'Browse articles by topic', allLabel: 'All' },
86
86
  articleFeatureCard: { readLabel: 'Read article', updatedLabel: 'Updated' },
87
+ articleEmbed: { playLabel: 'Play video', privacyNote: 'Loads YouTube when you play' },
87
88
  articleCardGrid: { readLabel: 'Read', updatedLabel: 'Updated', minutesSuffix: 'min' },
88
89
  articleHubSection: { moreLabel: 'See all' },
89
90
  articleTagPage: {
@@ -343,6 +344,7 @@ export const LABELS_IT: typeof LABELS = {
343
344
  alsoExplore: { eyebrow: 'Esplora anche' },
344
345
  articleCategoryNav: { ariaLabel: 'Sfoglia gli articoli per argomento', allLabel: 'Tutti' },
345
346
  articleFeatureCard: { readLabel: 'Leggi l’articolo', updatedLabel: 'Aggiornato' },
347
+ articleEmbed: { playLabel: 'Riproduci il video', privacyNote: 'Carica YouTube quando lo riproduci' },
346
348
  articleCardGrid: { readLabel: 'Leggi', updatedLabel: 'Aggiornato', minutesSuffix: 'min' },
347
349
  articleHubSection: { moreLabel: 'Vedi tutti' },
348
350
  articleTagPage: {