ferst-core 0.15.0 → 0.17.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.
Files changed (74) hide show
  1. package/NOTICE +63 -31
  2. package/README.md +13 -4
  3. package/bin/ferst-media.mjs +96 -0
  4. package/bin/ferst-modules.mjs +17 -2
  5. package/components/BlockRenderer.astro +131 -129
  6. package/components/Card.astro +53 -51
  7. package/components/MembersAccount.astro +370 -0
  8. package/components/PostCard.astro +138 -136
  9. package/components/SiteHeader.astro +32 -14
  10. package/components/blocks/Grid.astro +49 -48
  11. package/components/blocks/Heading.astro +4 -1
  12. package/components/islands/BookMonth.tsx +95 -0
  13. package/components/islands/MembersAccount.tsx +392 -0
  14. package/components/recipes/Banner.astro +146 -146
  15. package/components/recipes/Book.astro +1147 -926
  16. package/components/recipes/FeatureCards.astro +112 -118
  17. package/components/recipes/Gallery.astro +57 -59
  18. package/components/recipes/Hero.astro +112 -10
  19. package/components/recipes/LatestPosts.astro +295 -292
  20. package/components/recipes/Locations.astro +146 -143
  21. package/components/recipes/Marquee.astro +75 -75
  22. package/components/recipes/MediaCards.astro +213 -219
  23. package/components/recipes/MembersContent.astro +176 -0
  24. package/components/recipes/Pricing.astro +149 -150
  25. package/components/recipes/Stats.astro +150 -157
  26. package/components/recipes/Tiles.astro +342 -296
  27. package/content/blocks.ts +1091 -1024
  28. package/content/cookies.ts +14 -0
  29. package/content/imageSlots.mjs +542 -0
  30. package/content/recipe-questions.ts +81 -80
  31. package/content/schemas.ts +13 -11
  32. package/examples/recipes.ts +5 -0
  33. package/fonts/OFL.txt +1332 -287
  34. package/fonts/anton-latin-400-normal.woff2 +0 -0
  35. package/fonts/bangers-latin-400-normal.woff2 +0 -0
  36. package/fonts/bebas-neue-latin-400-normal.woff2 +0 -0
  37. package/fonts/bowlby-one-latin-400-normal.woff2 +0 -0
  38. package/fonts/fredoka-latin-400-normal.woff2 +0 -0
  39. package/fonts/fredoka-latin-600-normal.woff2 +0 -0
  40. package/fonts/fredoka-latin-700-normal.woff2 +0 -0
  41. package/fonts/knewave-latin-400-normal.woff2 +0 -0
  42. package/fonts/lora-latin-400-normal.woff2 +0 -0
  43. package/fonts/lora-latin-600-normal.woff2 +0 -0
  44. package/fonts/lora-latin-700-normal.woff2 +0 -0
  45. package/fonts/merriweather-latin-400-normal.woff2 +0 -0
  46. package/fonts/merriweather-latin-600-normal.woff2 +0 -0
  47. package/fonts/merriweather-latin-700-normal.woff2 +0 -0
  48. package/fonts/nunito-latin-400-normal.woff2 +0 -0
  49. package/fonts/nunito-latin-600-normal.woff2 +0 -0
  50. package/fonts/nunito-latin-700-normal.woff2 +0 -0
  51. package/fonts/oswald-latin-400-normal.woff2 +0 -0
  52. package/fonts/oswald-latin-600-normal.woff2 +0 -0
  53. package/fonts/oswald-latin-700-normal.woff2 +0 -0
  54. package/fonts/rubik-dirt-latin-400-normal.woff2 +0 -0
  55. package/integration.mjs +319 -263
  56. package/layouts/Base.astro +8 -16
  57. package/lib/book.ts +416 -378
  58. package/lib/fonts.ts +130 -0
  59. package/lib/gridRows.ts +197 -0
  60. package/lib/image-fields.ts +140 -0
  61. package/lib/image-size.mjs +108 -73
  62. package/lib/image-sizes.ts +16 -0
  63. package/lib/logo-header.ts +46 -0
  64. package/lib/media-check.mjs +524 -0
  65. package/lib/members-account.ts +276 -0
  66. package/lib/members.ts +115 -0
  67. package/lib/theme-preview.ts +203 -140
  68. package/lib/themeTokens.ts +235 -220
  69. package/package.json +80 -71
  70. package/routes/account.astro +16 -0
  71. package/routes/cookie-policy.astro +28 -28
  72. package/styles/fonts.css +239 -76
  73. package/styles/theme.css +228 -160
  74. package/lib/gridColumns.ts +0 -22
@@ -1,219 +1,213 @@
1
- ---
2
- /**
3
- * MediaCards — a Level-2 recipe: a grid of rich content cards with the IMAGE as a
4
- * header on top (cover-cropped to a uniform ratio, like PostCard), then an optional
5
- * icon badge, a title, a meta line (e.g. "Sundays 10:45 · Main hall"), a description, and
6
- * an optional CTA link. The image-HEADER pattern (distinct from `tiles`, which puts
7
- * the image BEHIND the text): use it for groups, team members, services or events —
8
- * anywhere the photo and the copy both need to be fully legible. Whole card links
9
- * when `href` is set. Token-driven, equal-height.
10
- */
11
- import Icon from '../Icon.astro';
12
- import { gridColumns } from '../../lib/gridColumns';
13
- import { isIconKey } from '../../lib/icons';
14
- import Heading from '../blocks/Heading.astro';
15
-
16
- import { inlineMarkdown, inlineMarkdownNoLinks } from '../../lib/inline-markdown';
17
- interface Card {
18
- image?: { src: string; alt?: string; focus?: string };
19
- icon?: string;
20
- title: string;
21
- meta?: string;
22
- text?: string;
23
- href?: string;
24
- linkLabel?: string;
25
- }
26
- interface Props {
27
- title?: string;
28
- intro?: string;
29
- columns?: 2 | 3;
30
- ratio?: '16/9' | '4/3' | '3/2' | '1/1' | '3/4';
31
- cards?: Card[];
32
- }
33
- const { title, intro, columns = 3, ratio = '16/9', cards = [] } = Astro.props;
34
- // Never reserve more columns than there are cards; `data-single` centres a lone one.
35
- const { tablet, desktop: cols } = gridColumns(cards.length, columns); // never a short last row
36
- ---
37
-
38
- <section class="b-media-cards">
39
- {(title || intro) && (
40
- <div class="b-media-cards__head">
41
- {title && <Heading text={title} level={2} />}
42
- {intro && <p class="b-media-cards__intro" set:html={inlineMarkdown(intro)} />}
43
- </div>
44
- )}
45
- <div class="b-media-cards__grid" data-cols={cols} data-tablet={tablet} data-single={cards.length === 1 ? 'true' : undefined}>
46
- {cards.map((card) => {
47
- // Surface a mailto:/tel: as visible, copyable text — a plain mailto does
48
- // nothing on a device with no mail app, so the address must be readable too.
49
- const email = card.href?.startsWith('mailto:') ? card.href.slice(7).split('?')[0] : null;
50
- const phone = card.href?.startsWith('tel:') ? card.href.slice(4) : null;
51
- return (
52
- <article class:list={['b-media-cards__card', 'ferst-tile', 'ferst-tile--sm', card.href && 'is-link']}>
53
- {card.image && (
54
- <div class="b-media-cards__media" data-ratio={ratio} style={`aspect-ratio: ${ratio.replace('/', ' / ')}`}>
55
- <img src={card.image.src} alt={card.image.alt ?? ''} loading="lazy" style={card.image.focus ? `object-position: ${card.image.focus}` : undefined} />
56
- </div>
57
- )}
58
- <div class="b-media-cards__body">
59
- {card.icon && isIconKey(card.icon) && (
60
- <span class="b-media-cards__badge" aria-hidden="true"><Icon name={card.icon} size={20} /></span>
61
- )}
62
- <h3 class="b-media-cards__title">
63
- {card.href ? <a href={card.href}>{card.title}</a> : card.title}
64
- </h3>
65
- {card.meta && <p class="b-media-cards__meta">{card.meta}</p>}
66
- {card.text && <p class="b-media-cards__text" set:html={card.href ? inlineMarkdownNoLinks(card.text) : inlineMarkdown(card.text)} />}
67
- {(email || phone) && (
68
- <span class="b-media-cards__contact">{email ?? phone}</span>
69
- )}
70
- {card.href && !email && !phone && (
71
- <span class="b-media-cards__cta" aria-hidden="true">{card.linkLabel ?? 'Learn more'} →</span>
72
- )}
73
- </div>
74
- </article>
75
- );
76
- })}
77
- </div>
78
- </section>
79
-
80
- <style>
81
- .b-media-cards {
82
- display: flex;
83
- flex-direction: column;
84
- gap: 2rem;
85
- max-width: 72rem;
86
- margin-inline: auto;
87
- padding-inline: 1rem;
88
- }
89
- .b-media-cards__head {
90
- display: flex;
91
- flex-direction: column;
92
- gap: 0.75rem;
93
- }
94
- .b-media-cards__intro {
95
- margin: 0;
96
- color: var(--muted);
97
- font-size: 1.0625rem;
98
- line-height: 1.6;
99
- max-width: var(--max);
100
- }
101
- .b-media-cards__grid {
102
- display: grid;
103
- grid-template-columns: 1fr;
104
- gap: 1.5rem;
105
- }
106
- /* A solitary card is a centred feature, not a full-width slab. */
107
- .b-media-cards__grid[data-single] { max-width: 28rem; margin-inline: auto; }
108
- /* Never a short last row (lib/gridColumns): twos on tablet for an even count; on desktop
109
- everything in one row, or even rows. Phones stay one column. */
110
- @media (min-width: 40em) {
111
- .b-media-cards__grid[data-tablet='2'] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
112
- }
113
- @media (min-width: 60em) {
114
- .b-media-cards__grid[data-cols='2'] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
115
- .b-media-cards__grid[data-cols='3'] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
116
- .b-media-cards__grid[data-cols='4'] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
117
- }
118
- .b-media-cards__card {
119
- position: relative;
120
- display: flex;
121
- flex-direction: column;
122
- /* surface comes from .ferst-tile .ferst-tile--sm (bg/border/radius/shadow-sm) */
123
- overflow: hidden;
124
- transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
125
- }
126
- .b-media-cards__card.is-link:hover {
127
- transform: translateY(-2px);
128
- box-shadow: var(--shadow-md);
129
- border-color: var(--gold);
130
- }
131
- /* Image header — cover-cropped to a uniform 16:9 so any source ratio fits (the
132
- PostCard technique; also out-specifies the global img{height:auto}). */
133
- .b-media-cards__media {
134
- position: relative;
135
- aspect-ratio: 16 / 9;
136
- overflow: hidden;
137
- background: var(--bg-section);
138
- }
139
- .b-media-cards .b-media-cards__media img {
140
- position: absolute;
141
- inset: 0;
142
- width: 100%;
143
- height: 100%;
144
- object-fit: cover;
145
- display: block;
146
- }
147
- .b-media-cards__body {
148
- display: flex;
149
- flex-direction: column;
150
- align-items: var(--content-items, stretch); /* follows the page / section alignment */
151
- gap: 0.5rem;
152
- padding: 1.1rem 1.2rem 1.3rem;
153
- flex: 1;
154
- }
155
- /* Icon badge — a small brand chip; slightly lifted over the image edge when an
156
- image is present (the negative margin only bites inside a card with a header). */
157
- .b-media-cards__badge {
158
- display: inline-flex;
159
- align-items: center;
160
- justify-content: center;
161
- width: 2.25rem;
162
- height: 2.25rem;
163
- border-radius: 999px;
164
- background: var(--gold-light);
165
- color: var(--gold);
166
- margin-top: -2.3rem;
167
- margin-bottom: 0.2rem;
168
- border: 3px solid var(--bg-surface);
169
- }
170
- /* No image → the badge sits normally at the top of the body. */
171
- .b-media-cards__card:not(:has(.b-media-cards__media)) .b-media-cards__badge {
172
- margin-top: 0;
173
- border: none;
174
- }
175
- .b-media-cards__title {
176
- margin: 0;
177
- font-size: 1.2rem;
178
- color: var(--fg);
179
- }
180
- .b-media-cards__card.is-link:hover .b-media-cards__title a { color: var(--gold); }
181
- .b-media-cards__title a { color: var(--fg); }
182
- /* Stretch the title link over the whole card so it's clickable. */
183
- .b-media-cards__title a::after { content: ''; position: absolute; inset: 0; }
184
- .b-media-cards__meta {
185
- margin: 0;
186
- align-self: var(--content-self, flex-start); /* a pill keeps its width, follows the alignment */
187
- padding: 0.2rem 0.6rem;
188
- border-radius: 999px;
189
- background: var(--bg-section);
190
- color: var(--muted);
191
- font-family: var(--font-heading);
192
- font-size: 0.72rem;
193
- font-weight: 600;
194
- letter-spacing: 0.03em;
195
- }
196
- .b-media-cards__text {
197
- margin: 0;
198
- color: var(--muted);
199
- line-height: 1.6;
200
- }
201
- .b-media-cards__cta {
202
- margin-top: auto;
203
- padding-top: 0.5rem;
204
- font-family: var(--font-heading);
205
- font-size: 0.85rem;
206
- font-weight: 600;
207
- color: var(--gold);
208
- }
209
- /* A mailto/tel shown as visible, copyable text (below any description). */
210
- .b-media-cards__contact {
211
- margin-top: auto;
212
- padding-top: 0.5rem;
213
- font-family: var(--font-heading);
214
- font-size: 0.85rem;
215
- font-weight: 600;
216
- color: var(--gold);
217
- overflow-wrap: anywhere;
218
- }
219
- </style>
1
+ ---
2
+ /**
3
+ * MediaCards — a Level-2 recipe: a grid of rich content cards with the IMAGE as a
4
+ * header on top (cover-cropped to a uniform ratio, like PostCard), then an optional
5
+ * icon badge, a title, a meta line (e.g. "Sundays 10:45 · Main hall"), a description, and
6
+ * an optional CTA link. The image-HEADER pattern (distinct from `tiles`, which puts
7
+ * the image BEHIND the text): use it for groups, team members, services or events —
8
+ * anywhere the photo and the copy both need to be fully legible. Whole card links
9
+ * when `href` is set. Token-driven, equal-height.
10
+ */
11
+ import Icon from '../Icon.astro';
12
+ import { planGrid } from '../../lib/gridRows';
13
+ import { isIconKey } from '../../lib/icons';
14
+ import Heading from '../blocks/Heading.astro';
15
+
16
+ import { inlineMarkdown, inlineMarkdownNoLinks } from '../../lib/inline-markdown';
17
+ interface Card {
18
+ image?: { src: string; alt?: string; focus?: string };
19
+ icon?: string;
20
+ title: string;
21
+ meta?: string;
22
+ text?: string;
23
+ href?: string;
24
+ linkLabel?: string;
25
+ }
26
+ interface Props {
27
+ title?: string;
28
+ intro?: string;
29
+ columns?: 2 | 3;
30
+ ratio?: '16/9' | '4/3' | '3/2' | '1/1' | '3/4';
31
+ cards?: Card[];
32
+ /** How the ragged last row lays out (lib/gridRows). */
33
+ lastRow?: 'auto' | 'fill' | 'center';
34
+ }
35
+ const { title, intro, columns = 3, ratio = '16/9', cards = [], lastRow = 'auto' } = Astro.props;
36
+ // Rows planned per screen (lib/gridRows); `data-single` centres a lone card.
37
+ const plan = planGrid(cards.length, { columns, item: 'mediaCards', lastRow });
38
+ ---
39
+
40
+ <section class="b-media-cards">
41
+ {(title || intro) && (
42
+ <div class="b-media-cards__head">
43
+ {title && <Heading text={title} level={2} />}
44
+ {intro && <p class="b-media-cards__intro" set:html={inlineMarkdown(intro)} />}
45
+ </div>
46
+ )}
47
+ <div class="b-media-cards__grid ferst-rows" data-cols={plan.cols} data-single={cards.length === 1 ? 'true' : undefined} style={plan.gridStyle}>
48
+ {cards.map((card, i) => {
49
+ // Surface a mailto:/tel: as visible, copyable text — a plain mailto does
50
+ // nothing on a device with no mail app, so the address must be readable too.
51
+ const email = card.href?.startsWith('mailto:') ? card.href.slice(7).split('?')[0] : null;
52
+ const phone = card.href?.startsWith('tel:') ? card.href.slice(4) : null;
53
+ return (
54
+ <article class:list={['b-media-cards__card', 'ferst-tile', 'ferst-tile--sm', card.href && 'is-link']} style={plan.itemStyles[i]}>
55
+ {card.image && (
56
+ <div class="b-media-cards__media" data-ratio={ratio} style={`aspect-ratio: ${ratio.replace('/', ' / ')}`}>
57
+ <img src={card.image.src} alt={card.image.alt ?? ''} loading="lazy" style={card.image.focus ? `object-position: ${card.image.focus}` : undefined} />
58
+ </div>
59
+ )}
60
+ <div class="b-media-cards__body">
61
+ {card.icon && isIconKey(card.icon) && (
62
+ <span class="b-media-cards__badge" aria-hidden="true"><Icon name={card.icon} size={20} /></span>
63
+ )}
64
+ <h3 class="b-media-cards__title">
65
+ {card.href ? <a href={card.href}>{card.title}</a> : card.title}
66
+ </h3>
67
+ {card.meta && <p class="b-media-cards__meta">{card.meta}</p>}
68
+ {card.text && <p class="b-media-cards__text" set:html={card.href ? inlineMarkdownNoLinks(card.text) : inlineMarkdown(card.text)} />}
69
+ {(email || phone) && (
70
+ <span class="b-media-cards__contact">{email ?? phone}</span>
71
+ )}
72
+ {card.href && !email && !phone && (
73
+ <span class="b-media-cards__cta" aria-hidden="true">{card.linkLabel ?? 'Learn more'} →</span>
74
+ )}
75
+ </div>
76
+ </article>
77
+ );
78
+ })}
79
+ </div>
80
+ </section>
81
+
82
+ <style>
83
+ .b-media-cards {
84
+ display: flex;
85
+ flex-direction: column;
86
+ gap: 2rem;
87
+ width: 100%; /* the full content width, whatever its items hold (lib/gridRows) */
88
+ max-width: 72rem;
89
+ margin-inline: auto;
90
+ padding-inline: 1rem;
91
+ }
92
+ .b-media-cards__head {
93
+ display: flex;
94
+ flex-direction: column;
95
+ gap: 0.75rem;
96
+ }
97
+ .b-media-cards__intro {
98
+ margin: 0;
99
+ color: var(--muted);
100
+ font-size: 1.0625rem;
101
+ line-height: 1.6;
102
+ max-width: var(--max);
103
+ }
104
+ .b-media-cards__grid {
105
+ display: grid;
106
+ gap: 1.5rem;
107
+ }
108
+ /* A solitary card is a centred feature, not a full-width slab. */
109
+ .b-media-cards__grid[data-single] { max-width: 28rem; margin-inline: auto; }
110
+ /* Rows come from lib/gridRows (the global .ferst-rows rules): even rows where the
111
+ count allows by using fewer columns, else full rows and a tidied last row. */
112
+ .b-media-cards__card {
113
+ position: relative;
114
+ display: flex;
115
+ flex-direction: column;
116
+ /* surface comes from .ferst-tile .ferst-tile--sm (bg/border/radius/shadow-sm) */
117
+ overflow: hidden;
118
+ transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
119
+ }
120
+ .b-media-cards__card.is-link:hover {
121
+ transform: translateY(-2px);
122
+ box-shadow: var(--shadow-md);
123
+ border-color: var(--gold);
124
+ }
125
+ /* Image header — cover-cropped to a uniform 16:9 so any source ratio fits (the
126
+ PostCard technique; also out-specifies the global img{height:auto}). */
127
+ .b-media-cards__media {
128
+ position: relative;
129
+ aspect-ratio: 16 / 9;
130
+ overflow: hidden;
131
+ background: var(--bg-section);
132
+ }
133
+ .b-media-cards .b-media-cards__media img {
134
+ position: absolute;
135
+ inset: 0;
136
+ width: 100%;
137
+ height: 100%;
138
+ object-fit: cover;
139
+ display: block;
140
+ }
141
+ .b-media-cards__body {
142
+ display: flex;
143
+ flex-direction: column;
144
+ align-items: var(--content-items, stretch); /* follows the page / section alignment */
145
+ gap: 0.5rem;
146
+ padding: 1.1rem 1.2rem 1.3rem;
147
+ flex: 1;
148
+ }
149
+ /* Icon badge — a small brand chip; slightly lifted over the image edge when an
150
+ image is present (the negative margin only bites inside a card with a header). */
151
+ .b-media-cards__badge {
152
+ display: inline-flex;
153
+ align-items: center;
154
+ justify-content: center;
155
+ width: 2.25rem;
156
+ height: 2.25rem;
157
+ border-radius: 999px;
158
+ background: var(--gold-light);
159
+ color: var(--gold);
160
+ margin-top: -2.3rem;
161
+ margin-bottom: 0.2rem;
162
+ border: 3px solid var(--bg-surface);
163
+ }
164
+ /* No image → the badge sits normally at the top of the body. */
165
+ .b-media-cards__card:not(:has(.b-media-cards__media)) .b-media-cards__badge {
166
+ margin-top: 0;
167
+ border: none;
168
+ }
169
+ .b-media-cards__title {
170
+ margin: 0;
171
+ font-size: 1.2rem;
172
+ color: var(--fg);
173
+ }
174
+ .b-media-cards__card.is-link:hover .b-media-cards__title a { color: var(--gold); }
175
+ .b-media-cards__title a { color: var(--fg); }
176
+ /* Stretch the title link over the whole card so it's clickable. */
177
+ .b-media-cards__title a::after { content: ''; position: absolute; inset: 0; }
178
+ .b-media-cards__meta {
179
+ margin: 0;
180
+ align-self: var(--content-self, flex-start); /* a pill keeps its width, follows the alignment */
181
+ padding: 0.2rem 0.6rem;
182
+ border-radius: 999px;
183
+ background: var(--bg-section);
184
+ color: var(--muted);
185
+ font-family: var(--font-heading);
186
+ font-size: 0.72rem;
187
+ font-weight: 600;
188
+ letter-spacing: 0.03em;
189
+ }
190
+ .b-media-cards__text {
191
+ margin: 0;
192
+ color: var(--muted);
193
+ line-height: 1.6;
194
+ }
195
+ .b-media-cards__cta {
196
+ margin-top: auto;
197
+ padding-top: 0.5rem;
198
+ font-family: var(--font-heading);
199
+ font-size: 0.85rem;
200
+ font-weight: 600;
201
+ color: var(--gold);
202
+ }
203
+ /* A mailto/tel shown as visible, copyable text (below any description). */
204
+ .b-media-cards__contact {
205
+ margin-top: auto;
206
+ padding-top: 0.5rem;
207
+ font-family: var(--font-heading);
208
+ font-size: 0.85rem;
209
+ font-weight: 600;
210
+ color: var(--gold);
211
+ overflow-wrap: anywhere;
212
+ }
213
+ </style>
@@ -0,0 +1,176 @@
1
+ ---
2
+ /**
3
+ * MembersContent — a members' page from the Ferst Members module, written in the portal. The
4
+ * build renders only a placeholder (and the block's title, when it has one): what members read is
5
+ * never in the build. In the visitor's browser the block asks the site for the page
6
+ * (`/ferst-api/members/pages/<id>`, same-origin, the session cookie going with it), and the
7
+ * platform checks who is signed in. Then it shows the page, a sign-in prompt (401), "not included"
8
+ * (403) or "can't be shown" (anything else). On the author's own computer (`astro dev` /
9
+ * `astro preview`, no Pages Functions) it says sign-in works on the published site. lib/members
10
+ * holds the decisions.
11
+ */
12
+ import Heading from '../blocks/Heading.astro';
13
+ import { MEMBERS_PAGE_TEXT, membersPageUrl } from '../../lib/members';
14
+
15
+ interface Props {
16
+ page: string;
17
+ title?: string;
18
+ }
19
+ const { page, title } = Astro.props;
20
+ const { align: blockAlign, headingAlign } = Astro.props as { align?: 'start' | 'center' | 'end'; headingAlign?: 'start' | 'center' | 'end' };
21
+ const headAlign = headingAlign ?? blockAlign;
22
+ const signIn = MEMBERS_PAGE_TEXT.signIn;
23
+ ---
24
+
25
+ <section class="b-members" data-members-page={membersPageUrl(page)} data-members-own-title={title ? undefined : ''} aria-busy="true">
26
+ <div class="b-members__head" data-recipe-head data-content-align={headAlign} hidden={!title}>
27
+ <Heading text={title ?? ''} level={2} />
28
+ </div>
29
+ <div class="b-members__skeleton" data-members-skeleton aria-hidden="true">
30
+ <span></span><span></span><span></span>
31
+ </div>
32
+ <div class="b-members__body" data-members-body hidden></div>
33
+ <p class="b-members__notice" role="status" data-members-notice="sign-in" hidden>
34
+ {signIn.before} <a href="/account" data-members-sign-in>{signIn.link}</a> {signIn.after}
35
+ </p>
36
+ <p class="b-members__notice" role="status" data-members-notice="not-included" hidden>{MEMBERS_PAGE_TEXT.notIncluded}</p>
37
+ <p class="b-members__notice" role="status" data-members-notice="unavailable" hidden>{MEMBERS_PAGE_TEXT.unavailable}</p>
38
+ <p class="b-members__notice" role="status" data-members-notice="local" hidden>{MEMBERS_PAGE_TEXT.local}</p>
39
+ </section>
40
+
41
+ <script>
42
+ import { isLocalHost, membersPageView, readMembersAnswer, signInHref, type MembersAnswer } from '../../lib/members';
43
+
44
+ async function ask(url: string): Promise<MembersAnswer | null> {
45
+ try {
46
+ const res = await fetch(url, { credentials: 'same-origin', headers: { Accept: 'application/json' } });
47
+ return await readMembersAnswer(res);
48
+ } catch {
49
+ return null;
50
+ }
51
+ }
52
+
53
+ async function setUp(block: HTMLElement) {
54
+ const url = block.dataset.membersPage;
55
+ if (!url) return;
56
+ const view = membersPageView(await ask(url), import.meta.env.DEV || isLocalHost(location.hostname));
57
+ block.querySelector<HTMLElement>('[data-members-skeleton]')?.remove();
58
+ block.removeAttribute('aria-busy');
59
+ if (view.kind === 'page') {
60
+ // The page's own title, unless the block gives its own.
61
+ const head = block.querySelector<HTMLElement>('.b-members__head');
62
+ if (head && block.dataset.membersOwnTitle !== undefined && view.title) {
63
+ const heading = head.querySelector<HTMLElement>('.b-heading');
64
+ if (heading) heading.textContent = view.title;
65
+ head.hidden = false;
66
+ }
67
+ const body = block.querySelector<HTMLElement>('[data-members-body]');
68
+ if (body) {
69
+ // The platform renders the page's Markdown and allows only plain tags (no scripts, no styles).
70
+ body.innerHTML = view.html;
71
+ body.hidden = false;
72
+ }
73
+ return;
74
+ }
75
+ if (view.kind === 'sign-in') {
76
+ const link = block.querySelector<HTMLAnchorElement>('[data-members-sign-in]');
77
+ if (link) link.href = signInHref(location.pathname + location.search);
78
+ }
79
+ const notice = block.querySelector<HTMLElement>(`[data-members-notice="${view.kind}"]`);
80
+ if (notice) notice.hidden = false;
81
+ }
82
+
83
+ document.querySelectorAll<HTMLElement>('[data-members-page]').forEach((b) => { void setUp(b); });
84
+ </script>
85
+
86
+ <style>
87
+ .b-members {
88
+ display: flex;
89
+ flex-direction: column;
90
+ gap: 1rem;
91
+ max-width: var(--max);
92
+ margin-inline: auto;
93
+ padding-inline: 1rem;
94
+ color: var(--fg);
95
+ }
96
+ .b-members__head[hidden],
97
+ .b-members__body[hidden],
98
+ .b-members__notice[hidden] {
99
+ display: none;
100
+ }
101
+
102
+ /* The placeholder while the page loads: three quiet bars, still under reduced motion. */
103
+ .b-members__skeleton {
104
+ display: flex;
105
+ flex-direction: column;
106
+ gap: 0.75rem;
107
+ }
108
+ .b-members__skeleton span {
109
+ display: block;
110
+ height: 1rem;
111
+ border-radius: var(--radius-sm);
112
+ background: var(--bg-section);
113
+ animation: b-members-pulse 1.6s ease-in-out infinite;
114
+ }
115
+ .b-members__skeleton span:nth-child(2) { width: 92%; }
116
+ .b-members__skeleton span:nth-child(3) { width: 64%; }
117
+ @keyframes b-members-pulse {
118
+ 50% { opacity: 0.55; }
119
+ }
120
+ @media (prefers-reduced-motion: reduce) {
121
+ .b-members__skeleton span { animation: none; }
122
+ }
123
+
124
+ /* The page itself: plain Markdown from the portal, read like a Prose block. */
125
+ .b-members__body :global(:is(p, ul, ol, blockquote, pre, table)) {
126
+ margin: 0 0 1rem;
127
+ line-height: 1.7;
128
+ }
129
+ .b-members__body :global(:is(ul, ol)) {
130
+ padding-inline-start: 1.4em;
131
+ }
132
+ .b-members__body :global(li + li) {
133
+ margin-top: 0.25rem;
134
+ }
135
+ .b-members__body :global(:is(h1, h2, h3, h4, h5, h6)) {
136
+ margin: 1.5rem 0 0.75rem;
137
+ line-height: 1.25;
138
+ color: var(--fg);
139
+ }
140
+ .b-members__body :global(a) {
141
+ color: var(--accent);
142
+ text-decoration: underline;
143
+ text-underline-offset: 0.15em;
144
+ }
145
+ .b-members__body :global(img) {
146
+ max-width: 100%;
147
+ height: auto;
148
+ border-radius: var(--radius-sm);
149
+ }
150
+ .b-members__body :global(blockquote) {
151
+ padding-inline-start: 1rem;
152
+ border-inline-start: 3px solid var(--border);
153
+ color: var(--muted);
154
+ }
155
+ .b-members__body > :global(:first-child) {
156
+ margin-top: 0;
157
+ }
158
+ .b-members__body > :global(:last-child) {
159
+ margin-bottom: 0;
160
+ }
161
+
162
+ .b-members__notice {
163
+ margin: 0;
164
+ padding: 0.85rem 1rem;
165
+ border: 1px solid var(--border);
166
+ border-radius: var(--radius-sm);
167
+ background: var(--bg-section);
168
+ line-height: 1.5;
169
+ }
170
+ .b-members__notice a {
171
+ color: var(--accent);
172
+ font-weight: 600;
173
+ text-decoration: underline;
174
+ text-underline-offset: 0.15em;
175
+ }
176
+ </style>