@sarimarcus/content-sites-ui 0.79.0 → 0.80.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 +11 -0
- package/package.json +2 -2
- package/src/editorial/ArticlePage.astro +31 -5
- package/src/editorial/ArticlePrint.astro +12 -0
- package/src/editorial/FootnotePreview.astro +132 -0
- package/src/editorial/ReadingProgress.astro +10 -0
- package/src/editorial/ResumeReading.astro +114 -0
- package/src/editorial/ShareButtons.astro +35 -9
- package/src/internal/labels.ts +6 -0
- package/src/seo/ArticleMetadata.astro +5 -2
- package/src/seo/author.ts +3 -1
- package/src/styles/article-lede.css +71 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
All packages in the platform release in lockstep; entries are per release version.
|
|
4
4
|
|
|
5
|
+
## 0.80.0 (2026-11-20)
|
|
6
|
+
|
|
7
|
+
- Article head (SLA-4402): with `toArticleAuthor(..., { includeExtendedBio: true })`, an author's optional `shortBio` replaces `bio` in the byline bio card under the hero and in the About-the-author panel. In the editorial rail head, the compact byline shows the name as plain text when the bio card renders (it already links the profile); `ArticleMetadata` gains `linkName` (default `true`), so every other byline keeps its `rel="author"` link. `ShareButtons`: pointer cursor, and the copy button shows a check icon for about 2 s only after the clipboard write succeeds.
|
|
8
|
+
- Article reader features (SLA-4403), each switchable per site through `ArticlePage`'s `readingFeatures` (with `labels.openSource`, `labels.continueReading`, `labels.dismiss` overrides): `FootnotePreview` (a popover card for `[^N]` markers filled from the matching `#fn-N` source, keeping its rel handling), `ReadingProgress` (a CSS scroll-driven bar under the header; nothing in browsers without scroll timelines), `ResumeReading` (a localStorage "Continue reading" bar, 30-day expiry) and `ArticlePrint` (print layout; opens `details` before printing). Their CSS lives in `article-lede.css`, which only article pages import.
|
|
9
|
+
|
|
10
|
+
### Intended output changes
|
|
11
|
+
|
|
12
|
+
- `html:articles/**` — article pages gain the reader components and their styles; editorial heads show the short bio and a plain byline name; share buttons gain the cursor and icon change.
|
|
13
|
+
- `html:articoli/**` — the same on curiosity-engineering-it's article pages.
|
|
14
|
+
- `css:added` — the new utility classes in the compiled stylesheet.
|
|
15
|
+
|
|
5
16
|
## 0.79.0 (2026-11-20)
|
|
6
17
|
|
|
7
18
|
- Article end matter: `ArticleTopicPager` drops its "All N <topic> articles" link (the category badge above the title already links the topic) and the rule above "Next in…", and its heading grows to `text-2xl`. `ArticlePage` moves the pager and Related out of the prose measure into a content-width container, so a three-column Related gets room on desktop (card `sizes` follow `relatedProps.columns`), and the gap above Related shows only when the pager lists an article. The bottom `backLink` footer is gone (SLA-4397).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sarimarcus/content-sites-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.80.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.
|
|
54
|
+
"@sarimarcus/content-sites-core": "0.80.0"
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -33,6 +33,10 @@ import ArticleKeyFacts from './ArticleKeyFacts.astro';
|
|
|
33
33
|
import ArticleTopicPager from './ArticleTopicPager.astro';
|
|
34
34
|
import ShareButtons from './ShareButtons.astro';
|
|
35
35
|
import ArticleAuthorBio from './ArticleAuthorBio.astro';
|
|
36
|
+
import FootnotePreview from './FootnotePreview.astro';
|
|
37
|
+
import ReadingProgress from './ReadingProgress.astro';
|
|
38
|
+
import ResumeReading from './ResumeReading.astro';
|
|
39
|
+
import ArticlePrint from './ArticlePrint.astro';
|
|
36
40
|
import Interlude from './interludes/Interlude.astro';
|
|
37
41
|
import RelatedCard from './interludes/RelatedCard.astro';
|
|
38
42
|
import { DEFAULT_INTERLUDE_LABELS } from './article-page';
|
|
@@ -170,6 +174,15 @@ interface Props {
|
|
|
170
174
|
};
|
|
171
175
|
/** Optional "All articles" back-link, shown on mobile above an editorial hero (the breadcrumb covers wider screens). */
|
|
172
176
|
backLink?: { href: string; label?: string } | null;
|
|
177
|
+
/** Reader features (SLA-4403), each on unless set to `false`: footnote preview cards, print layout, reading progress bar, resume bar. */
|
|
178
|
+
readingFeatures?: {
|
|
179
|
+
footnotePreviews?: boolean;
|
|
180
|
+
print?: boolean;
|
|
181
|
+
progress?: boolean;
|
|
182
|
+
resume?: boolean;
|
|
183
|
+
/** Copy overrides; defaults come from the package labels for `locale`. */
|
|
184
|
+
labels?: { openSource?: string; continueReading?: string; dismiss?: string };
|
|
185
|
+
};
|
|
173
186
|
}
|
|
174
187
|
|
|
175
188
|
const {
|
|
@@ -214,7 +227,9 @@ const {
|
|
|
214
227
|
relatedItems = [],
|
|
215
228
|
relatedProps = {},
|
|
216
229
|
backLink = null,
|
|
230
|
+
readingFeatures = {},
|
|
217
231
|
} = Astro.props;
|
|
232
|
+
const { footnotePreviews = true, print = true, progress = true, resume = true, labels: readingLabels = {} } = readingFeatures;
|
|
218
233
|
const editorial = headVariant === 'editorial';
|
|
219
234
|
const railHead = (heroVariant === 'rail' || editorial) && !!heroImage;
|
|
220
235
|
|
|
@@ -361,7 +376,13 @@ const relatedColumns = relatedProps.columns ?? 2;
|
|
|
361
376
|
)}
|
|
362
377
|
|
|
363
378
|
<main>
|
|
364
|
-
<article
|
|
379
|
+
<article
|
|
380
|
+
data-pagefind-body
|
|
381
|
+
data-pagefind-meta="type:article"
|
|
382
|
+
data-article-print={print ? '' : undefined}
|
|
383
|
+
class={progress ? '[timeline-scope:--article-body]' : undefined}
|
|
384
|
+
>
|
|
385
|
+
{progress && <ReadingProgress />}
|
|
365
386
|
{emitAudienceFacets && article.audiences?.map((a) => (
|
|
366
387
|
<span class="sr-only" data-pagefind-filter={`audience:${a}`}>{a}</span>
|
|
367
388
|
))}
|
|
@@ -399,6 +420,7 @@ const relatedColumns = relatedProps.columns ?? 2;
|
|
|
399
420
|
eraBasePath={eraBasePath}
|
|
400
421
|
compact={editorial}
|
|
401
422
|
portrait={!(editorial && author?.bio)}
|
|
423
|
+
linkName={!(editorial && author?.bio)}
|
|
402
424
|
/><slot name="rail" /></Fragment>
|
|
403
425
|
<Fragment slot="actions">{showShareButtons && shareUrl && showShareTop && <ShareButtons url={shareUrl} title={article.title} locale={locale} slim={editorial} />}</Fragment>
|
|
404
426
|
</ContentHero>
|
|
@@ -466,7 +488,7 @@ const relatedColumns = relatedProps.columns ?? 2;
|
|
|
466
488
|
)}
|
|
467
489
|
|
|
468
490
|
{showToc && (
|
|
469
|
-
<Fragment><div class={editorial ? 'mb-10 min-[1360px]:hidden' : 'mb-10'} data-pagefind-ignore>
|
|
491
|
+
<Fragment><div class={editorial ? 'mb-10 min-[1360px]:hidden' : 'mb-10'} data-pagefind-ignore data-article-toc>
|
|
470
492
|
<TableOfContents items={tocItems} eyebrow={l.tocEyebrow} headerClass="max-md:hidden" {...tocProps} />
|
|
471
493
|
</div>{editorial && (
|
|
472
494
|
<aside class="absolute left-full top-0 bottom-0 ml-10 hidden w-52 min-[1360px]:block" data-article-toc-margin data-pagefind-ignore>
|
|
@@ -477,7 +499,7 @@ const relatedColumns = relatedProps.columns ?? 2;
|
|
|
477
499
|
)}</Fragment>
|
|
478
500
|
)}
|
|
479
501
|
|
|
480
|
-
<div class={proseClass}>
|
|
502
|
+
<div class:list={[proseClass, progress && '[view-timeline:--article-body_block]']} data-article-sections>
|
|
481
503
|
{article.sections.map((section) => {
|
|
482
504
|
const blocks = buildSectionBlocks(section);
|
|
483
505
|
const subParagraphs = (section.subsections ?? []).map((sub) => ({
|
|
@@ -525,7 +547,7 @@ const relatedColumns = relatedProps.columns ?? 2;
|
|
|
525
547
|
}
|
|
526
548
|
if (block.kind === 'affiliate-carousel' && AffiliateCarouselComponent) {
|
|
527
549
|
return (
|
|
528
|
-
<div class="not-prose my-8">
|
|
550
|
+
<div class="not-prose my-8" data-print-hide>
|
|
529
551
|
<AffiliateCarouselComponent
|
|
530
552
|
ids={block.carousel.ids}
|
|
531
553
|
heading={block.carousel.heading}
|
|
@@ -594,7 +616,7 @@ const relatedColumns = relatedProps.columns ?? 2;
|
|
|
594
616
|
</Container>
|
|
595
617
|
|
|
596
618
|
{/* End matter leaves the prose measure: three cards need the content rail on desktop. */}
|
|
597
|
-
{(topicPager || relatedItems.length > 0 || Astro.slots.has('after-related')) && <Container size="content" class="pb-10 sm:pb-14">
|
|
619
|
+
{(topicPager || relatedItems.length > 0 || Astro.slots.has('after-related')) && <Container size="content" class="pb-10 sm:pb-14 print:hidden">
|
|
598
620
|
{topicPager && (
|
|
599
621
|
<ArticleTopicPager
|
|
600
622
|
topic={topicPager.topic}
|
|
@@ -620,8 +642,12 @@ const relatedColumns = relatedProps.columns ?? 2;
|
|
|
620
642
|
|
|
621
643
|
<slot name="after-related" />
|
|
622
644
|
</Container>}
|
|
645
|
+
|
|
646
|
+
{footnotePreviews && sourcesLen > 0 && <FootnotePreview locale={locale} openSourceLabel={readingLabels.openSource} />}
|
|
647
|
+
{resume && <ResumeReading locale={locale} continueReadingLabel={readingLabels.continueReading} dismissLabel={readingLabels.dismiss} />}
|
|
623
648
|
</article>
|
|
624
649
|
</main>
|
|
650
|
+
{print && <ArticlePrint />}
|
|
625
651
|
|
|
626
652
|
<script>
|
|
627
653
|
import { openFaqTarget } from '../composed/faq-target.ts';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* ArticlePrint: opens every `details` in the article before printing (SLA-4403). The print layout itself is in
|
|
4
|
+
* article-lede.css, scoped to pages holding `[data-article-print]`.
|
|
5
|
+
*/
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<script is:inline>
|
|
9
|
+
addEventListener('beforeprint', () => {
|
|
10
|
+
document.querySelectorAll('[data-article-print] details').forEach((d) => (d.open = true));
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* FootnotePreview: one shared popover card for the article's `[^N]` markers (SLA-4403). It opens on hover or focus
|
|
4
|
+
* (pointer devices) or on tap (touch), and is filled from the matching `#fn-N` item of AuthoritativeSources, so the
|
|
5
|
+
* card's link keeps that list's rel handling and a competitor source (rendered unlinked there) gets no link (Rule 38).
|
|
6
|
+
* Without JS the marker stays a plain jump to `#fn-N`.
|
|
7
|
+
*/
|
|
8
|
+
import { getLabels } from '../internal/labels';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
locale?: string;
|
|
12
|
+
openSourceLabel?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { openSourceLabel = getLabels(Astro.props.locale).articlePage.openSourceLabel } = Astro.props;
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<div
|
|
19
|
+
popover="auto"
|
|
20
|
+
data-fn-preview
|
|
21
|
+
data-open-label={openSourceLabel}
|
|
22
|
+
class="inset-auto m-0 w-[min(20rem,calc(100vw-2rem))] rounded-lg border border-border bg-card p-4 text-sm leading-relaxed text-foreground shadow-lg"
|
|
23
|
+
>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
const CUT = 200;
|
|
28
|
+
const cut = (text: string) => {
|
|
29
|
+
const t = text.replace(/\s+/g, ' ').trim();
|
|
30
|
+
if (t.length <= CUT) return t;
|
|
31
|
+
const head = t.slice(0, CUT);
|
|
32
|
+
return `${head.slice(0, head.lastIndexOf(' ') > CUT * 0.6 ? head.lastIndexOf(' ') : CUT).replace(/[,;:.\s]+$/, '')}…`;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function initFootnotePreview() {
|
|
36
|
+
const card = document.querySelector<HTMLElement>('[data-fn-preview]');
|
|
37
|
+
if (!card || card.dataset.bound === 'true' || typeof card.showPopover !== 'function') return;
|
|
38
|
+
card.dataset.bound = 'true';
|
|
39
|
+
const hover = matchMedia('(hover: hover) and (pointer: fine)');
|
|
40
|
+
let current: HTMLAnchorElement | null = null;
|
|
41
|
+
let openTimer: ReturnType<typeof setTimeout> | undefined;
|
|
42
|
+
let closeTimer: ReturnType<typeof setTimeout> | undefined;
|
|
43
|
+
|
|
44
|
+
const fill = (item: HTMLElement) => {
|
|
45
|
+
const link = item.querySelector<HTMLAnchorElement>('a[href]');
|
|
46
|
+
const name = (link?.querySelector('span') ?? item.querySelector('div > span span') ?? item.querySelector('div > span'))?.textContent ?? '';
|
|
47
|
+
const text = item.querySelector('p')?.textContent ?? '';
|
|
48
|
+
card.replaceChildren();
|
|
49
|
+
const title = document.createElement('p');
|
|
50
|
+
title.className = 'font-semibold';
|
|
51
|
+
title.textContent = name.trim();
|
|
52
|
+
card.append(title);
|
|
53
|
+
if (text.trim()) {
|
|
54
|
+
const body = document.createElement('p');
|
|
55
|
+
body.className = 'mt-1 text-muted-foreground';
|
|
56
|
+
body.textContent = cut(text);
|
|
57
|
+
card.append(body);
|
|
58
|
+
}
|
|
59
|
+
if (link) {
|
|
60
|
+
const open = document.createElement('a');
|
|
61
|
+
open.href = link.href;
|
|
62
|
+
open.target = '_blank';
|
|
63
|
+
open.rel = link.rel;
|
|
64
|
+
open.className = 'mt-2 inline-block font-medium text-primary underline underline-offset-4';
|
|
65
|
+
open.textContent = `${card.dataset.openLabel ?? ''} ↗`;
|
|
66
|
+
card.append(open);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const place = (ref: HTMLElement) => {
|
|
71
|
+
const r = ref.getBoundingClientRect();
|
|
72
|
+
const w = card.offsetWidth;
|
|
73
|
+
const h = card.offsetHeight;
|
|
74
|
+
const left = Math.min(Math.max(8, r.left + r.width / 2 - w / 2), innerWidth - w - 8);
|
|
75
|
+
const below = r.bottom + 8;
|
|
76
|
+
const top = below + h > innerHeight - 8 && r.top - h - 8 > 8 ? r.top - h - 8 : below;
|
|
77
|
+
card.style.left = `${left}px`;
|
|
78
|
+
card.style.top = `${top}px`;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const show = (ref: HTMLAnchorElement) => {
|
|
82
|
+
const item = document.getElementById(ref.hash.slice(1));
|
|
83
|
+
if (!item) return;
|
|
84
|
+
clearTimeout(closeTimer);
|
|
85
|
+
if (current === ref && card.matches(':popover-open')) return;
|
|
86
|
+
current = ref;
|
|
87
|
+
fill(item);
|
|
88
|
+
if (!card.matches(':popover-open')) card.showPopover();
|
|
89
|
+
place(ref);
|
|
90
|
+
};
|
|
91
|
+
const hide = () => {
|
|
92
|
+
clearTimeout(openTimer);
|
|
93
|
+
closeTimer = setTimeout(() => {
|
|
94
|
+
if (card.matches(':popover-open')) card.hidePopover();
|
|
95
|
+
current = null;
|
|
96
|
+
}, 200);
|
|
97
|
+
};
|
|
98
|
+
const refOf = (e: Event) => (e.target as Element | null)?.closest?.<HTMLAnchorElement>('a.footnote-ref') ?? null;
|
|
99
|
+
|
|
100
|
+
document.addEventListener('pointerover', (e) => {
|
|
101
|
+
if (!hover.matches) return;
|
|
102
|
+
const ref = refOf(e);
|
|
103
|
+
if (ref) {
|
|
104
|
+
clearTimeout(openTimer);
|
|
105
|
+
openTimer = setTimeout(() => show(ref), 120);
|
|
106
|
+
} else if ((e.target as Element).closest('[data-fn-preview]')) clearTimeout(closeTimer);
|
|
107
|
+
});
|
|
108
|
+
document.addEventListener('pointerout', (e) => {
|
|
109
|
+
if (!hover.matches) return;
|
|
110
|
+
const from = (e.target as Element).closest('a.footnote-ref, [data-fn-preview]');
|
|
111
|
+
const to = (e.relatedTarget as Element | null)?.closest?.('a.footnote-ref, [data-fn-preview]');
|
|
112
|
+
if (from && from !== to) hide();
|
|
113
|
+
});
|
|
114
|
+
document.addEventListener('focusin', (e) => {
|
|
115
|
+
const ref = refOf(e);
|
|
116
|
+
if (ref) show(ref);
|
|
117
|
+
});
|
|
118
|
+
document.addEventListener('focusout', (e) => {
|
|
119
|
+
if (refOf(e) && !card.contains(e.relatedTarget as Node | null)) hide();
|
|
120
|
+
});
|
|
121
|
+
document.addEventListener('click', (e) => {
|
|
122
|
+
const ref = refOf(e);
|
|
123
|
+
if (!ref || hover.matches) return;
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
show(ref);
|
|
126
|
+
});
|
|
127
|
+
addEventListener('scroll', () => card.matches(':popover-open') && current && place(current), { passive: true });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
initFootnotePreview();
|
|
131
|
+
document.addEventListener('astro:page-load', initFootnotePreview);
|
|
132
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* ReadingProgress: a 3px accent bar under the fixed site header that fills as the reader scrolls through the element
|
|
4
|
+
* carrying the `--article-body` view timeline (SLA-4403). CSS only, in article-lede.css; browsers without
|
|
5
|
+
* scroll-driven animations show nothing.
|
|
6
|
+
*/
|
|
7
|
+
import { HEADER_OFFSET_TOP } from '../layout/headerOffset';
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<div data-reading-progress aria-hidden="true" class:list={['reading-progress bg-primary', HEADER_OFFSET_TOP]}></div>
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* ResumeReading: remembers the furthest article section the reader reached (localStorage, per path, 30 days) and, on a
|
|
4
|
+
* return visit to an article left after its 2nd section and before its last, offers a bottom bar
|
|
5
|
+
* "Continue reading: <heading> →" (SLA-4403). Nothing leaves the browser. Sections are the `section[id]` children of
|
|
6
|
+
* `[data-article-sections]`.
|
|
7
|
+
*/
|
|
8
|
+
import Icon from '../primitives/Icon.astro';
|
|
9
|
+
import { getLabels } from '../internal/labels';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
locale?: string;
|
|
13
|
+
continueReadingLabel?: string;
|
|
14
|
+
dismissLabel?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const l = getLabels(Astro.props.locale).articlePage;
|
|
18
|
+
const { continueReadingLabel = l.continueReadingLabel, dismissLabel = l.dismissLabel } = Astro.props;
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
<div
|
|
22
|
+
data-resume-reading
|
|
23
|
+
hidden
|
|
24
|
+
class="fixed inset-x-0 bottom-0 z-40 border-t border-border bg-card/95 pb-[env(safe-area-inset-bottom)] shadow-lg backdrop-blur"
|
|
25
|
+
>
|
|
26
|
+
<div class="mx-auto flex max-w-measure items-center gap-2 px-4">
|
|
27
|
+
<a data-resume-link href="#" class="flex min-h-12 min-w-0 flex-1 items-center gap-1.5 text-sm hover:text-primary">
|
|
28
|
+
<span class="shrink-0 text-muted-foreground">{continueReadingLabel}</span>
|
|
29
|
+
<span data-resume-heading class="truncate font-medium text-foreground"></span>
|
|
30
|
+
<Icon name="arrow-right" class="h-4 w-4 shrink-0 text-primary" />
|
|
31
|
+
</a>
|
|
32
|
+
<button
|
|
33
|
+
type="button"
|
|
34
|
+
data-resume-close
|
|
35
|
+
aria-label={dismissLabel}
|
|
36
|
+
title={dismissLabel}
|
|
37
|
+
class="inline-flex min-h-11 min-w-11 cursor-pointer items-center justify-center rounded-full text-muted-foreground hover:text-primary"
|
|
38
|
+
>
|
|
39
|
+
<Icon name="x" class="h-4 w-4" />
|
|
40
|
+
</button>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
const TTL = 30 * 24 * 60 * 60 * 1000;
|
|
46
|
+
|
|
47
|
+
function initResumeReading() {
|
|
48
|
+
const bar = document.querySelector<HTMLElement>('[data-resume-reading]');
|
|
49
|
+
if (!bar || bar.dataset.bound === 'true') return;
|
|
50
|
+
bar.dataset.bound = 'true';
|
|
51
|
+
const sections = [...document.querySelectorAll<HTMLElement>('[data-article-sections] > section[id]')];
|
|
52
|
+
if (sections.length < 3) return;
|
|
53
|
+
const key = `csf:resume:${location.pathname}`;
|
|
54
|
+
type Saved = { id: string; t: number };
|
|
55
|
+
const read = (): Saved | null => {
|
|
56
|
+
try {
|
|
57
|
+
return JSON.parse(localStorage.getItem(key) ?? 'null');
|
|
58
|
+
} catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const write = (value: Saved | null) => {
|
|
63
|
+
try {
|
|
64
|
+
if (value) localStorage.setItem(key, JSON.stringify(value));
|
|
65
|
+
else localStorage.removeItem(key);
|
|
66
|
+
} catch {}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const stored = read();
|
|
70
|
+
const saved = stored && Date.now() - stored.t <= TTL ? stored : null;
|
|
71
|
+
if (stored && !saved) write(null);
|
|
72
|
+
const savedIndex = saved ? sections.findIndex((s) => s.id === saved.id) : -1;
|
|
73
|
+
if (saved && savedIndex >= 2 && savedIndex < sections.length - 1 && !location.hash && scrollY < 200) {
|
|
74
|
+
const target = sections[savedIndex];
|
|
75
|
+
const link = bar.querySelector<HTMLAnchorElement>('[data-resume-link]')!;
|
|
76
|
+
bar.querySelector('[data-resume-heading]')!.textContent = target.querySelector('h2')?.textContent?.trim() ?? '';
|
|
77
|
+
link.href = `#${target.id}`;
|
|
78
|
+
bar.hidden = false;
|
|
79
|
+
const startY = scrollY;
|
|
80
|
+
const close = () => {
|
|
81
|
+
bar.hidden = true;
|
|
82
|
+
removeEventListener('scroll', onScrollAway);
|
|
83
|
+
};
|
|
84
|
+
const onScrollAway = () => Math.abs(scrollY - startY) > 80 && close();
|
|
85
|
+
link.addEventListener('click', close);
|
|
86
|
+
bar.querySelector('[data-resume-close]')!.addEventListener('click', close);
|
|
87
|
+
addEventListener('scroll', onScrollAway, { passive: true });
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
let best = Math.max(savedIndex, 0);
|
|
91
|
+
let queued = false;
|
|
92
|
+
const track = () => {
|
|
93
|
+
queued = false;
|
|
94
|
+
const line = innerHeight * 0.4;
|
|
95
|
+
let i = -1;
|
|
96
|
+
for (const [n, s] of sections.entries()) if (s.getBoundingClientRect().top < line) i = n;
|
|
97
|
+
const end = sections[sections.length - 1].getBoundingClientRect().bottom < innerHeight;
|
|
98
|
+
if (end) write(null);
|
|
99
|
+
else if (i > best) {
|
|
100
|
+
best = i;
|
|
101
|
+
write({ id: sections[i].id, t: Date.now() });
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
addEventListener('scroll', () => {
|
|
105
|
+
if (!queued) {
|
|
106
|
+
queued = true;
|
|
107
|
+
requestAnimationFrame(track);
|
|
108
|
+
}
|
|
109
|
+
}, { passive: true });
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
initResumeReading();
|
|
113
|
+
document.addEventListener('astro:page-load', initResumeReading);
|
|
114
|
+
</script>
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Includes WhatsApp, Flipboard, X, LinkedIn, Native Share (`navigator.share` on supported devices),
|
|
5
5
|
* and Copy Link with inline "Copied" confirmation via `aria-live="polite"`.
|
|
6
6
|
*/
|
|
7
|
+
import Icon from '../primitives/Icon.astro';
|
|
7
8
|
import { getLabels } from '../internal/labels';
|
|
8
9
|
import { buildShareUrls } from './share';
|
|
9
10
|
|
|
@@ -135,7 +136,7 @@ const btnClass = slim
|
|
|
135
136
|
hidden
|
|
136
137
|
aria-label={resolvedNativeShareLabel}
|
|
137
138
|
title={resolvedNativeShareLabel}
|
|
138
|
-
class={btnClass}
|
|
139
|
+
class:list={[btnClass, 'cursor-pointer']}
|
|
139
140
|
>
|
|
140
141
|
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
141
142
|
<circle cx="18" cy="5" r="3" />
|
|
@@ -153,12 +154,16 @@ const btnClass = slim
|
|
|
153
154
|
data-copied-label={resolvedCopiedLabel}
|
|
154
155
|
aria-label={resolvedCopyLabel}
|
|
155
156
|
title={resolvedCopyLabel}
|
|
156
|
-
class={
|
|
157
|
+
class:list={[
|
|
158
|
+
slim ? btnClass : 'inline-flex items-center gap-1.5 px-3.5 min-h-[44px] h-11 rounded-full border border-border bg-card text-xs font-medium text-muted-foreground hover:text-primary hover:border-primary/40 transition-colors',
|
|
159
|
+
'group/copy cursor-pointer data-[copied]:text-primary data-[copied]:border-primary',
|
|
160
|
+
]}
|
|
157
161
|
>
|
|
158
|
-
<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
162
|
+
<svg class="w-3.5 h-3.5 group-data-[copied]/copy:hidden" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
159
163
|
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" />
|
|
160
164
|
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />
|
|
161
165
|
</svg>
|
|
166
|
+
<Icon name="check" class="w-3.5 h-3.5 hidden group-data-[copied]/copy:block" strokeWidth={2.5} />
|
|
162
167
|
<span data-copy-text aria-live="polite" class:list={[slim && 'sr-only']}>{resolvedCopyLabel}</span>
|
|
163
168
|
</button>
|
|
164
169
|
</div>
|
|
@@ -185,14 +190,35 @@ const btnClass = slim
|
|
|
185
190
|
if (copyBtn && copyText) {
|
|
186
191
|
const defaultLabel = copyBtn.dataset.copyLabel || '';
|
|
187
192
|
const copiedLabel = copyBtn.dataset.copiedLabel || '';
|
|
188
|
-
|
|
193
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
194
|
+
const copy = async (): Promise<boolean> => {
|
|
189
195
|
try {
|
|
190
196
|
await navigator.clipboard.writeText(url);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
197
|
+
return true;
|
|
198
|
+
} catch {
|
|
199
|
+
const ta = document.createElement('textarea');
|
|
200
|
+
ta.value = url;
|
|
201
|
+
ta.setAttribute('readonly', '');
|
|
202
|
+
ta.style.cssText = 'position:fixed;opacity:0';
|
|
203
|
+
document.body.appendChild(ta);
|
|
204
|
+
ta.select();
|
|
205
|
+
let ok = false;
|
|
206
|
+
try {
|
|
207
|
+
ok = document.execCommand('copy');
|
|
208
|
+
} catch {}
|
|
209
|
+
ta.remove();
|
|
210
|
+
return ok;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
copyBtn.addEventListener('click', async () => {
|
|
214
|
+
if (!(await copy())) return;
|
|
215
|
+
copyText.textContent = copiedLabel;
|
|
216
|
+
copyBtn.dataset.copied = '';
|
|
217
|
+
clearTimeout(timer);
|
|
218
|
+
timer = setTimeout(() => {
|
|
219
|
+
copyText.textContent = defaultLabel;
|
|
220
|
+
delete copyBtn.dataset.copied;
|
|
221
|
+
}, 2000);
|
|
196
222
|
});
|
|
197
223
|
}
|
|
198
224
|
});
|
package/src/internal/labels.ts
CHANGED
|
@@ -174,6 +174,9 @@ export const LABELS = {
|
|
|
174
174
|
allArticlesLabel: 'All articles',
|
|
175
175
|
relatedTitle: 'Related reading',
|
|
176
176
|
tocEyebrow: 'In this article',
|
|
177
|
+
openSourceLabel: 'Open source',
|
|
178
|
+
continueReadingLabel: 'Continue reading:',
|
|
179
|
+
dismissLabel: 'Dismiss',
|
|
177
180
|
},
|
|
178
181
|
authoritativeSources: {
|
|
179
182
|
title: 'Sources',
|
|
@@ -434,6 +437,9 @@ export const LABELS_IT: typeof LABELS = {
|
|
|
434
437
|
allArticlesLabel: 'Tutti gli articoli',
|
|
435
438
|
relatedTitle: 'Letture correlate',
|
|
436
439
|
tocEyebrow: 'In questo articolo',
|
|
440
|
+
openSourceLabel: 'Apri la fonte',
|
|
441
|
+
continueReadingLabel: 'Riprendi la lettura:',
|
|
442
|
+
dismissLabel: 'Chiudi',
|
|
437
443
|
},
|
|
438
444
|
authoritativeSources: {
|
|
439
445
|
title: 'Fonti',
|
|
@@ -52,6 +52,8 @@ interface Props {
|
|
|
52
52
|
compact?: boolean;
|
|
53
53
|
/** With `compact`: show the small portrait (default). A page that shows it in the bio passes false. */
|
|
54
54
|
portrait?: boolean;
|
|
55
|
+
/** Link the name to `author.href` with rel="author" (default). A page whose bio card already links the profile passes false. */
|
|
56
|
+
linkName?: boolean;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
const defaultLabels = getLabels(Astro.props.locale ?? Astro.currentLocale);
|
|
@@ -75,6 +77,7 @@ const {
|
|
|
75
77
|
eraBasePath,
|
|
76
78
|
compact = false,
|
|
77
79
|
portrait = true,
|
|
80
|
+
linkName = true,
|
|
78
81
|
} = Astro.props;
|
|
79
82
|
const { era: _era, eraBasePath: _eraBasePath, ...bylineProps } = Astro.props;
|
|
80
83
|
|
|
@@ -120,7 +123,7 @@ const bylineLead = author ? (grouped ? ' ' : ' ') : (grouped ? '' : ' ');
|
|
|
120
123
|
))}
|
|
121
124
|
<div class="min-w-0 text-sm leading-snug">
|
|
122
125
|
{author && <span class="text-muted-foreground">{writtenByLabel} </span>}
|
|
123
|
-
{author && (author.href ? (
|
|
126
|
+
{author && (author.href && linkName ? (
|
|
124
127
|
<a href={author.href} rel="author" class="font-semibold text-foreground hover:text-primary hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary">{name}</a>
|
|
125
128
|
) : (
|
|
126
129
|
<span class="font-semibold text-foreground">{name}</span>
|
|
@@ -163,7 +166,7 @@ const bylineLead = author ? (grouped ? ' ' : ' ') : (grouped ? '' : ' ');
|
|
|
163
166
|
|
|
164
167
|
{/* name, credentials, dates */}
|
|
165
168
|
<div class="min-w-0">{bylineLead}{author && <div class="text-xs text-muted-foreground mb-0.5">{writtenByLabel}</div>}
|
|
166
|
-
{author && (author.href ? (
|
|
169
|
+
{author && (author.href && linkName ? (
|
|
167
170
|
<a href={author.href} rel="author" class="font-semibold text-foreground hover:text-primary transition-colors hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary">
|
|
168
171
|
{name}
|
|
169
172
|
</a>
|
package/src/seo/author.ts
CHANGED
|
@@ -10,6 +10,8 @@ export interface ArticleAuthorProfile {
|
|
|
10
10
|
jobTitle?: string;
|
|
11
11
|
role?: string;
|
|
12
12
|
bio?: string;
|
|
13
|
+
/** One or two sentences; with `includeExtendedBio` it replaces `bio` in every byline bio (hero card and About-the-author panel). */
|
|
14
|
+
shortBio?: string;
|
|
13
15
|
expertise?: readonly string[];
|
|
14
16
|
}
|
|
15
17
|
|
|
@@ -47,7 +49,7 @@ export function toArticleAuthor(
|
|
|
47
49
|
...(includeExtendedBio && profile
|
|
48
50
|
? {
|
|
49
51
|
jobTitle: profile.jobTitle ?? profile.role ?? null,
|
|
50
|
-
bio: profile.bio ?? null,
|
|
52
|
+
bio: profile.shortBio ?? profile.bio ?? null,
|
|
51
53
|
expertise: profile.expertise ?? null,
|
|
52
54
|
}
|
|
53
55
|
: {}),
|
|
@@ -23,3 +23,74 @@
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
/* Article reader features (SLA-4403). Lives here, not in component <style> blocks, because every article page
|
|
28
|
+
imports this file and nothing else does: a component style would ride the editorial barrel onto every page. */
|
|
29
|
+
.reading-progress {
|
|
30
|
+
display: none;
|
|
31
|
+
}
|
|
32
|
+
@supports (animation-timeline: view()) and (timeline-scope: --article-body) {
|
|
33
|
+
.reading-progress {
|
|
34
|
+
display: block;
|
|
35
|
+
position: fixed;
|
|
36
|
+
inset-inline: 0;
|
|
37
|
+
height: 3px;
|
|
38
|
+
z-index: 40;
|
|
39
|
+
pointer-events: none;
|
|
40
|
+
transform-origin: 0 50%;
|
|
41
|
+
transform: scaleX(0);
|
|
42
|
+
animation: reading-progress-fill linear both;
|
|
43
|
+
animation-timeline: --article-body;
|
|
44
|
+
animation-range: contain 0% contain 100%;
|
|
45
|
+
}
|
|
46
|
+
@keyframes reading-progress-fill {
|
|
47
|
+
to {
|
|
48
|
+
transform: scaleX(1);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@media print {
|
|
54
|
+
:root:has([data-article-print]) body {
|
|
55
|
+
background: #fff;
|
|
56
|
+
color: #000;
|
|
57
|
+
}
|
|
58
|
+
:root:has([data-article-print]) :is(header, nav, footer):not([data-article-print] *),
|
|
59
|
+
:root:has([data-article-print])
|
|
60
|
+
:is(
|
|
61
|
+
[data-share-group],
|
|
62
|
+
[data-author-bio],
|
|
63
|
+
[data-article-toc],
|
|
64
|
+
[data-article-toc-margin],
|
|
65
|
+
[data-affiliate-widget],
|
|
66
|
+
[data-reading-progress],
|
|
67
|
+
[data-resume-reading],
|
|
68
|
+
[data-fn-preview],
|
|
69
|
+
[data-article-back],
|
|
70
|
+
[data-print-hide],
|
|
71
|
+
.fixed,
|
|
72
|
+
iframe
|
|
73
|
+
) {
|
|
74
|
+
display: none !important;
|
|
75
|
+
}
|
|
76
|
+
:root:has([data-article-print]) .sticky {
|
|
77
|
+
position: static !important;
|
|
78
|
+
}
|
|
79
|
+
[data-article-print] [data-hero] img {
|
|
80
|
+
max-height: 8cm;
|
|
81
|
+
width: auto;
|
|
82
|
+
max-width: 100%;
|
|
83
|
+
object-fit: cover;
|
|
84
|
+
}
|
|
85
|
+
[data-article-print] :is(h2, h3) {
|
|
86
|
+
break-after: avoid-page;
|
|
87
|
+
}
|
|
88
|
+
[data-article-print] :is(figure, img, li) {
|
|
89
|
+
break-inside: avoid-page;
|
|
90
|
+
}
|
|
91
|
+
[data-article-print] a[href^='http']::after {
|
|
92
|
+
content: ' (' attr(href) ')';
|
|
93
|
+
font-size: 0.8em;
|
|
94
|
+
word-break: break-all;
|
|
95
|
+
}
|
|
96
|
+
}
|