@sarimarcus/content-sites-ui 0.55.2 → 0.56.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 +10 -0
- package/package.json +2 -2
- package/src/editorial/ArticleCard.astro +11 -1
- package/src/editorial/ArticleCardGrid.astro +99 -0
- package/src/editorial/ArticleGrid.astro +4 -3
- package/src/editorial/ArticleHubSection.astro +56 -4
- package/src/editorial/ArticlePage.astro +506 -0
- package/src/editorial/ArticleTagPage.astro +88 -0
- package/src/editorial/EditorialHomePage.astro +256 -0
- package/src/editorial/EraListingPage.astro +9 -1
- package/src/editorial/EraListingRoute.astro +4 -0
- package/src/editorial/ShareButtons.astro +198 -0
- package/src/editorial/article-page.ts +19 -0
- package/src/editorial/author-page.ts +27 -0
- package/src/editorial/index.ts +20 -0
- package/src/editorial/interludes/RelatedCard.astro +31 -1
- package/src/editorial/share.ts +24 -0
- package/src/editorial/types.ts +4 -0
- package/src/internal/labels.ts +84 -2
- package/src/navigation/SiteHeader.astro +28 -1
- package/src/navigation/index.ts +1 -0
- package/src/seo/ArticleMetadata.astro +36 -1
- package/src/seo/author.ts +24 -1
- package/src/seo/index.ts +1 -1
- package/src/seo/types.ts +3 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* EditorialHomePage — Editorial magazine homepage template for articles-only sites (SLA-3722).
|
|
4
|
+
* Structure:
|
|
5
|
+
* 1. Magazine Hero / Featured Lead (`ArticleFeatureCard`, eager/LCP)
|
|
6
|
+
* 2. Trending / In-Focus Strip (`shelf` from `selectFeaturedArticles`, when non-empty)
|
|
7
|
+
* 3. Latest Grid (`ArticleCardGrid`, excluding Featured)
|
|
8
|
+
* 4. Topic Rails (`ArticleHubSection` with Xataka-style `subTags` quick-filter pills, for categories with >= 3 articles)
|
|
9
|
+
* 5. Author Strip (`AuthorStrip`, adapts to 1 or N authors)
|
|
10
|
+
* 6. Graceful 0-article empty state when no articles exist yet.
|
|
11
|
+
*/
|
|
12
|
+
import type { ImageMetadata } from 'astro';
|
|
13
|
+
import { formatDisplayDay, buildNow } from '@sarimarcus/content-sites-core/dates';
|
|
14
|
+
import {
|
|
15
|
+
isUpdatedAfterPublication,
|
|
16
|
+
selectFeaturedArticles,
|
|
17
|
+
sortArticles,
|
|
18
|
+
topCategoryTags,
|
|
19
|
+
type ArticleTagMeta,
|
|
20
|
+
type FeaturedSnapshot,
|
|
21
|
+
} from '@sarimarcus/content-sites-core/articles';
|
|
22
|
+
import { readingTime } from '@sarimarcus/content-sites-core/text';
|
|
23
|
+
import { routePath, type SiteRoutes } from '@sarimarcus/content-sites-core/url';
|
|
24
|
+
import Container from '../layout/Container.astro';
|
|
25
|
+
import { getLabels } from '../internal/labels';
|
|
26
|
+
import ArticleCardGrid, { type ArticleCardGridEntry } from './ArticleCardGrid.astro';
|
|
27
|
+
import ArticleFeatureCard from './ArticleFeatureCard.astro';
|
|
28
|
+
import ArticleHubSection from './ArticleHubSection.astro';
|
|
29
|
+
import AuthorStrip from './AuthorStrip.astro';
|
|
30
|
+
import { authorPhotoDataUri } from './author-page';
|
|
31
|
+
|
|
32
|
+
export interface EditorialHomeAuthor {
|
|
33
|
+
name: string;
|
|
34
|
+
slug: string;
|
|
35
|
+
role?: string;
|
|
36
|
+
jobTitle?: string;
|
|
37
|
+
credentials?: string;
|
|
38
|
+
photo?: string;
|
|
39
|
+
image?: ImageMetadata;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface Props {
|
|
43
|
+
brand: string;
|
|
44
|
+
tagline: string;
|
|
45
|
+
description: string;
|
|
46
|
+
articles: readonly (ArticleCardGridEntry & { data: { author?: string } })[];
|
|
47
|
+
articleImages: Readonly<Record<string, ImageMetadata>>;
|
|
48
|
+
categoryMap: Readonly<Record<string, string>>;
|
|
49
|
+
tagMap?: Readonly<Record<string, ArticleTagMeta>>;
|
|
50
|
+
authors?: readonly EditorialHomeAuthor[];
|
|
51
|
+
featuredSnapshot?: FeaturedSnapshot | null;
|
|
52
|
+
url: (path: string) => string;
|
|
53
|
+
routes?: SiteRoutes;
|
|
54
|
+
locale?: string;
|
|
55
|
+
timeZone?: string;
|
|
56
|
+
latestLimit?: number;
|
|
57
|
+
topicRailMinArticles?: number;
|
|
58
|
+
topicRailLimit?: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const {
|
|
62
|
+
brand,
|
|
63
|
+
tagline,
|
|
64
|
+
description,
|
|
65
|
+
articles,
|
|
66
|
+
articleImages,
|
|
67
|
+
categoryMap,
|
|
68
|
+
tagMap = {},
|
|
69
|
+
authors = [],
|
|
70
|
+
featuredSnapshot = null,
|
|
71
|
+
url,
|
|
72
|
+
routes = {},
|
|
73
|
+
locale = 'en-US',
|
|
74
|
+
timeZone = 'Europe/Madrid',
|
|
75
|
+
latestLimit = 6,
|
|
76
|
+
topicRailMinArticles = 3,
|
|
77
|
+
topicRailLimit = 4,
|
|
78
|
+
} = Astro.props;
|
|
79
|
+
|
|
80
|
+
const l = getLabels(locale).editorialHomePage;
|
|
81
|
+
const sorted = sortArticles(articles);
|
|
82
|
+
const { hero: lead, shelf } = selectFeaturedArticles(sorted, featuredSnapshot, {
|
|
83
|
+
slugOf: (a) => a.data.slug,
|
|
84
|
+
now: buildNow(),
|
|
85
|
+
});
|
|
86
|
+
const latestArticles = sorted
|
|
87
|
+
.filter((a) => a.data.slug !== lead?.data.slug)
|
|
88
|
+
.slice(0, latestLimit);
|
|
89
|
+
|
|
90
|
+
const tagLabels: Record<string, string> = Object.fromEntries(
|
|
91
|
+
Object.entries(tagMap).map(([k, v]) => [k, v.label]),
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const topicRails = Object.entries(categoryMap)
|
|
95
|
+
.map(([category, label]) => {
|
|
96
|
+
const inCategory = sorted.filter((a) => a.data.category === category);
|
|
97
|
+
const subTags = topCategoryTags(sorted, category, tagMap, 4, routes).map((t) => ({
|
|
98
|
+
label: `#${t.label}`,
|
|
99
|
+
href: url(t.href),
|
|
100
|
+
}));
|
|
101
|
+
return {
|
|
102
|
+
category,
|
|
103
|
+
label,
|
|
104
|
+
count: inCategory.length,
|
|
105
|
+
articles: inCategory.slice(0, topicRailLimit),
|
|
106
|
+
moreHref: url(routePath('articleTopic', category, routes)),
|
|
107
|
+
subTags,
|
|
108
|
+
};
|
|
109
|
+
})
|
|
110
|
+
.filter((rail) => rail.count >= topicRailMinArticles);
|
|
111
|
+
|
|
112
|
+
const stripAuthors = authors.map((a) => ({
|
|
113
|
+
name: a.name,
|
|
114
|
+
displayName: a.name,
|
|
115
|
+
specialty: a.jobTitle ?? a.role ?? a.credentials ?? '',
|
|
116
|
+
href: url(routePath('author', a.slug, routes)),
|
|
117
|
+
image: a.image ?? (a.photo ? url(a.photo) : authorPhotoDataUri(a.name)),
|
|
118
|
+
}));
|
|
119
|
+
|
|
120
|
+
const leadUpdated = lead ? isUpdatedAfterPublication(lead.data) : false;
|
|
121
|
+
const leadDisplayIso = lead ? (leadUpdated ? lead.data.dateModified! : (lead.data.datePublished ?? '')) : '';
|
|
122
|
+
const leadDisplayDate = lead ? formatDisplayDay(leadDisplayIso, locale, timeZone) : '';
|
|
123
|
+
const leadReadMins = lead?.data.sections ? readingTime({ sections: lead.data.sections }) : 1;
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
<main class="pt-20 md:pt-28 pb-16">
|
|
127
|
+
<header class="border-b border-border/80 pb-10 mb-12">
|
|
128
|
+
<Container>
|
|
129
|
+
<p class="text-xs font-semibold uppercase tracking-[0.2em] text-primary mb-3">
|
|
130
|
+
{brand}
|
|
131
|
+
</p>
|
|
132
|
+
<h1 class="font-display text-3xl sm:text-5xl lg:text-6xl font-bold text-foreground tracking-tight max-w-measure-wide mb-4">
|
|
133
|
+
{tagline}
|
|
134
|
+
</h1>
|
|
135
|
+
<p class="text-base sm:text-lg text-muted-foreground max-w-deck leading-relaxed">
|
|
136
|
+
{description}
|
|
137
|
+
</p>
|
|
138
|
+
</Container>
|
|
139
|
+
</header>
|
|
140
|
+
|
|
141
|
+
{lead ? (
|
|
142
|
+
<Container>
|
|
143
|
+
<section aria-label={l.featuredEyebrow} class="mb-14">
|
|
144
|
+
<ArticleFeatureCard
|
|
145
|
+
href={url(routePath('articles', lead.data.slug, routes))}
|
|
146
|
+
title={lead.data.title}
|
|
147
|
+
description={lead.data.description}
|
|
148
|
+
author={lead.data.author ?? brand}
|
|
149
|
+
label={lead.data.category ? (categoryMap[lead.data.category] ?? l.featuredEyebrow) : l.featuredEyebrow}
|
|
150
|
+
image={articleImages[lead.data.slug]}
|
|
151
|
+
imageAlt={lead.data.imageAlt}
|
|
152
|
+
dateTime={leadDisplayIso}
|
|
153
|
+
dateLabel={leadDisplayDate}
|
|
154
|
+
updated={leadUpdated}
|
|
155
|
+
readingLabel={`${leadReadMins} min`}
|
|
156
|
+
loading="eager"
|
|
157
|
+
headingLevel={2}
|
|
158
|
+
locale={locale}
|
|
159
|
+
/>
|
|
160
|
+
</section>
|
|
161
|
+
|
|
162
|
+
{shelf.length > 0 && (
|
|
163
|
+
<ArticleHubSection
|
|
164
|
+
id="in-focus"
|
|
165
|
+
heading={l.trendingHeading}
|
|
166
|
+
count={shelf.length}
|
|
167
|
+
locale={locale}
|
|
168
|
+
>
|
|
169
|
+
<ArticleCardGrid
|
|
170
|
+
articles={shelf}
|
|
171
|
+
articleImages={articleImages}
|
|
172
|
+
url={url}
|
|
173
|
+
categoryLabels={categoryMap}
|
|
174
|
+
tagLabels={tagLabels}
|
|
175
|
+
locale={locale}
|
|
176
|
+
timeZone={timeZone}
|
|
177
|
+
routes={routes}
|
|
178
|
+
columns={3}
|
|
179
|
+
/>
|
|
180
|
+
</ArticleHubSection>
|
|
181
|
+
)}
|
|
182
|
+
|
|
183
|
+
{latestArticles.length > 0 && (
|
|
184
|
+
<ArticleHubSection
|
|
185
|
+
id="latest-articles"
|
|
186
|
+
heading={l.latestHeading}
|
|
187
|
+
count={latestArticles.length}
|
|
188
|
+
moreHref={url(routePath('articles', undefined, routes))}
|
|
189
|
+
moreLabel={l.latestViewAll}
|
|
190
|
+
locale={locale}
|
|
191
|
+
>
|
|
192
|
+
<ArticleCardGrid
|
|
193
|
+
articles={latestArticles}
|
|
194
|
+
articleImages={articleImages}
|
|
195
|
+
url={url}
|
|
196
|
+
categoryLabels={categoryMap}
|
|
197
|
+
tagLabels={tagLabels}
|
|
198
|
+
locale={locale}
|
|
199
|
+
timeZone={timeZone}
|
|
200
|
+
routes={routes}
|
|
201
|
+
/>
|
|
202
|
+
</ArticleHubSection>
|
|
203
|
+
)}
|
|
204
|
+
|
|
205
|
+
{topicRails.map((rail) => (
|
|
206
|
+
<ArticleHubSection
|
|
207
|
+
id={`topic-${rail.category}`}
|
|
208
|
+
heading={rail.label}
|
|
209
|
+
count={rail.count}
|
|
210
|
+
subTags={rail.subTags}
|
|
211
|
+
moreHref={rail.moreHref}
|
|
212
|
+
moreLabel={l.topicsMoreLabel}
|
|
213
|
+
locale={locale}
|
|
214
|
+
class="mb-14 pt-10 border-t border-border/60"
|
|
215
|
+
>
|
|
216
|
+
<ArticleCardGrid
|
|
217
|
+
articles={rail.articles}
|
|
218
|
+
articleImages={articleImages}
|
|
219
|
+
url={url}
|
|
220
|
+
categoryLabels={categoryMap}
|
|
221
|
+
tagLabels={tagLabels}
|
|
222
|
+
locale={locale}
|
|
223
|
+
timeZone={timeZone}
|
|
224
|
+
routes={routes}
|
|
225
|
+
/>
|
|
226
|
+
</ArticleHubSection>
|
|
227
|
+
))}
|
|
228
|
+
</Container>
|
|
229
|
+
) : (
|
|
230
|
+
<Container size="measure" class="py-12">
|
|
231
|
+
<div class="rounded-2xl border border-border bg-card p-8 sm:p-10 text-center">
|
|
232
|
+
<p class="text-xs font-semibold uppercase tracking-[0.2em] text-primary mb-2">
|
|
233
|
+
{l.emptyEyebrow}
|
|
234
|
+
</p>
|
|
235
|
+
<h2 class="font-display text-2xl sm:text-3xl font-semibold text-foreground mb-3">
|
|
236
|
+
{l.emptyHeading}
|
|
237
|
+
</h2>
|
|
238
|
+
<p class="text-muted-foreground leading-relaxed max-w-deck mx-auto">
|
|
239
|
+
{l.emptyBody}
|
|
240
|
+
</p>
|
|
241
|
+
</div>
|
|
242
|
+
</Container>
|
|
243
|
+
)}
|
|
244
|
+
|
|
245
|
+
{stripAuthors.length > 0 && (
|
|
246
|
+
<div class="mt-16">
|
|
247
|
+
<AuthorStrip
|
|
248
|
+
authors={stripAuthors}
|
|
249
|
+
ariaLabel={l.authorsHeading}
|
|
250
|
+
heading={l.authorsHeading}
|
|
251
|
+
teamHref={url(routePath('authors', undefined, routes))}
|
|
252
|
+
teamLabel={l.authorsHeading}
|
|
253
|
+
/>
|
|
254
|
+
</div>
|
|
255
|
+
)}
|
|
256
|
+
</main>
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
* header-extra — a line under the lede (e.g. the article count and the era's date range). Page 1 only.
|
|
10
10
|
* grid — the site's article card grid for this page.
|
|
11
11
|
* pagination — the site's pagination.
|
|
12
|
+
* places — places-to-visit strip after the list. Page 1 only.
|
|
12
13
|
* go-deeper — related-content blocks after the list. Page 1 only.
|
|
14
|
+
* faq — the site FAQ block, rendered in a measure column at the bottom. Page 1 only.
|
|
13
15
|
*/
|
|
14
16
|
import type { ImageMetadata } from 'astro';
|
|
15
17
|
import type { EraDefinition } from '@sarimarcus/content-sites-core/eras';
|
|
@@ -36,6 +38,7 @@ interface Props {
|
|
|
36
38
|
const { eyebrow, heading, lede, era, hero, currentPage, listHeading, dossiersLabel } = Astro.props;
|
|
37
39
|
const first = currentPage === 1;
|
|
38
40
|
const headingId = `${era.anchor}-articles-heading`;
|
|
41
|
+
const faqHtml = first && Astro.slots.has('faq') ? (await Astro.slots.render('faq')).trim() : '';
|
|
39
42
|
---
|
|
40
43
|
|
|
41
44
|
{first ? (
|
|
@@ -63,9 +66,14 @@ const headingId = `${era.anchor}-articles-heading`;
|
|
|
63
66
|
<slot name="grid" />
|
|
64
67
|
<slot name="pagination" />
|
|
65
68
|
</section>
|
|
66
|
-
<slot name="go-deeper" />
|
|
69
|
+
<slot name="places" /><slot name="go-deeper" />
|
|
67
70
|
<EraDossiers era={era} label={dossiersLabel} />
|
|
68
71
|
</Container>
|
|
72
|
+
{faqHtml && (
|
|
73
|
+
<Container size="measure" class="mt-16">
|
|
74
|
+
<Fragment set:html={faqHtml} />
|
|
75
|
+
</Container>
|
|
76
|
+
)}
|
|
69
77
|
</ArticlesListingPage>
|
|
70
78
|
) : (
|
|
71
79
|
<ArticlesListingPage eyebrow={eyebrow} heading={heading} lede={lede}>
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* `breadcrumbs`, `prevHref`, `nextHref`) and pass the same model here. Slots:
|
|
7
7
|
* grid — the site's article card grid for this page.
|
|
8
8
|
* pagination — the site's pagination.
|
|
9
|
+
* places — places-to-visit strip after the list. Page 1 only.
|
|
10
|
+
* faq — the site FAQ block, rendered in a measure column at the bottom. Page 1 only.
|
|
9
11
|
*/
|
|
10
12
|
import type { ImageMetadata } from 'astro';
|
|
11
13
|
import type { EraDefinition } from '@sarimarcus/content-sites-core/eras';
|
|
@@ -45,7 +47,9 @@ const { first, page, heading, trail, count, timelineHref, labels: L } = listing;
|
|
|
45
47
|
</Fragment>
|
|
46
48
|
<slot name="grid" slot="grid" />
|
|
47
49
|
<slot name="pagination" slot="pagination" />
|
|
50
|
+
<slot name="places" slot="places" />
|
|
48
51
|
<p slot="go-deeper" class="mt-12">
|
|
49
52
|
<LinkArrow href={timelineHref}>{L.timelineLink(era.label)}</LinkArrow>
|
|
50
53
|
</p>
|
|
54
|
+
<slot name="faq" slot="faq" />
|
|
51
55
|
</EraListingPage>
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* ShareButtons — Mobile- & Discover-first article share bar (SLA-3718, Release B).
|
|
4
|
+
* Includes WhatsApp, Flipboard, X, LinkedIn, Native Share (`navigator.share` on supported devices),
|
|
5
|
+
* and Copy Link with inline "Copied" confirmation via `aria-live="polite"`.
|
|
6
|
+
*/
|
|
7
|
+
import { getLabels } from '../internal/labels';
|
|
8
|
+
import { buildShareUrls } from './share';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
url: string;
|
|
12
|
+
title: string;
|
|
13
|
+
locale?: string;
|
|
14
|
+
compact?: boolean;
|
|
15
|
+
class?: string;
|
|
16
|
+
ariaLabel?: string;
|
|
17
|
+
shareLabel?: string;
|
|
18
|
+
whatsappLabel?: string;
|
|
19
|
+
flipboardLabel?: string;
|
|
20
|
+
xLabel?: string;
|
|
21
|
+
linkedinLabel?: string;
|
|
22
|
+
nativeShareLabel?: string;
|
|
23
|
+
copyLabel?: string;
|
|
24
|
+
copiedLabel?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
url,
|
|
29
|
+
title,
|
|
30
|
+
locale,
|
|
31
|
+
compact = false,
|
|
32
|
+
class: className = '',
|
|
33
|
+
ariaLabel,
|
|
34
|
+
shareLabel,
|
|
35
|
+
whatsappLabel,
|
|
36
|
+
flipboardLabel,
|
|
37
|
+
xLabel,
|
|
38
|
+
linkedinLabel,
|
|
39
|
+
nativeShareLabel,
|
|
40
|
+
copyLabel,
|
|
41
|
+
copiedLabel,
|
|
42
|
+
} = Astro.props;
|
|
43
|
+
|
|
44
|
+
const l = getLabels(locale).shareButtons;
|
|
45
|
+
const resolvedAriaLabel = ariaLabel ?? l.ariaLabel;
|
|
46
|
+
const resolvedShareLabel = shareLabel ?? l.shareLabel;
|
|
47
|
+
const resolvedWhatsappLabel = whatsappLabel ?? l.whatsappLabel;
|
|
48
|
+
const resolvedFlipboardLabel = flipboardLabel ?? l.flipboardLabel;
|
|
49
|
+
const resolvedXLabel = xLabel ?? l.xLabel;
|
|
50
|
+
const resolvedLinkedinLabel = linkedinLabel ?? l.linkedinLabel;
|
|
51
|
+
const resolvedNativeShareLabel = nativeShareLabel ?? l.nativeShareLabel;
|
|
52
|
+
const resolvedCopyLabel = copyLabel ?? l.copyLabel;
|
|
53
|
+
const resolvedCopiedLabel = copiedLabel ?? l.copiedLabel;
|
|
54
|
+
|
|
55
|
+
const urls = buildShareUrls({ url, title });
|
|
56
|
+
const btnClass = compact
|
|
57
|
+
? 'inline-flex items-center justify-center min-h-[44px] min-w-[44px] w-11 h-11 rounded-full border border-border bg-card/80 text-muted-foreground hover:text-primary hover:border-primary/40 transition-colors'
|
|
58
|
+
: 'inline-flex items-center justify-center min-h-[44px] min-w-[44px] w-11 h-11 rounded-full border border-border bg-card text-muted-foreground hover:text-primary hover:border-primary/40 transition-colors';
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
<div
|
|
62
|
+
class:list={['flex flex-wrap items-center gap-2', className]}
|
|
63
|
+
role="group"
|
|
64
|
+
aria-label={resolvedAriaLabel}
|
|
65
|
+
data-share-group
|
|
66
|
+
data-share-url={url}
|
|
67
|
+
data-share-title={title}
|
|
68
|
+
>
|
|
69
|
+
{!compact && (
|
|
70
|
+
<span class="text-xs font-semibold uppercase tracking-wider text-muted-foreground mr-1">
|
|
71
|
+
{resolvedShareLabel}
|
|
72
|
+
</span>
|
|
73
|
+
)}
|
|
74
|
+
|
|
75
|
+
<a
|
|
76
|
+
href={urls.whatsapp}
|
|
77
|
+
target="_blank"
|
|
78
|
+
rel="noopener noreferrer"
|
|
79
|
+
aria-label={resolvedWhatsappLabel}
|
|
80
|
+
title={resolvedWhatsappLabel}
|
|
81
|
+
class={btnClass}
|
|
82
|
+
>
|
|
83
|
+
<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">
|
|
84
|
+
<path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" />
|
|
85
|
+
</svg>
|
|
86
|
+
</a>
|
|
87
|
+
|
|
88
|
+
<a
|
|
89
|
+
href={urls.flipboard}
|
|
90
|
+
target="_blank"
|
|
91
|
+
rel="noopener noreferrer"
|
|
92
|
+
aria-label={resolvedFlipboardLabel}
|
|
93
|
+
title={resolvedFlipboardLabel}
|
|
94
|
+
class={btnClass}
|
|
95
|
+
>
|
|
96
|
+
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
|
97
|
+
<path d="M3 3h18v18H3V3zm14.4 7.2h-4.8v4.8H7.8V6.6h9.6v3.6z" />
|
|
98
|
+
</svg>
|
|
99
|
+
</a>
|
|
100
|
+
|
|
101
|
+
<a
|
|
102
|
+
href={urls.x}
|
|
103
|
+
target="_blank"
|
|
104
|
+
rel="noopener noreferrer"
|
|
105
|
+
aria-label={resolvedXLabel}
|
|
106
|
+
title={resolvedXLabel}
|
|
107
|
+
class={btnClass}
|
|
108
|
+
>
|
|
109
|
+
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
|
110
|
+
<path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z" />
|
|
111
|
+
</svg>
|
|
112
|
+
</a>
|
|
113
|
+
|
|
114
|
+
<a
|
|
115
|
+
href={urls.linkedin}
|
|
116
|
+
target="_blank"
|
|
117
|
+
rel="noopener noreferrer"
|
|
118
|
+
aria-label={resolvedLinkedinLabel}
|
|
119
|
+
title={resolvedLinkedinLabel}
|
|
120
|
+
class={btnClass}
|
|
121
|
+
>
|
|
122
|
+
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
|
123
|
+
<path d="M19 3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14m-.5 15.5v-5.3a3.26 3.26 0 0 0-3.26-3.26c-.85 0-1.84.52-2.28 1.3v-1.11h-2.79v8.37h2.79v-4.93c0-.77.62-1.4 1.39-1.4a1.4 1.4 0 0 1 1.4 1.4v4.93h2.75M6.88 8.56a1.68 1.68 0 0 0 1.68-1.68c0-.93-.75-1.69-1.68-1.69a1.69 1.69 0 0 0-1.69 1.69c0 .93.76 1.68 1.69 1.68m1.39 9.94v-8.37H5.5v8.37h2.77z" />
|
|
124
|
+
</svg>
|
|
125
|
+
</a>
|
|
126
|
+
|
|
127
|
+
<button
|
|
128
|
+
type="button"
|
|
129
|
+
data-native-share
|
|
130
|
+
hidden
|
|
131
|
+
aria-label={resolvedNativeShareLabel}
|
|
132
|
+
title={resolvedNativeShareLabel}
|
|
133
|
+
class={btnClass}
|
|
134
|
+
>
|
|
135
|
+
<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">
|
|
136
|
+
<circle cx="18" cy="5" r="3" />
|
|
137
|
+
<circle cx="6" cy="12" r="3" />
|
|
138
|
+
<circle cx="18" cy="19" r="3" />
|
|
139
|
+
<line x1="8.59" y1="13.51" x2="15.42" y2="17.49" />
|
|
140
|
+
<line x1="15.41" y1="6.51" x2="8.59" y2="10.49" />
|
|
141
|
+
</svg>
|
|
142
|
+
</button>
|
|
143
|
+
|
|
144
|
+
<button
|
|
145
|
+
type="button"
|
|
146
|
+
data-copy-link
|
|
147
|
+
data-copy-label={resolvedCopyLabel}
|
|
148
|
+
data-copied-label={resolvedCopiedLabel}
|
|
149
|
+
aria-label={resolvedCopyLabel}
|
|
150
|
+
title={resolvedCopyLabel}
|
|
151
|
+
class="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"
|
|
152
|
+
>
|
|
153
|
+
<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">
|
|
154
|
+
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" />
|
|
155
|
+
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />
|
|
156
|
+
</svg>
|
|
157
|
+
<span data-copy-text aria-live="polite">{resolvedCopyLabel}</span>
|
|
158
|
+
</button>
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
<script>
|
|
162
|
+
function initShareGroups() {
|
|
163
|
+
const canShare = typeof navigator !== 'undefined' && typeof navigator.share === 'function';
|
|
164
|
+
document.querySelectorAll<HTMLElement>('[data-share-group]').forEach((group) => {
|
|
165
|
+
if (group.dataset.bound === 'true') return;
|
|
166
|
+
group.dataset.bound = 'true';
|
|
167
|
+
const url = group.dataset.shareUrl || window.location.href;
|
|
168
|
+
const title = group.dataset.shareTitle || document.title;
|
|
169
|
+
|
|
170
|
+
const nativeBtn = group.querySelector<HTMLButtonElement>('[data-native-share]');
|
|
171
|
+
if (nativeBtn && canShare) {
|
|
172
|
+
nativeBtn.hidden = false;
|
|
173
|
+
nativeBtn.addEventListener('click', () => {
|
|
174
|
+
navigator.share({ title, url }).catch(() => {});
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const copyBtn = group.querySelector<HTMLButtonElement>('[data-copy-link]');
|
|
179
|
+
const copyText = group.querySelector<HTMLElement>('[data-copy-text]');
|
|
180
|
+
if (copyBtn && copyText) {
|
|
181
|
+
const defaultLabel = copyBtn.dataset.copyLabel || '';
|
|
182
|
+
const copiedLabel = copyBtn.dataset.copiedLabel || '';
|
|
183
|
+
copyBtn.addEventListener('click', async () => {
|
|
184
|
+
try {
|
|
185
|
+
await navigator.clipboard.writeText(url);
|
|
186
|
+
copyText.textContent = copiedLabel;
|
|
187
|
+
setTimeout(() => {
|
|
188
|
+
copyText.textContent = defaultLabel;
|
|
189
|
+
}, 2000);
|
|
190
|
+
} catch {}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
initShareGroups();
|
|
197
|
+
document.addEventListener('astro:page-load', initShareGroups);
|
|
198
|
+
</script>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Default English interlude labels for `Interlude.astro` (SLA-3720).
|
|
2
|
+
import type { InterludeLabels } from './interludes/types';
|
|
3
|
+
|
|
4
|
+
export const DEFAULT_INTERLUDE_LABELS: InterludeLabels = {
|
|
5
|
+
answerBox: 'Quick Answer',
|
|
6
|
+
evidence: {
|
|
7
|
+
title: 'Evidence & Context',
|
|
8
|
+
finding: 'Finding',
|
|
9
|
+
basis: 'Basis',
|
|
10
|
+
boundary: 'Boundary',
|
|
11
|
+
},
|
|
12
|
+
fieldNote: 'From the Desk',
|
|
13
|
+
timeline: 'Timeline',
|
|
14
|
+
tldr: {
|
|
15
|
+
bullets: 'Key Takeaways',
|
|
16
|
+
prose: 'In Short',
|
|
17
|
+
},
|
|
18
|
+
didYouKnow: 'Did You Know?',
|
|
19
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { monogram } from './monogram';
|
|
2
|
+
|
|
1
3
|
export interface AuthorWorkItem {
|
|
2
4
|
title: string;
|
|
3
5
|
description?: string;
|
|
@@ -111,3 +113,28 @@ export function groupAuthorWork(
|
|
|
111
113
|
topicCount,
|
|
112
114
|
};
|
|
113
115
|
}
|
|
116
|
+
|
|
117
|
+
/** Default `AuthorWorkGroupConfig` for articles-only editorial sites (SLA-3721). */
|
|
118
|
+
export const EDITORIAL_AUTHOR_WORK_CONFIG: readonly AuthorWorkGroupConfig[] = [
|
|
119
|
+
{
|
|
120
|
+
collection: 'articles',
|
|
121
|
+
label: 'Articles',
|
|
122
|
+
kind: 'Article',
|
|
123
|
+
listing: '/articles',
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Generates an inline SVG data URI avatar with the author's monogram initials when no portrait asset exists,
|
|
129
|
+
* so `AuthorCard` and `AuthorsIndexPage` always receive a valid non-empty `photo` string (SLA-3721).
|
|
130
|
+
*/
|
|
131
|
+
export function authorPhotoDataUri(
|
|
132
|
+
name: string,
|
|
133
|
+
options?: { bg?: string; fg?: string },
|
|
134
|
+
): string {
|
|
135
|
+
const initials = monogram(name) || '?';
|
|
136
|
+
const bg = options?.bg ?? '#1e293b';
|
|
137
|
+
const fg = options?.fg ?? '#38bdf8';
|
|
138
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120" width="120" height="120"><rect width="120" height="120" rx="60" fill="${bg}"/><text x="50%" y="54%" style="dominant-baseline:middle;text-anchor:middle" fill="${fg}" font-family="system-ui,sans-serif" font-size="44" font-weight="700">${initials}</text></svg>`;
|
|
139
|
+
return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
|
|
140
|
+
}
|
package/src/editorial/index.ts
CHANGED
|
@@ -73,9 +73,29 @@ export { default as AuthorsIndexPage } from './AuthorsIndexPage.astro';
|
|
|
73
73
|
export {
|
|
74
74
|
socialLinkLabel,
|
|
75
75
|
groupAuthorWork,
|
|
76
|
+
EDITORIAL_AUTHOR_WORK_CONFIG,
|
|
77
|
+
authorPhotoDataUri,
|
|
76
78
|
type AuthorWorkItem,
|
|
77
79
|
type AuthorTopicLink,
|
|
78
80
|
type AuthorWorkGroupConfig,
|
|
79
81
|
type AuthorRawItem,
|
|
80
82
|
type GroupedAuthorWork,
|
|
81
83
|
} from './author-page';
|
|
84
|
+
export { default as ArticleCardGrid } from './ArticleCardGrid.astro';
|
|
85
|
+
export type { ArticleCardGridEntry } from './ArticleCardGrid.astro';
|
|
86
|
+
export type { ArticleHubSubTag } from './ArticleHubSection.astro';
|
|
87
|
+
export { default as ArticleTagPage } from './ArticleTagPage.astro';
|
|
88
|
+
export type { ArticleTagPill } from './ArticleTagPage.astro';
|
|
89
|
+
export { default as ShareButtons } from './ShareButtons.astro';
|
|
90
|
+
export { buildShareUrls } from './share';
|
|
91
|
+
export type { ShareUrlInput, ShareUrls } from './share';
|
|
92
|
+
export { default as ArticlePage } from './ArticlePage.astro';
|
|
93
|
+
export type {
|
|
94
|
+
ArticlePageResolvedCard,
|
|
95
|
+
ArticlePageTagLink,
|
|
96
|
+
ArticlePageSection,
|
|
97
|
+
ArticlePageData,
|
|
98
|
+
} from './ArticlePage.astro';
|
|
99
|
+
export { DEFAULT_INTERLUDE_LABELS } from './article-page';
|
|
100
|
+
export { default as EditorialHomePage } from './EditorialHomePage.astro';
|
|
101
|
+
export type { EditorialHomeAuthor } from './EditorialHomePage.astro';
|
|
@@ -13,7 +13,7 @@ interface Props {
|
|
|
13
13
|
eyebrow: string;
|
|
14
14
|
title: string;
|
|
15
15
|
description?: string;
|
|
16
|
-
variant?: 'inline' | 'featured';
|
|
16
|
+
variant?: 'inline' | 'featured' | 'compact';
|
|
17
17
|
image?: ImageMetadata;
|
|
18
18
|
imageAlt?: string;
|
|
19
19
|
eyebrowClass?: string;
|
|
@@ -43,6 +43,36 @@ const { href, eyebrow, title, description, variant = 'inline', image, imageAlt,
|
|
|
43
43
|
aria-hidden="true"
|
|
44
44
|
/>
|
|
45
45
|
</a>
|
|
46
|
+
) : variant === 'compact' ? (
|
|
47
|
+
<a
|
|
48
|
+
href={href}
|
|
49
|
+
class="group not-prose my-8 flex items-center gap-4 p-3 sm:p-4 rounded-xl border border-border bg-card/80 hover:border-primary/60 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background transition-colors"
|
|
50
|
+
>
|
|
51
|
+
{image && (
|
|
52
|
+
<div class="w-20 h-20 sm:w-28 sm:h-20 shrink-0 overflow-hidden rounded-lg bg-muted">
|
|
53
|
+
<ResponsivePicture
|
|
54
|
+
src={image}
|
|
55
|
+
alt={imageAlt ?? title}
|
|
56
|
+
sizes="112px"
|
|
57
|
+
class="w-full h-full object-cover"
|
|
58
|
+
loading="lazy"
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
)}
|
|
62
|
+
<div class="min-w-0 flex-1">
|
|
63
|
+
<p class={eyebrowClass ?? 'text-xs font-semibold uppercase tracking-[0.16em] text-primary mb-1'}>
|
|
64
|
+
{eyebrow}
|
|
65
|
+
</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">
|
|
67
|
+
{title}
|
|
68
|
+
</h4>
|
|
69
|
+
</div>
|
|
70
|
+
<Icon
|
|
71
|
+
name="arrow-right"
|
|
72
|
+
class="shrink-0 w-5 h-5 text-primary transition-transform motion-safe:group-hover:translate-x-1"
|
|
73
|
+
aria-hidden="true"
|
|
74
|
+
/>
|
|
75
|
+
</a>
|
|
46
76
|
) : (
|
|
47
77
|
<a
|
|
48
78
|
href={href}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Pure URL builders for ShareButtons.astro (SLA-3718).
|
|
2
|
+
export interface ShareUrlInput {
|
|
3
|
+
url: string;
|
|
4
|
+
title: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface ShareUrls {
|
|
8
|
+
whatsapp: string;
|
|
9
|
+
flipboard: string;
|
|
10
|
+
x: string;
|
|
11
|
+
linkedin: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function buildShareUrls({ url, title }: ShareUrlInput): ShareUrls {
|
|
15
|
+
const encodedUrl = encodeURIComponent(url);
|
|
16
|
+
const encodedTitle = encodeURIComponent(title);
|
|
17
|
+
const encodedWhatsapp = encodeURIComponent(`${title} ${url}`);
|
|
18
|
+
return {
|
|
19
|
+
whatsapp: `https://wa.me/?text=${encodedWhatsapp}`,
|
|
20
|
+
flipboard: `https://share.flipboard.com/bookmarklet/popout?v=2&title=${encodedTitle}&url=${encodedUrl}`,
|
|
21
|
+
x: `https://x.com/intent/tweet?text=${encodedTitle}&url=${encodedUrl}`,
|
|
22
|
+
linkedin: `https://www.linkedin.com/sharing/share-offsite/?url=${encodedUrl}`,
|
|
23
|
+
};
|
|
24
|
+
}
|
package/src/editorial/types.ts
CHANGED
|
@@ -24,6 +24,10 @@ export interface ArticleSummary {
|
|
|
24
24
|
updated?: boolean;
|
|
25
25
|
/** Pre-composed reading-time text, e.g. "6 min read". */
|
|
26
26
|
readingLabel?: string;
|
|
27
|
+
/** Optional category eyebrow label above the title. */
|
|
28
|
+
categoryLabel?: string;
|
|
29
|
+
/** Optional primary sub-tag pill label above the title. */
|
|
30
|
+
tagLabel?: string;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
/** A key-fact tile. `detailHtml` is parsed by the site, so footnote markers resolve. */
|