ferst-core 0.14.0 → 0.16.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/README.md +13 -4
- package/bin/ferst-media.mjs +96 -0
- package/cms/config.template.yml +11 -0
- package/components/Card.astro +53 -51
- package/components/PostCard.astro +138 -136
- package/components/SiteHeader.astro +1356 -1273
- package/components/blocks/Grid.astro +49 -48
- package/components/blocks/Heading.astro +4 -1
- package/components/recipes/Banner.astro +146 -146
- package/components/recipes/Book.astro +39 -4
- package/components/recipes/FeatureCards.astro +112 -118
- package/components/recipes/Gallery.astro +57 -59
- package/components/recipes/Hero.astro +638 -533
- package/components/recipes/LatestPosts.astro +295 -292
- package/components/recipes/Locations.astro +146 -143
- package/components/recipes/Marquee.astro +75 -75
- package/components/recipes/MediaCards.astro +213 -219
- package/components/recipes/Pricing.astro +149 -150
- package/components/recipes/Stats.astro +150 -157
- package/components/recipes/Tiles.astro +342 -296
- package/content/blocks.ts +1072 -1024
- package/content/imageSlots.mjs +542 -0
- package/content/schemas.ts +35 -2
- package/examples/recipes.ts +4 -0
- package/fonts/OFL.txt +1332 -287
- package/fonts/anton-latin-400-normal.woff2 +0 -0
- package/fonts/bangers-latin-400-normal.woff2 +0 -0
- package/fonts/bebas-neue-latin-400-normal.woff2 +0 -0
- package/fonts/bowlby-one-latin-400-normal.woff2 +0 -0
- package/fonts/fredoka-latin-400-normal.woff2 +0 -0
- package/fonts/fredoka-latin-600-normal.woff2 +0 -0
- package/fonts/fredoka-latin-700-normal.woff2 +0 -0
- package/fonts/knewave-latin-400-normal.woff2 +0 -0
- package/fonts/lora-latin-400-normal.woff2 +0 -0
- package/fonts/lora-latin-600-normal.woff2 +0 -0
- package/fonts/lora-latin-700-normal.woff2 +0 -0
- package/fonts/merriweather-latin-400-normal.woff2 +0 -0
- package/fonts/merriweather-latin-600-normal.woff2 +0 -0
- package/fonts/merriweather-latin-700-normal.woff2 +0 -0
- package/fonts/nunito-latin-400-normal.woff2 +0 -0
- package/fonts/nunito-latin-600-normal.woff2 +0 -0
- package/fonts/nunito-latin-700-normal.woff2 +0 -0
- package/fonts/oswald-latin-400-normal.woff2 +0 -0
- package/fonts/oswald-latin-600-normal.woff2 +0 -0
- package/fonts/oswald-latin-700-normal.woff2 +0 -0
- package/fonts/rubik-dirt-latin-400-normal.woff2 +0 -0
- package/integration.mjs +253 -249
- package/layouts/Base.astro +13 -3
- package/lib/book.ts +94 -1
- package/lib/fonts.ts +130 -0
- package/lib/gridRows.ts +197 -0
- package/lib/image-fields.ts +140 -0
- package/lib/image-size.mjs +108 -0
- package/lib/image-sizes.ts +16 -0
- package/lib/logo-header.ts +46 -0
- package/lib/media-check.mjs +524 -0
- package/lib/theme-preview.ts +203 -140
- package/lib/themeTokens.ts +235 -220
- package/package.json +3 -2
- package/styles/fonts.css +239 -76
- package/styles/theme.css +228 -160
- package/lib/gridColumns.ts +0 -22
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
---
|
|
2
|
-
/** A layout container: places child blocks in a responsive N
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
---
|
|
2
|
+
/** A layout container: places child blocks in a responsive grid of up to N columns, its
|
|
3
|
+
* rows planned per screen width like every other grid (lib/gridRows): one to a row on
|
|
4
|
+
* phones, two on tablets, N on desktops, a shorter row filled or centred. Each child sits
|
|
5
|
+
* in a cell that carries its placement; the cell is a one-track grid itself, so the child
|
|
6
|
+
* fills it exactly as it filled the grid's track before. */
|
|
7
|
+
import BlockRenderer from '../BlockRenderer.astro';
|
|
8
|
+
import { planGrid } from '../../lib/gridRows';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
columns?: 2 | 3 | 4;
|
|
12
|
+
gap?: 'sm' | 'md' | 'lg';
|
|
13
|
+
blocks?: any[];
|
|
14
|
+
/** How the ragged last row lays out (lib/gridRows). */
|
|
15
|
+
lastRow?: 'auto' | 'fill' | 'center';
|
|
16
|
+
}
|
|
17
|
+
const { columns = 2, gap = 'md', blocks = [], lastRow = 'auto' } = Astro.props;
|
|
18
|
+
// Only the blocks that render take a cell.
|
|
19
|
+
const shown = blocks.filter((b) => b && b.enabled !== false);
|
|
20
|
+
const rows = planGrid(shown.length, { columns, item: 'grid', lastRow });
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
<div class="b-grid ferst-rows" data-cols={rows.cols} data-gap={gap} style={rows.gridStyle}>
|
|
24
|
+
{shown.map((block, i) => (
|
|
25
|
+
<div class="b-grid__cell" style={rows.itemStyles[i]}>
|
|
26
|
+
<BlockRenderer blocks={[block]} />
|
|
27
|
+
</div>
|
|
28
|
+
))}
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
.b-grid {
|
|
33
|
+
display: grid;
|
|
34
|
+
}
|
|
35
|
+
.b-grid[data-gap='sm'] {
|
|
36
|
+
gap: 0.75rem;
|
|
37
|
+
}
|
|
38
|
+
.b-grid[data-gap='md'] {
|
|
39
|
+
gap: 1.5rem;
|
|
40
|
+
}
|
|
41
|
+
.b-grid[data-gap='lg'] {
|
|
42
|
+
gap: 3rem;
|
|
43
|
+
}
|
|
44
|
+
/* Rows come from lib/gridRows (the global .ferst-rows rules). */
|
|
45
|
+
.b-grid__cell {
|
|
46
|
+
display: grid;
|
|
47
|
+
min-width: 0;
|
|
48
|
+
}
|
|
49
|
+
</style>
|
|
@@ -10,9 +10,12 @@ const { text, level = 2, align, gradient = false } = Astro.props;
|
|
|
10
10
|
const Tag = `h${level}` as unknown as keyof HTMLElementTagNameMap;
|
|
11
11
|
// A readable, page-unique anchor so any heading can be linked to (#mass-times).
|
|
12
12
|
const id = uniqueSlug(text, pageSlugs(Astro.locals));
|
|
13
|
+
// A recipe can draw the heading as something else (a hero's wordmark picture, described by
|
|
14
|
+
// `text`); the heading, its anchor and its level stay the same.
|
|
15
|
+
const drawn = Astro.slots.has('default') ? (await Astro.slots.render('default')).trim() : '';
|
|
13
16
|
---
|
|
14
17
|
|
|
15
|
-
<Tag class="b-heading" id={id} data-align={align} data-gradient={gradient ? 'true' : 'false'}>{text}</Tag>
|
|
18
|
+
<Tag class="b-heading" id={id} data-align={align} data-gradient={gradient ? 'true' : 'false'}>{drawn ? <Fragment set:html={drawn} /> : text}</Tag>
|
|
16
19
|
|
|
17
20
|
<style>
|
|
18
21
|
/* By default a heading INHERITS the page/section content alignment (the
|
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
---
|
|
2
|
-
/**
|
|
3
|
-
* Banner — a Level-2 recipe: a full-bleed feature band with a fixed/parallax
|
|
4
|
-
* background image, a legibility scrim, and a floating "shaded" content card
|
|
5
|
-
* over it. Composes Heading + Button.
|
|
6
|
-
*
|
|
7
|
-
* Parallax is pure CSS (`background-attachment: fixed`) — no JS, GPU-composited.
|
|
8
|
-
* It's auto-disabled on touch/coarse pointers (where `fixed` is janky or ignored,
|
|
9
|
-
* e.g. iOS) and under `prefers-reduced-motion`, both falling back to a clean
|
|
10
|
-
* `scroll` background. The card uses the surface tokens (radius, shadow) so it
|
|
11
|
-
* matches every other surface, and a backdrop blur for the "shaded glass" look.
|
|
12
|
-
*/
|
|
13
|
-
import Heading from '../blocks/Heading.astro';
|
|
14
|
-
import Button from '../Button.astro';
|
|
15
|
-
|
|
16
|
-
interface Props {
|
|
17
|
-
image: string;
|
|
18
|
-
eyebrow?: string;
|
|
19
|
-
title: string;
|
|
20
|
-
text?: string;
|
|
21
|
-
cta?: { label: string; href: string };
|
|
22
|
-
overlay?: number;
|
|
23
|
-
align?: 'start' | 'center' | 'end';
|
|
24
|
-
parallax?: boolean;
|
|
25
|
-
fullBleed?: boolean;
|
|
26
|
-
}
|
|
27
|
-
const { image, eyebrow, title, text, cta, overlay = 50, align = 'start', parallax = true, fullBleed = false } = Astro.props;
|
|
28
|
-
const scrim = overlay / 100;
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
<section
|
|
32
|
-
class="b-banner"
|
|
33
|
-
data-align={align}
|
|
34
|
-
data-parallax={parallax ? 'true' : 'false'}
|
|
35
|
-
data-full-bleed={fullBleed ? 'true' : 'false'}
|
|
36
|
-
style={`--banner-image: url('${image}'); --banner-scrim: ${scrim};`}
|
|
37
|
-
>
|
|
38
|
-
<div class="b-banner__scrim" aria-hidden="true"></div>
|
|
39
|
-
<div class="b-banner__card">
|
|
40
|
-
{eyebrow && <p class="b-banner__eyebrow">{eyebrow}</p>}
|
|
41
|
-
<Heading text={title} level={2} align="start" />
|
|
42
|
-
{text && <p class="b-banner__text">{text}</p>}
|
|
43
|
-
{cta && (
|
|
44
|
-
<div class="b-banner__cta">
|
|
45
|
-
<Button href={cta.href} variant="cta">{cta.label}</Button>
|
|
46
|
-
</div>
|
|
47
|
-
)}
|
|
48
|
-
</div>
|
|
49
|
-
</section>
|
|
50
|
-
|
|
51
|
-
<style>
|
|
52
|
-
.b-banner {
|
|
53
|
-
position: relative;
|
|
54
|
-
isolation: isolate;
|
|
55
|
-
display: grid;
|
|
56
|
-
padding: clamp(3rem, 9vw, 7rem) clamp(1.25rem, 5vw, 4rem);
|
|
57
|
-
min-height: min(60vh, 34rem);
|
|
58
|
-
border-radius: var(--radius);
|
|
59
|
-
overflow: hidden;
|
|
60
|
-
background-image: var(--banner-image);
|
|
61
|
-
background-size: cover;
|
|
62
|
-
background-position: center;
|
|
63
|
-
background-repeat: no-repeat;
|
|
64
|
-
}
|
|
65
|
-
/* Full-bleed: break out of the content column to the full viewport width, edges
|
|
66
|
-
squared off. Safe from a horizontal scrollbar because Base sets overflow-x:
|
|
67
|
-
clip on html/body. The card keeps a comfortable inset that tracks the content
|
|
68
|
-
column on wide screens, so it still lines up with the page below. */
|
|
69
|
-
.b-banner[data-full-bleed='true'] {
|
|
70
|
-
width: 100vw;
|
|
71
|
-
margin-inline: calc(50% - 50vw);
|
|
72
|
-
border-radius: 0;
|
|
73
|
-
padding-inline: max(clamp(1.25rem, 5vw, 4rem), calc((100vw - 72rem) / 2 + 2rem));
|
|
74
|
-
}
|
|
75
|
-
/* Parallax: pin the image to the viewport so it slides under the content.
|
|
76
|
-
Only on fine pointers with motion allowed — `fixed` is ignored/janky on
|
|
77
|
-
touch (iOS) and unwelcome under reduced-motion. */
|
|
78
|
-
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
|
|
79
|
-
.b-banner[data-parallax='true'] {
|
|
80
|
-
background-attachment: fixed;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.b-banner[data-align='start'] { justify-items: start; }
|
|
85
|
-
.b-banner[data-align='center'] { justify-items: center; text-align: center; }
|
|
86
|
-
.b-banner[data-align='end'] { justify-items: end; }
|
|
87
|
-
|
|
88
|
-
.b-banner__scrim {
|
|
89
|
-
position: absolute;
|
|
90
|
-
inset: 0;
|
|
91
|
-
z-index: -1;
|
|
92
|
-
background: linear-gradient(to top, rgba(8, 10, 18, calc(var(--banner-scrim) + 0.2)), rgba(8, 10, 18, var(--banner-scrim)));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/* The floating "shaded glass" card. */
|
|
96
|
-
.b-banner__card {
|
|
97
|
-
max-width: 34rem;
|
|
98
|
-
display: flex;
|
|
99
|
-
flex-direction: column;
|
|
100
|
-
gap: 1rem;
|
|
101
|
-
padding: clamp(1.5rem, 3vw, 2.25rem);
|
|
102
|
-
border-radius: var(--radius);
|
|
103
|
-
background: color-mix(in srgb, var(--bg-surface) 82%, transparent);
|
|
104
|
-
border: var(--card-border);
|
|
105
|
-
box-shadow: var(--shadow-lg);
|
|
106
|
-
-webkit-backdrop-filter: blur(10px);
|
|
107
|
-
backdrop-filter: blur(10px);
|
|
108
|
-
color: var(--fg);
|
|
109
|
-
}
|
|
110
|
-
.b-banner__eyebrow {
|
|
111
|
-
margin: 0;
|
|
112
|
-
text-transform: uppercase;
|
|
113
|
-
letter-spacing: 0.12em;
|
|
114
|
-
font-size: 0.8125rem;
|
|
115
|
-
font-weight: 700;
|
|
116
|
-
color: var(--gold);
|
|
117
|
-
}
|
|
118
|
-
.b-banner__text {
|
|
119
|
-
margin: 0;
|
|
120
|
-
color: var(--muted);
|
|
121
|
-
line-height: 1.65;
|
|
122
|
-
}
|
|
123
|
-
.b-banner__cta {
|
|
124
|
-
margin-top: 0.25rem;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/* Multi-layer parallax: the background is pinned (fixed), and the card itself
|
|
128
|
-
drifts at a different rate as the banner scrolls through view — two layers,
|
|
129
|
-
two speeds. Native scroll-timeline, so no JS; off under reduced-motion or
|
|
130
|
-
where unsupported (the card just sits still). Transforming the card is safe:
|
|
131
|
-
it's not an ancestor of the fixed background. */
|
|
132
|
-
@media (prefers-reduced-motion: no-preference) {
|
|
133
|
-
@supports (animation-timeline: view()) {
|
|
134
|
-
.b-banner__card {
|
|
135
|
-
animation: b-banner-drift linear both;
|
|
136
|
-
animation-timeline: view();
|
|
137
|
-
animation-range: cover;
|
|
138
|
-
will-change: transform;
|
|
139
|
-
}
|
|
140
|
-
@keyframes b-banner-drift {
|
|
141
|
-
from { transform: translateY(48px); }
|
|
142
|
-
to { transform: translateY(-48px); }
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
</style>
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Banner — a Level-2 recipe: a full-bleed feature band with a fixed/parallax
|
|
4
|
+
* background image, a legibility scrim, and a floating "shaded" content card
|
|
5
|
+
* over it. Composes Heading + Button.
|
|
6
|
+
*
|
|
7
|
+
* Parallax is pure CSS (`background-attachment: fixed`) — no JS, GPU-composited.
|
|
8
|
+
* It's auto-disabled on touch/coarse pointers (where `fixed` is janky or ignored,
|
|
9
|
+
* e.g. iOS) and under `prefers-reduced-motion`, both falling back to a clean
|
|
10
|
+
* `scroll` background. The card uses the surface tokens (radius, shadow) so it
|
|
11
|
+
* matches every other surface, and a backdrop blur for the "shaded glass" look.
|
|
12
|
+
*/
|
|
13
|
+
import Heading from '../blocks/Heading.astro';
|
|
14
|
+
import Button from '../Button.astro';
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
image: string;
|
|
18
|
+
eyebrow?: string;
|
|
19
|
+
title: string;
|
|
20
|
+
text?: string;
|
|
21
|
+
cta?: { label: string; href: string };
|
|
22
|
+
overlay?: number;
|
|
23
|
+
align?: 'start' | 'center' | 'end';
|
|
24
|
+
parallax?: boolean;
|
|
25
|
+
fullBleed?: boolean;
|
|
26
|
+
}
|
|
27
|
+
const { image, eyebrow, title, text, cta, overlay = 50, align = 'start', parallax = true, fullBleed = false } = Astro.props;
|
|
28
|
+
const scrim = overlay / 100;
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
<section
|
|
32
|
+
class="b-banner"
|
|
33
|
+
data-align={align}
|
|
34
|
+
data-parallax={parallax ? 'true' : 'false'}
|
|
35
|
+
data-full-bleed={fullBleed ? 'true' : 'false'}
|
|
36
|
+
style={`--banner-image: url('${image}'); --banner-scrim: ${scrim};`}
|
|
37
|
+
>
|
|
38
|
+
<div class="b-banner__scrim" aria-hidden="true"></div>
|
|
39
|
+
<div class="b-banner__card" data-display-title>
|
|
40
|
+
{eyebrow && <p class="b-banner__eyebrow">{eyebrow}</p>}
|
|
41
|
+
<Heading text={title} level={2} align="start" />
|
|
42
|
+
{text && <p class="b-banner__text">{text}</p>}
|
|
43
|
+
{cta && (
|
|
44
|
+
<div class="b-banner__cta">
|
|
45
|
+
<Button href={cta.href} variant="cta">{cta.label}</Button>
|
|
46
|
+
</div>
|
|
47
|
+
)}
|
|
48
|
+
</div>
|
|
49
|
+
</section>
|
|
50
|
+
|
|
51
|
+
<style>
|
|
52
|
+
.b-banner {
|
|
53
|
+
position: relative;
|
|
54
|
+
isolation: isolate;
|
|
55
|
+
display: grid;
|
|
56
|
+
padding: clamp(3rem, 9vw, 7rem) clamp(1.25rem, 5vw, 4rem);
|
|
57
|
+
min-height: min(60vh, 34rem);
|
|
58
|
+
border-radius: var(--radius);
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
background-image: var(--banner-image);
|
|
61
|
+
background-size: cover;
|
|
62
|
+
background-position: center;
|
|
63
|
+
background-repeat: no-repeat;
|
|
64
|
+
}
|
|
65
|
+
/* Full-bleed: break out of the content column to the full viewport width, edges
|
|
66
|
+
squared off. Safe from a horizontal scrollbar because Base sets overflow-x:
|
|
67
|
+
clip on html/body. The card keeps a comfortable inset that tracks the content
|
|
68
|
+
column on wide screens, so it still lines up with the page below. */
|
|
69
|
+
.b-banner[data-full-bleed='true'] {
|
|
70
|
+
width: 100vw;
|
|
71
|
+
margin-inline: calc(50% - 50vw);
|
|
72
|
+
border-radius: 0;
|
|
73
|
+
padding-inline: max(clamp(1.25rem, 5vw, 4rem), calc((100vw - 72rem) / 2 + 2rem));
|
|
74
|
+
}
|
|
75
|
+
/* Parallax: pin the image to the viewport so it slides under the content.
|
|
76
|
+
Only on fine pointers with motion allowed — `fixed` is ignored/janky on
|
|
77
|
+
touch (iOS) and unwelcome under reduced-motion. */
|
|
78
|
+
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
|
|
79
|
+
.b-banner[data-parallax='true'] {
|
|
80
|
+
background-attachment: fixed;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.b-banner[data-align='start'] { justify-items: start; }
|
|
85
|
+
.b-banner[data-align='center'] { justify-items: center; text-align: center; }
|
|
86
|
+
.b-banner[data-align='end'] { justify-items: end; }
|
|
87
|
+
|
|
88
|
+
.b-banner__scrim {
|
|
89
|
+
position: absolute;
|
|
90
|
+
inset: 0;
|
|
91
|
+
z-index: -1;
|
|
92
|
+
background: linear-gradient(to top, rgba(8, 10, 18, calc(var(--banner-scrim) + 0.2)), rgba(8, 10, 18, var(--banner-scrim)));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* The floating "shaded glass" card. */
|
|
96
|
+
.b-banner__card {
|
|
97
|
+
max-width: 34rem;
|
|
98
|
+
display: flex;
|
|
99
|
+
flex-direction: column;
|
|
100
|
+
gap: 1rem;
|
|
101
|
+
padding: clamp(1.5rem, 3vw, 2.25rem);
|
|
102
|
+
border-radius: var(--radius);
|
|
103
|
+
background: color-mix(in srgb, var(--bg-surface) 82%, transparent);
|
|
104
|
+
border: var(--card-border);
|
|
105
|
+
box-shadow: var(--shadow-lg);
|
|
106
|
+
-webkit-backdrop-filter: blur(10px);
|
|
107
|
+
backdrop-filter: blur(10px);
|
|
108
|
+
color: var(--fg);
|
|
109
|
+
}
|
|
110
|
+
.b-banner__eyebrow {
|
|
111
|
+
margin: 0;
|
|
112
|
+
text-transform: uppercase;
|
|
113
|
+
letter-spacing: 0.12em;
|
|
114
|
+
font-size: 0.8125rem;
|
|
115
|
+
font-weight: 700;
|
|
116
|
+
color: var(--gold);
|
|
117
|
+
}
|
|
118
|
+
.b-banner__text {
|
|
119
|
+
margin: 0;
|
|
120
|
+
color: var(--muted);
|
|
121
|
+
line-height: 1.65;
|
|
122
|
+
}
|
|
123
|
+
.b-banner__cta {
|
|
124
|
+
margin-top: 0.25rem;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* Multi-layer parallax: the background is pinned (fixed), and the card itself
|
|
128
|
+
drifts at a different rate as the banner scrolls through view — two layers,
|
|
129
|
+
two speeds. Native scroll-timeline, so no JS; off under reduced-motion or
|
|
130
|
+
where unsupported (the card just sits still). Transforming the card is safe:
|
|
131
|
+
it's not an ancestor of the fixed background. */
|
|
132
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
133
|
+
@supports (animation-timeline: view()) {
|
|
134
|
+
.b-banner__card {
|
|
135
|
+
animation: b-banner-drift linear both;
|
|
136
|
+
animation-timeline: view();
|
|
137
|
+
animation-range: cover;
|
|
138
|
+
will-change: transform;
|
|
139
|
+
}
|
|
140
|
+
@keyframes b-banner-drift {
|
|
141
|
+
from { transform: translateY(48px); }
|
|
142
|
+
to { transform: translateY(-48px); }
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
@@ -28,8 +28,10 @@
|
|
|
28
28
|
*/
|
|
29
29
|
import ContactForm from './ContactForm.astro';
|
|
30
30
|
import Heading from '../blocks/Heading.astro';
|
|
31
|
-
import { bookTarget, loadBookResource, loadBookService, metaLine, whereText, type BookService, type BookWho } from '../../lib/book';
|
|
31
|
+
import { bookTarget, eventsData, ldJson, loadBookResource, loadBookService, loadEventDates, metaLine, whereText, type BookService, type BookWho, type EventsContext } from '../../lib/book';
|
|
32
32
|
import { resolveGitBase, resolveSiteId } from '../../lib/git-base.mjs';
|
|
33
|
+
import { canonicalUrl } from '../../lib/seo.mjs';
|
|
34
|
+
import { loadSiteSettings } from '../../lib/siteSettings';
|
|
33
35
|
|
|
34
36
|
interface Props {
|
|
35
37
|
service?: string;
|
|
@@ -84,6 +86,29 @@ const many = !list && offers.length > 1;
|
|
|
84
86
|
const panels = list ? [lead] : offers;
|
|
85
87
|
const sources = list ? JSON.stringify(offers.map((o) => ({ book: o.definition, event: o.event ?? '' }))) : undefined;
|
|
86
88
|
const placeOf = (d: BookService) => d.resources.find((r) => r.kind === 'place')?.name ?? '';
|
|
89
|
+
|
|
90
|
+
// For search engines (0.15.0; myai4-webdev docs/EVENTS.md slice 6d): each coming date of a class or an
|
|
91
|
+
// event as a schema.org Event, once the site has an address (as all its structured data, Base.astro).
|
|
92
|
+
// Read at build, and brought up to date as the page loads. A preview (no site address) has none.
|
|
93
|
+
const siteUrl = (import.meta.env.FERST_SITE_URL as string | undefined) || '';
|
|
94
|
+
let ldContext: EventsContext | null = null;
|
|
95
|
+
if (siteUrl) {
|
|
96
|
+
const settings = await loadSiteSettings().catch(() => null);
|
|
97
|
+
ldContext = {
|
|
98
|
+
url: `${canonicalUrl(siteUrl, Astro.url?.pathname ?? '/')}#${anchor}`,
|
|
99
|
+
organisation: { name: settings?.identity?.siteTitle, url: `${siteUrl.replace(/\/+$/, '')}/` },
|
|
100
|
+
places: (settings?.places ?? []) as EventsContext['places'],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const ldOf = async (def: BookService): Promise<string | null> => {
|
|
104
|
+
if (!ldContext || def.mode !== 'places') return null;
|
|
105
|
+
const dates = list
|
|
106
|
+
? (await Promise.all(offers.map((o) => loadEventDates(o.definition, { event: o.event })))).flat().sort((a, b) => a.start.localeCompare(b.start))
|
|
107
|
+
: await loadEventDates(def.definition, { event: def.event, resource: def.resource });
|
|
108
|
+
const data = eventsData(dates, ldContext);
|
|
109
|
+
return data ? ldJson(data) : null;
|
|
110
|
+
};
|
|
111
|
+
const lds = await Promise.all(panels.map(ldOf));
|
|
87
112
|
---
|
|
88
113
|
|
|
89
114
|
<section class="b-book" id={anchor} data-book-block data-demo={demo ? '1' : undefined} data-find={`${base}/sites/${encodeURIComponent(siteId ?? '')}/book/find`}>
|
|
@@ -116,6 +141,7 @@ const placeOf = (d: BookService) => d.resources.find((r) => r.kind === 'place')?
|
|
|
116
141
|
data-list={sources}
|
|
117
142
|
data-look={one ? 'button' : undefined} data-date={one ? date ?? '' : undefined}
|
|
118
143
|
data-with={whereText(def.resources)} hidden={i > 0}>
|
|
144
|
+
{lds[i] && <script type="application/ld+json" is:inline data-book-ld data-ctx={JSON.stringify(ldContext)} set:html={lds[i]} />}
|
|
119
145
|
{many && def.description && <p class="b-book__intro">{def.description}</p>}
|
|
120
146
|
<div class="b-book__notice" role="alert" data-book-error hidden></div>
|
|
121
147
|
|
|
@@ -193,7 +219,7 @@ const placeOf = (d: BookService) => d.resources.find((r) => r.kind === 'place')?
|
|
|
193
219
|
</section>
|
|
194
220
|
|
|
195
221
|
<script>
|
|
196
|
-
import { addDays, bookingMessage, calendarFile, dayChip, endChoices, googleCalendarLink, londonDay, whenText, whichFree, type EventDate, type TimesAnswer } from '../../lib/book';
|
|
222
|
+
import { addDays, bookingMessage, calendarFile, dayChip, endChoices, eventsData, googleCalendarLink, londonDay, whenText, whichFree, type EventDate, type EventsContext, type TimesAnswer } from '../../lib/book';
|
|
197
223
|
|
|
198
224
|
const SPAN = 14; // days shown at once (dates for a class: four weeks)
|
|
199
225
|
const AHEAD = 60; // how far ahead the platform takes bookings
|
|
@@ -368,6 +394,15 @@ const placeOf = (d: BookService) => d.resources.find((r) => r.kind === 'place')?
|
|
|
368
394
|
if (holdBtn && mode === 'places' && !one) { const n = Math.max(1, Number(count!.value) || 1); holdBtn.textContent = `Hold ${n === 1 ? 'this place' : `${n} places`}`; }
|
|
369
395
|
}
|
|
370
396
|
|
|
397
|
+
/** The page's dates for search engines, brought up to date (the places left) from what's just been read. */
|
|
398
|
+
function freshForSearch() {
|
|
399
|
+
const ld = block.querySelector<HTMLScriptElement>('script[data-book-ld]');
|
|
400
|
+
if (!ld || !answer || from !== today) return;
|
|
401
|
+
const data = eventsData(answer.events ?? [], JSON.parse(ld.dataset.ctx ?? '{}') as EventsContext);
|
|
402
|
+
if (data) ld.textContent = JSON.stringify(data);
|
|
403
|
+
else ld.remove();
|
|
404
|
+
}
|
|
405
|
+
|
|
371
406
|
async function load() {
|
|
372
407
|
say(null);
|
|
373
408
|
timesEl.innerHTML = `<p class="b-book__empty">${mode === 'places' ? 'Loading dates…' : 'Loading free times…'}</p>`;
|
|
@@ -380,7 +415,7 @@ const placeOf = (d: BookService) => d.resources.find((r) => r.kind === 'place')?
|
|
|
380
415
|
}));
|
|
381
416
|
answer = { service: { id: '', name: block.dataset.name ?? '', minutes }, resources: [], days: [], events: all.flat().sort((a, b) => a.start.localeCompare(b.start)) };
|
|
382
417
|
start = null; date = null;
|
|
383
|
-
drawDays(); drawTimes();
|
|
418
|
+
drawDays(); drawTimes(); freshForSearch();
|
|
384
419
|
return;
|
|
385
420
|
}
|
|
386
421
|
const res = await fetch(`${src}?from=${from}&to=${addDays(from, span)}${onlyEvent ? `&event=${encodeURIComponent(onlyEvent)}` : ''}${onlyWith ? `&resource=${encodeURIComponent(onlyWith)}` : ''}`, { headers: { Accept: 'application/json' } });
|
|
@@ -388,7 +423,7 @@ const placeOf = (d: BookService) => d.resources.find((r) => r.kind === 'place')?
|
|
|
388
423
|
answer = (await res.json()) as TimesAnswer;
|
|
389
424
|
day = answer.days.find((d) => free(d.day).length)?.day ?? null;
|
|
390
425
|
start = null; date = null;
|
|
391
|
-
drawDays(); drawTimes();
|
|
426
|
+
drawDays(); drawTimes(); freshForSearch();
|
|
392
427
|
} catch (e) {
|
|
393
428
|
timesEl.innerHTML = '';
|
|
394
429
|
say(bookingMessage(e instanceof Error ? e.message : ''));
|