@sarimarcus/content-sites-tourism 0.30.1 → 0.31.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 +3 -3
- package/src/cards/EventCard.astro +159 -0
- package/src/cards/GuideCard.astro +64 -0
- package/src/cards/index.ts +3 -0
- package/src/sections/ArticleCardGrid.astro +60 -0
- package/src/sections/HomeTripPlanner.astro +40 -0
- package/src/sections/MonumentBody.astro +91 -0
- package/src/sections/MonumentBodySlot.astro +66 -0
- package/src/sections/index.ts +9 -0
- package/src/sections/monumentBody.ts +33 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All packages in the platform release in lockstep; entries are per release version.
|
|
4
4
|
|
|
5
|
+
## 0.31.0 (2026-10-08)
|
|
6
|
+
|
|
7
|
+
- `./cards` adds `GuideCard` (`GuideCardTone`: gold, terracotta, azulejo) and `EventCard` (takes `href`, `image`, `fallbackSrc`, `imageAlt`, `tagLabels`; the site adapter keeps the image glob, placeholder, tag labels and city alt) (SLA-3017).
|
|
8
|
+
- `./sections` adds `HomeTripPlanner`, `MonumentBody` and `MonumentBodySlot` (markdown and GYG tagging come in as `renderMarkdown`, `renderInline` and `tagLinks` props) and `ArticleCardGrid` (`timeZone` default `Europe/Madrid`) (SLA-3017).
|
|
9
|
+
|
|
10
|
+
### Breaking
|
|
11
|
+
|
|
12
|
+
- `MonumentBody` drops `basePath` for `renderMarkdown`, `renderInline` and `tagLinks`; the site EventCard becomes an adapter over the tourism card. Sites run `rewrite-imports.mjs --delete-local`, then `scripts/platform/migrations/core-markdown.mjs` and `scripts/platform/migrations/promoted-site-files.mjs` (SLA-3017).
|
|
13
|
+
|
|
14
|
+
|
|
5
15
|
## 0.30.1 (2026-10-07)
|
|
6
16
|
|
|
7
17
|
- No changes; lockstep release with ui (SLA-2989).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sarimarcus/content-sites-tourism",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "City-tourism vertical: city-entity components, pages templates and utilities for the tourism sites.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"astro": "^7.0.6",
|
|
38
38
|
"tailwindcss": "^4.1.18",
|
|
39
|
-
"@sarimarcus/content-sites-core": "0.
|
|
40
|
-
"@sarimarcus/content-sites-ui": "0.
|
|
39
|
+
"@sarimarcus/content-sites-core": "0.31.0",
|
|
40
|
+
"@sarimarcus/content-sites-ui": "0.31.0"
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* EventCard — event teaser: period badge coloured by event type, UNESCO and free pills, dates, price, audience
|
|
4
|
+
* badges. The site adapter resolves the href, the optimised image, the fallback, the alt text and the tag labels.
|
|
5
|
+
*/
|
|
6
|
+
import type { ImageMetadata } from 'astro';
|
|
7
|
+
import { Badge, Icon, ResponsivePicture } from '@sarimarcus/content-sites-ui/primitives';
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
href: string;
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
image?: ImageMetadata;
|
|
14
|
+
/** Shown when `image` is absent. */
|
|
15
|
+
fallbackSrc: string;
|
|
16
|
+
imageAlt: string;
|
|
17
|
+
period: string;
|
|
18
|
+
dates?: string;
|
|
19
|
+
type: string;
|
|
20
|
+
category: string;
|
|
21
|
+
price?: string;
|
|
22
|
+
tags?: string[];
|
|
23
|
+
/** Audience badges (first three shown). */
|
|
24
|
+
tagLabels?: string[];
|
|
25
|
+
index?: number;
|
|
26
|
+
class?: string;
|
|
27
|
+
priority?: boolean; // Explicit LCP priority
|
|
28
|
+
eager?: number; // How many eager loads (default 1)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
href,
|
|
33
|
+
name,
|
|
34
|
+
description,
|
|
35
|
+
image,
|
|
36
|
+
fallbackSrc,
|
|
37
|
+
imageAlt,
|
|
38
|
+
period,
|
|
39
|
+
dates,
|
|
40
|
+
type,
|
|
41
|
+
category,
|
|
42
|
+
price,
|
|
43
|
+
tags = [],
|
|
44
|
+
tagLabels = [],
|
|
45
|
+
index = 999,
|
|
46
|
+
class: className,
|
|
47
|
+
priority = false,
|
|
48
|
+
eager = 1,
|
|
49
|
+
} = Astro.props;
|
|
50
|
+
|
|
51
|
+
const fetchPriority = priority || index === 0 ? "high" : "auto";
|
|
52
|
+
const loadingStrategy = index < eager ? "eager" : "lazy";
|
|
53
|
+
|
|
54
|
+
const isUNESCO = tags.includes('unesco');
|
|
55
|
+
const isFree = tags.includes('free') || price?.toLowerCase().includes('free');
|
|
56
|
+
|
|
57
|
+
// Type-based colors - WCAG AA compliant
|
|
58
|
+
const typeColors: Record<string, string> = {
|
|
59
|
+
festival: 'bg-primary text-chalk', // 11.8:1 ✓
|
|
60
|
+
feria: 'bg-accent-strong text-chalk', // 7.1:1 ✓
|
|
61
|
+
gastronomie: 'bg-secondary text-chalk', // 8.2:1 ✓
|
|
62
|
+
religieux: 'bg-shadow text-chalk', // 11.3:1 ✓
|
|
63
|
+
};
|
|
64
|
+
const typeColor = typeColors[type] || 'bg-shadow text-chalk';
|
|
65
|
+
const labels = tagLabels.slice(0, 3);
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
<article class:list={['group relative bg-card rounded-xl overflow-hidden card-lift border border-border flex flex-col h-full', className]}>
|
|
69
|
+
<a href={href} class="flex flex-col h-full focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 rounded-xl">
|
|
70
|
+
<div class="relative h-48 sm:h-56 overflow-hidden img-placeholder shrink-0">
|
|
71
|
+
{image ? (
|
|
72
|
+
<ResponsivePicture
|
|
73
|
+
src={image}
|
|
74
|
+
alt={imageAlt}
|
|
75
|
+
sizes="(max-width: 639px) 100vw, (max-width: 1023px) 50vw, 33vw"
|
|
76
|
+
pictureAttributes={{ class: 'block w-full h-full' }}
|
|
77
|
+
class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"
|
|
78
|
+
loading={loadingStrategy}
|
|
79
|
+
fetchpriority={fetchPriority}
|
|
80
|
+
decoding="async"
|
|
81
|
+
/>
|
|
82
|
+
) : (
|
|
83
|
+
<img
|
|
84
|
+
src={fallbackSrc}
|
|
85
|
+
alt={imageAlt}
|
|
86
|
+
width="400"
|
|
87
|
+
height="224"
|
|
88
|
+
class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"
|
|
89
|
+
loading={loadingStrategy}
|
|
90
|
+
fetchpriority={fetchPriority}
|
|
91
|
+
decoding="async"
|
|
92
|
+
/>
|
|
93
|
+
)}
|
|
94
|
+
|
|
95
|
+
<div class="absolute top-3 right-3 max-w-[55%]">
|
|
96
|
+
<Badge tone="custom" toneClass={`${typeColor} backdrop-blur-sm`} size="lg" lines={1}>{period}</Badge>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<div class="p-4 sm:p-5 flex flex-col flex-1">
|
|
101
|
+
<span class="text-xs text-muted-foreground uppercase tracking-wider mb-1 block">{category}</span>
|
|
102
|
+
<h3 class="text-lg sm:text-xl font-semibold text-foreground leading-tight font-display mb-2">
|
|
103
|
+
{name}
|
|
104
|
+
</h3>
|
|
105
|
+
|
|
106
|
+
{(isUNESCO || isFree) && (
|
|
107
|
+
<div class="flex flex-wrap gap-1.5 mb-3">
|
|
108
|
+
{isUNESCO && (
|
|
109
|
+
<Badge tone="custom" toneClass="bg-accent-strong/10 text-accent-strong" size="sm" lines={1}>
|
|
110
|
+
<Icon name="star" filled class="w-3 h-3 inline-block align-[-1px] mr-1" aria-hidden="true" />UNESCO
|
|
111
|
+
</Badge>
|
|
112
|
+
)}
|
|
113
|
+
{isFree && (
|
|
114
|
+
<Badge tone="custom" toneClass="bg-secondary/10 text-secondary" size="sm" lines={1}>Free</Badge>
|
|
115
|
+
)}
|
|
116
|
+
</div>
|
|
117
|
+
)}
|
|
118
|
+
|
|
119
|
+
<p class="text-base text-muted-foreground line-clamp-2 mb-4">
|
|
120
|
+
{description}
|
|
121
|
+
</p>
|
|
122
|
+
|
|
123
|
+
<div class="flex flex-wrap gap-3 text-sm text-shadow-light mb-4">
|
|
124
|
+
{dates && (
|
|
125
|
+
<span class="inline-flex items-center gap-1.5">
|
|
126
|
+
<Icon name="calendar" class="w-3.5 h-3.5 text-primary" aria-hidden="true" />
|
|
127
|
+
<span>{dates}</span>
|
|
128
|
+
</span>
|
|
129
|
+
)}
|
|
130
|
+
{price && (
|
|
131
|
+
<span class="inline-flex items-center gap-1.5">
|
|
132
|
+
<Icon name="credit-card" class="w-3.5 h-3.5 text-accent" aria-hidden="true" />
|
|
133
|
+
<span>{price.split(',')[0]}</span>
|
|
134
|
+
</span>
|
|
135
|
+
)}
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
{labels.length > 0 && (
|
|
139
|
+
<div class="flex flex-wrap gap-1.5 mb-3">
|
|
140
|
+
{labels.map((label: string) => (
|
|
141
|
+
<Badge tone="primary" size="sm">{label}</Badge>
|
|
142
|
+
))}
|
|
143
|
+
</div>
|
|
144
|
+
)}
|
|
145
|
+
|
|
146
|
+
<div class="flex items-center justify-between pt-3 border-t border-border mt-auto">
|
|
147
|
+
<span class="inline-flex items-center gap-1.5 text-sm text-muted-foreground">
|
|
148
|
+
<Icon name="calendar" class="w-3.5 h-3.5" aria-hidden="true" />
|
|
149
|
+
{type === 'festival' ? 'Festival' : type === 'feria' ? 'Feria' : type === 'gastronomie' ? 'Gastronomy' : type === 'religieux' ? 'Tradition' : 'Event'}
|
|
150
|
+
</span>
|
|
151
|
+
|
|
152
|
+
<span class="inline-flex items-center gap-2 text-sm font-medium text-primary group-hover:text-primary-strong transition-colors">
|
|
153
|
+
Discover
|
|
154
|
+
<Icon name="arrow-right" class="w-4 h-4 transition-transform group-hover:translate-x-1" aria-hidden="true" />
|
|
155
|
+
</span>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
</a>
|
|
159
|
+
</article>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* GuideCard — a "start here" guide teaser on the home page. The tone keys are the tourism sites' palette names
|
|
4
|
+
* (accent, primary, secondary roles over the site's `chalk` surface token).
|
|
5
|
+
*/
|
|
6
|
+
import type { ImageMetadata } from 'astro';
|
|
7
|
+
import { ResponsiveImage } from '@sarimarcus/content-sites-ui/primitives';
|
|
8
|
+
|
|
9
|
+
export type GuideCardTone = 'gold' | 'terracotta' | 'azulejo';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
title: string;
|
|
13
|
+
description: string;
|
|
14
|
+
href: string;
|
|
15
|
+
image: ImageMetadata;
|
|
16
|
+
imageAlt: string;
|
|
17
|
+
tag?: string;
|
|
18
|
+
tone?: GuideCardTone;
|
|
19
|
+
class?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { title, description, href, image, imageAlt, tag, tone = 'gold', class: className = '' } = Astro.props;
|
|
23
|
+
|
|
24
|
+
const toneStyles = {
|
|
25
|
+
gold: {
|
|
26
|
+
accent: 'text-accent-strong',
|
|
27
|
+
hoverBorder: 'hover:border-accent',
|
|
28
|
+
surface: 'from-accent/10 via-chalk to-accent/5',
|
|
29
|
+
},
|
|
30
|
+
terracotta: {
|
|
31
|
+
accent: 'text-primary',
|
|
32
|
+
hoverBorder: 'hover:border-primary',
|
|
33
|
+
surface: 'from-primary/10 via-chalk to-primary/5',
|
|
34
|
+
},
|
|
35
|
+
azulejo: {
|
|
36
|
+
accent: 'text-secondary',
|
|
37
|
+
hoverBorder: 'hover:border-secondary',
|
|
38
|
+
surface: 'from-secondary/10 via-chalk to-secondary/5',
|
|
39
|
+
},
|
|
40
|
+
} as const;
|
|
41
|
+
|
|
42
|
+
const styles = toneStyles[tone];
|
|
43
|
+
---
|
|
44
|
+
<a
|
|
45
|
+
href={href}
|
|
46
|
+
class:list={[
|
|
47
|
+
`group rounded-2xl border border-border bg-gradient-to-br ${styles.surface} p-5 shadow-sm transition-[border-color,box-shadow,transform] duration-200 motion-safe:hover:-translate-y-1 hover:shadow-lg ${styles.hoverBorder}`,
|
|
48
|
+
className,
|
|
49
|
+
]}
|
|
50
|
+
>
|
|
51
|
+
<div class="mb-4 overflow-hidden rounded-2xl border border-white/40 bg-card/70">
|
|
52
|
+
<ResponsiveImage
|
|
53
|
+
src={image}
|
|
54
|
+
alt={imageAlt}
|
|
55
|
+
sizes="(min-width: 1024px) 22rem, (min-width: 768px) 30vw, 100vw"
|
|
56
|
+
class="h-40 w-full object-cover transition-transform duration-300 motion-safe:group-hover:scale-[1.03]"
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
{tag && (
|
|
60
|
+
<span class={`mb-3 block text-xs font-medium uppercase tracking-[0.15em] ${styles.accent}`}>{tag}</span>
|
|
61
|
+
)}
|
|
62
|
+
<h3 class="mb-2 text-lg font-semibold font-display">{title}</h3>
|
|
63
|
+
<p class="text-sm leading-relaxed text-muted-foreground">{description}</p>
|
|
64
|
+
</a>
|
package/src/cards/index.ts
CHANGED
|
@@ -7,11 +7,14 @@ export { default as BarCard } from './BarCard.astro';
|
|
|
7
7
|
export { default as NeighborhoodCard } from './NeighborhoodCard.astro';
|
|
8
8
|
export { default as HotelCard } from './HotelCard.astro';
|
|
9
9
|
export { default as ActivityCard } from './ActivityCard.astro';
|
|
10
|
+
export { default as GuideCard } from './GuideCard.astro';
|
|
11
|
+
export { default as EventCard } from './EventCard.astro';
|
|
10
12
|
export type { WalkCardStrings } from './WalkCard.astro';
|
|
11
13
|
export type { CardRating } from './RestaurantCard.astro';
|
|
12
14
|
export type { BarFeature } from './BarCard.astro';
|
|
13
15
|
export type { CardAmenity, HotelStars } from './HotelCard.astro';
|
|
14
16
|
export type { ActivityCardStrings } from './ActivityCard.astro';
|
|
17
|
+
export type { GuideCardTone } from './GuideCard.astro';
|
|
15
18
|
export type {
|
|
16
19
|
NeighborhoodAttraction,
|
|
17
20
|
NeighborhoodBadge,
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* ArticleCardGrid — the article listing grid (ui ArticleGrid) from article collection entries: the date label shows
|
|
4
|
+
* the last update when it falls on another calendar day than publication, formatted in `timeZone`.
|
|
5
|
+
*/
|
|
6
|
+
import type { ImageMetadata } from 'astro';
|
|
7
|
+
import { ArticleGrid } from '@sarimarcus/content-sites-ui/editorial';
|
|
8
|
+
import { url } from '@sarimarcus/content-sites-core/url';
|
|
9
|
+
|
|
10
|
+
export interface ArticleCardGridEntry {
|
|
11
|
+
data: {
|
|
12
|
+
slug: string;
|
|
13
|
+
title: string;
|
|
14
|
+
description: string;
|
|
15
|
+
author?: string;
|
|
16
|
+
imageAlt?: string;
|
|
17
|
+
datePublished?: string;
|
|
18
|
+
dateModified?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface Props {
|
|
23
|
+
articles: ArticleCardGridEntry[];
|
|
24
|
+
articleImages: Record<string, ImageMetadata>;
|
|
25
|
+
/** IANA zone the card dates are shown in. */
|
|
26
|
+
timeZone?: string;
|
|
27
|
+
readLabel?: string;
|
|
28
|
+
updatedLabel?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const { articles, articleImages, timeZone = 'Europe/Madrid', readLabel = 'Read', updatedLabel = 'Updated' } = Astro.props;
|
|
32
|
+
|
|
33
|
+
function formatCardDate(dateStr: string | undefined): string {
|
|
34
|
+
if (!dateStr) return '';
|
|
35
|
+
// Articles carry a real HH:MM, so show it here too instead of just the day.
|
|
36
|
+
const date = new Date(dateStr);
|
|
37
|
+
return dateStr.includes('T')
|
|
38
|
+
? date.toLocaleString('en-GB', { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', timeZone })
|
|
39
|
+
: date.toLocaleDateString('en-GB', { year: 'numeric', month: 'long', day: 'numeric', timeZone });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const items = articles.map(({ data: a }) => {
|
|
43
|
+
// Compare calendar days, not raw strings.
|
|
44
|
+
const updated = Boolean(a.dateModified && (!a.datePublished || a.dateModified.slice(0, 10) !== a.datePublished.slice(0, 10)));
|
|
45
|
+
const dateTime = (updated ? a.dateModified : a.datePublished) ?? '';
|
|
46
|
+
return {
|
|
47
|
+
href: url(`/articles/${a.slug}`),
|
|
48
|
+
title: a.title,
|
|
49
|
+
description: a.description,
|
|
50
|
+
author: a.author,
|
|
51
|
+
image: articleImages[a.slug],
|
|
52
|
+
imageAlt: a.imageAlt,
|
|
53
|
+
dateTime,
|
|
54
|
+
dateLabel: formatCardDate(dateTime),
|
|
55
|
+
updated,
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
<ArticleGrid articles={items} readLabel={readLabel} updatedLabel={updatedLabel} />
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
/** HomeTripPlanner — the home page's "Build your trip" band: one card per plan page, the featured one outlined. */
|
|
3
|
+
import { Container } from '@sarimarcus/content-sites-ui/layout';
|
|
4
|
+
import { url } from '@sarimarcus/content-sites-core/url';
|
|
5
|
+
|
|
6
|
+
export interface HomeTripPlannerCard {
|
|
7
|
+
title: string;
|
|
8
|
+
description: string;
|
|
9
|
+
href: string;
|
|
10
|
+
featured: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
cards: HomeTripPlannerCard[];
|
|
15
|
+
eyebrow?: string;
|
|
16
|
+
heading?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const { cards, eyebrow = 'Build your trip', heading = 'What shape is your visit taking?' } = Astro.props;
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
<section class="bg-chalk-warm border-b border-border py-12 lg:py-16">
|
|
23
|
+
<Container>
|
|
24
|
+
<div class="mb-6 text-center">
|
|
25
|
+
<p class="mb-2 text-sm font-medium uppercase tracking-[0.2em] text-primary">{eyebrow}</p>
|
|
26
|
+
<h2 class="text-2xl sm:text-3xl font-display font-normal text-foreground">{heading}</h2>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="mx-auto grid max-w-measure-wide gap-3 sm:grid-cols-2 xl:grid-cols-4">
|
|
29
|
+
{cards.map((card) => (
|
|
30
|
+
<a
|
|
31
|
+
href={url(card.href)}
|
|
32
|
+
class={`group rounded-2xl border border-border bg-card p-5 shadow-sm transition-[border-color,box-shadow,transform] duration-200 motion-safe:hover:-translate-y-1 hover:border-primary hover:shadow-lg focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 ${card.featured ? 'border-primary bg-primary/5' : ''}`}
|
|
33
|
+
>
|
|
34
|
+
<h3 class="mb-2 text-lg font-semibold font-display">{card.title}</h3>
|
|
35
|
+
<p class="text-sm leading-relaxed text-muted-foreground">{card.description}</p>
|
|
36
|
+
</a>
|
|
37
|
+
))}
|
|
38
|
+
</div>
|
|
39
|
+
</Container>
|
|
40
|
+
</section>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Monument body: lede + H2 sections with interludes between them, and a
|
|
4
|
+
* full-bleed `band` slot (the tour carousel) that breaks out of the measure
|
|
5
|
+
* column mid-body. Closes and reopens the measure Container around the band,
|
|
6
|
+
* so the caller must render it OUTSIDE any Container.
|
|
7
|
+
*
|
|
8
|
+
* Placement, in slot order (slot 0 = after the lede, slot N = after section N):
|
|
9
|
+
* - slot 0: VisitTiming (data-driven, every monument)
|
|
10
|
+
* - slot 1: the lead insider tip
|
|
11
|
+
* - authored `interludes[]` at their `afterSection`
|
|
12
|
+
* - the band after slot `pickBandSlot()` (core interludes), which avoids
|
|
13
|
+
* slots holding an authored interlude whenever a free one exists
|
|
14
|
+
*
|
|
15
|
+
* Markdown stays the site's: `renderMarkdown` renders the tip body, `renderInline` the interlude strings (wrapped in
|
|
16
|
+
* trustedHtml here), and `tagLinks` rewrites the section HTML (the site's affiliate tagging; identity by default).
|
|
17
|
+
*/
|
|
18
|
+
import { Container } from '@sarimarcus/content-sites-ui/layout';
|
|
19
|
+
import { pickBandSlot } from '@sarimarcus/content-sites-core/interludes';
|
|
20
|
+
import MonumentBodySlot from './MonumentBodySlot.astro';
|
|
21
|
+
import type { MonumentBodyContent, MonumentBodyLabels, MonumentBodyTip, MonumentBodyVisitTiming } from './monumentBody.ts';
|
|
22
|
+
|
|
23
|
+
interface Props {
|
|
24
|
+
body: MonumentBodyContent;
|
|
25
|
+
interludes?: any[];
|
|
26
|
+
visitTiming?: MonumentBodyVisitTiming;
|
|
27
|
+
leadTip?: MonumentBodyTip;
|
|
28
|
+
bandAfter?: number;
|
|
29
|
+
/** Whether the band renders. `Astro.slots.has` only says the slot was passed, not that it has content. */
|
|
30
|
+
hasBand?: boolean;
|
|
31
|
+
proseClass?: string;
|
|
32
|
+
renderMarkdown: (markdown: string) => string;
|
|
33
|
+
renderInline: (markdown: string) => string;
|
|
34
|
+
tagLinks?: (html: string, pathname: string) => string;
|
|
35
|
+
labels?: MonumentBodyLabels;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const {
|
|
39
|
+
body,
|
|
40
|
+
interludes = [],
|
|
41
|
+
visitTiming,
|
|
42
|
+
leadTip,
|
|
43
|
+
bandAfter = 2,
|
|
44
|
+
hasBand: bandEnabled = true,
|
|
45
|
+
proseClass = 'prose prose-lg max-w-none',
|
|
46
|
+
renderMarkdown,
|
|
47
|
+
renderInline,
|
|
48
|
+
tagLinks,
|
|
49
|
+
labels,
|
|
50
|
+
} = Astro.props;
|
|
51
|
+
|
|
52
|
+
const slotCount = body.sections.length + 1;
|
|
53
|
+
const clamp = (n: number) => Math.min(Math.max(n, 0), slotCount - 1);
|
|
54
|
+
const bySlot: any[][] = Array.from({ length: slotCount }, () => []);
|
|
55
|
+
for (const il of interludes) bySlot[clamp(il.afterSection)].push(il);
|
|
56
|
+
|
|
57
|
+
const tipSlot = clamp(1);
|
|
58
|
+
|
|
59
|
+
const bandSlot = pickBandSlot(body.sections.length, interludes, bandAfter);
|
|
60
|
+
const hasBand = bandEnabled && Astro.slots.has('band');
|
|
61
|
+
const firstSlots = hasBand ? bandSlot + 1 : slotCount;
|
|
62
|
+
|
|
63
|
+
const first = Array.from({ length: firstSlots }, (_, i) => i);
|
|
64
|
+
const rest = Array.from({ length: slotCount - firstSlots }, (_, i) => firstSlots + i);
|
|
65
|
+
const slotProps = (i: number) => ({
|
|
66
|
+
index: i,
|
|
67
|
+
section: i > 0 ? body.sections[i - 1] : undefined,
|
|
68
|
+
lede: i === 0 ? body.lede : undefined,
|
|
69
|
+
visitTiming: i === 0 ? visitTiming : undefined,
|
|
70
|
+
interludes: bySlot[i],
|
|
71
|
+
tip: i === tipSlot ? leadTip : undefined,
|
|
72
|
+
renderMarkdown,
|
|
73
|
+
renderInline,
|
|
74
|
+
tagLinks,
|
|
75
|
+
labels,
|
|
76
|
+
});
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
<Container size="measure">
|
|
80
|
+
<article id="description" class:list={[proseClass, 'scroll-mt-28']} data-pagefind-body>
|
|
81
|
+
{first.map((i) => <MonumentBodySlot {...slotProps(i)} />)}
|
|
82
|
+
</article>
|
|
83
|
+
</Container>
|
|
84
|
+
{hasBand && <slot name="band" />}
|
|
85
|
+
{rest.length > 0 && (
|
|
86
|
+
<Container size="measure">
|
|
87
|
+
<article class:list={[proseClass, 'mt-12']} data-pagefind-body>
|
|
88
|
+
{rest.map((i) => <MonumentBodySlot {...slotProps(i)} />)}
|
|
89
|
+
</article>
|
|
90
|
+
</Container>
|
|
91
|
+
)}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
/** One slot of MonumentBody: either the lede (index 0) or one H2 section, then whatever sits after it. */
|
|
3
|
+
import { Callout } from '@sarimarcus/content-sites-ui/primitives';
|
|
4
|
+
import { ComparisonTable, DidYouKnow, Quote, StatFact, Timeline, VisitTiming } from '@sarimarcus/content-sites-ui/editorial';
|
|
5
|
+
import { trustedHtml } from '@sarimarcus/content-sites-ui/types';
|
|
6
|
+
import type { MonumentBodyLabels, MonumentBodySection, MonumentBodyTip, MonumentBodyVisitTiming } from './monumentBody.ts';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
index: number;
|
|
10
|
+
section?: MonumentBodySection;
|
|
11
|
+
lede?: string;
|
|
12
|
+
visitTiming?: MonumentBodyVisitTiming;
|
|
13
|
+
interludes: any[];
|
|
14
|
+
tip?: MonumentBodyTip;
|
|
15
|
+
renderMarkdown: (markdown: string) => string;
|
|
16
|
+
renderInline: (markdown: string) => string;
|
|
17
|
+
tagLinks?: (html: string, pathname: string) => string;
|
|
18
|
+
labels?: MonumentBodyLabels;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const { section, lede, visitTiming, interludes, tip, renderMarkdown, renderInline, tagLinks, labels } = Astro.props;
|
|
22
|
+
const didYouKnowLabel = labels?.didYouKnow ?? 'Did you know?';
|
|
23
|
+
const timelineLabel = labels?.timeline ?? 'Timeline';
|
|
24
|
+
const pathname = Astro.url.pathname;
|
|
25
|
+
const md = (s: string | undefined) => trustedHtml(typeof s === 'string' ? renderInline(s) : '');
|
|
26
|
+
const tag = (html: string) => (tagLinks ? tagLinks(html, pathname) : html);
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
{section && (
|
|
30
|
+
<section id={section.id} data-guide-section class="scroll-mt-28">
|
|
31
|
+
<h2 set:html={section.headingHtml} />
|
|
32
|
+
<Fragment set:html={tag(section.html)} />
|
|
33
|
+
</section>
|
|
34
|
+
)}
|
|
35
|
+
{lede && <Fragment set:html={tag(lede)} />}
|
|
36
|
+
{visitTiming && (
|
|
37
|
+
<div class="not-prose">
|
|
38
|
+
<VisitTiming visitTiming={visitTiming} class="mt-12 !mt-10 mb-10" />
|
|
39
|
+
</div>
|
|
40
|
+
)}
|
|
41
|
+
{interludes.map((il) => (
|
|
42
|
+
<div class="not-prose">
|
|
43
|
+
{il.type === 'stat-fact' && <StatFact figure={md(il.figure)} caption={md(il.caption)} />}
|
|
44
|
+
{il.type === 'did-you-know' && <DidYouKnow content={md(il.content)} label={didYouKnowLabel} />}
|
|
45
|
+
{il.type === 'timeline' && (
|
|
46
|
+
<Timeline events={il.events.map((e: any) => ({ ...e, label: md(e.label), description: e.description ? md(e.description) : undefined }))} label={timelineLabel} />
|
|
47
|
+
)}
|
|
48
|
+
{il.type === 'quote' && (
|
|
49
|
+
<Quote
|
|
50
|
+
variant="pull"
|
|
51
|
+
content={md(il.content)}
|
|
52
|
+
attribution={il.attribution ? { name: md(il.attribution.name), role: il.attribution.role ? md(il.attribution.role) : undefined } : undefined}
|
|
53
|
+
/>
|
|
54
|
+
)}
|
|
55
|
+
{il.type === 'comparison-table' && (
|
|
56
|
+
<ComparisonTable headers={il.headers.map(md)} rows={il.rows.map((r: string[]) => r.map(md))} />
|
|
57
|
+
)}
|
|
58
|
+
</div>
|
|
59
|
+
))}
|
|
60
|
+
{tip && (
|
|
61
|
+
<div class="not-prose my-10">
|
|
62
|
+
<Callout type="tip" title={tip.title}>
|
|
63
|
+
<div class="[&_p]:m-0 [&_a]:text-primary [&_a]:underline" set:html={renderMarkdown(tip.body)} />
|
|
64
|
+
</Callout>
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
package/src/sections/index.ts
CHANGED
|
@@ -8,11 +8,20 @@ export { default as NeighborhoodHubHero } from './NeighborhoodHubHero.astro';
|
|
|
8
8
|
export { default as ItineraryTeaser } from './ItineraryTeaser.astro';
|
|
9
9
|
export { default as HomeMonuments } from './HomeMonuments.astro';
|
|
10
10
|
export { default as TourismNavigation } from './TourismNavigation.astro';
|
|
11
|
+
export { default as HomeTripPlanner } from './HomeTripPlanner.astro';
|
|
12
|
+
export { default as MonumentBody } from './MonumentBody.astro';
|
|
13
|
+
export { default as MonumentBodySlot } from './MonumentBodySlot.astro';
|
|
14
|
+
export { default as ArticleCardGrid } from './ArticleCardGrid.astro';
|
|
11
15
|
export type { WalkStop } from './WalkStops.astro';
|
|
12
16
|
export type { WhoItsForTag } from './WhoItsFor.astro';
|
|
13
17
|
export type { NeighborhoodCategoryType } from './NeighborhoodCategory.astro';
|
|
14
18
|
export type { SituationalScenario } from './SituationalNav.astro';
|
|
15
19
|
export type { HubCategoryPill } from './NeighborhoodHubHero.astro';
|
|
16
20
|
export type { ItineraryTeaserStop } from './ItineraryTeaser.astro';
|
|
21
|
+
export type { HomeTripPlannerCard } from './HomeTripPlanner.astro';
|
|
22
|
+
export type { ArticleCardGridEntry } from './ArticleCardGrid.astro';
|
|
23
|
+
export type {
|
|
24
|
+
MonumentBodyContent, MonumentBodySection, MonumentBodyVisitTiming, MonumentBodyTip, MonumentBodyLabels,
|
|
25
|
+
} from './monumentBody.ts';
|
|
17
26
|
export { navMonths, upcomingEventLinks } from './tourismNavigation.ts';
|
|
18
27
|
export type { TourismNavigationProps, TourismNavHubLink, TourismNavMonth, TourismNavDuration } from './tourismNavigation.ts';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Shapes MonumentBody and MonumentBodySlot take. Structural, so a site's own body splitter satisfies them.
|
|
2
|
+
|
|
3
|
+
export interface MonumentBodySection {
|
|
4
|
+
/** Anchor id, unique within the page. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Inline-rendered heading HTML for the `<h2>`. */
|
|
7
|
+
headingHtml: string;
|
|
8
|
+
/** Rendered HTML of the section body, heading line removed. */
|
|
9
|
+
html: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface MonumentBodyContent {
|
|
13
|
+
/** HTML for content before the first H2; `''` when the body opens with an H2. */
|
|
14
|
+
lede: string;
|
|
15
|
+
sections: MonumentBodySection[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface MonumentBodyVisitTiming {
|
|
19
|
+
bestSeason?: string;
|
|
20
|
+
quietestHours?: string;
|
|
21
|
+
visitDuration?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface MonumentBodyTip {
|
|
25
|
+
title: string;
|
|
26
|
+
/** Markdown, rendered by the caller's `renderMarkdown`. */
|
|
27
|
+
body: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface MonumentBodyLabels {
|
|
31
|
+
didYouKnow?: string;
|
|
32
|
+
timeline?: string;
|
|
33
|
+
}
|