ferst-core 0.17.1 → 0.18.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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  // ferst-modules — what this site has from its organisation's modules in the Ferst portal:
3
- // the forms it can place, what it can take payment for and bookings for, its members' pages, and
4
- // the calendar it shows.
3
+ // the forms it can place, what it can take payment for and bookings for, whether Members is on,
4
+ // and the calendar it shows.
5
5
  // Run it in a client repo root:
6
6
  //
7
7
  // npx --no-install ferst-modules # the site named in ferst-site.json
@@ -11,8 +11,8 @@
11
11
  // Forms and calendars live in the portal, never in the repo: place a form with a
12
12
  // `{ "type": "form", "form": "<its name on this site>" }` block, take a payment with a
13
13
  // `{ "type": "pay", "item": "<its id>" }` block, take bookings with a
14
- // `{ "type": "book", "service": "<its id>" }` block (or `"resource"`, for a person or a place), show a
15
- // members' page with a `{ "type": "membersContent", "page": "<its id>" }` block, and show the calendar by setting
14
+ // `{ "type": "book", "service": "<its id>" }` block (or `"resource"`, for a person or a place), and show the
15
+ // calendar by setting
16
16
  // calendarSettings.embedUrl to the address printed here.
17
17
  import { readFileSync, realpathSync } from 'node:fs';
18
18
  import { resolve } from 'node:path';
@@ -107,16 +107,11 @@ export function formatModules(data) {
107
107
  out.push('');
108
108
  }
109
109
 
110
- // Members (platform 2026-11-30+): the members' pages this site shows, titles only (the pages
111
- // themselves are members-only and never in the repo).
112
- if (data.modules.members !== undefined || data.members !== undefined) {
110
+ // Members (platform 2026-11-30+): whether visitors sign in on this site. Members-only content is a
111
+ // setting on a page in the CMS, not a block (members' pages were removed on 2026-12-02).
112
+ if (data.modules.members !== undefined) {
113
113
  out.push('Members');
114
- if (!data.modules.members) out.push(' The Members module is off for this site.');
115
- else if (!data.members?.pages?.length) out.push(' No members’ pages on this site yet. They are written in the portal (Members, Pages).');
116
- for (const p of data.members?.pages ?? []) {
117
- out.push(` ${p.title}`);
118
- out.push(` place it with: { "type": "membersContent", "page": "${p.id}" }`);
119
- }
114
+ out.push(data.modules.members ? ' On: visitors join and sign in on the site’s /account page.' : ' The Members module is off for this site.');
120
115
  out.push('');
121
116
  }
122
117
 
@@ -29,7 +29,6 @@ import ContactForm from './recipes/ContactForm.astro';
29
29
  import Form from './recipes/Form.astro';
30
30
  import Pay from './recipes/Pay.astro';
31
31
  import Book from './recipes/Book.astro';
32
- import MembersContent from './recipes/MembersContent.astro';
33
32
  import Accordion from './recipes/Accordion.astro';
34
33
  import Tiles from './recipes/Tiles.astro';
35
34
  import Banner from './recipes/Banner.astro';
@@ -86,7 +85,6 @@ const registry: Record<BlockType, any> = {
86
85
  form: Form,
87
86
  pay: Pay,
88
87
  book: Book,
89
- membersContent: MembersContent,
90
88
  accordion: Accordion,
91
89
  tiles: Tiles,
92
90
  banner: Banner,
package/content/blocks.ts CHANGED
@@ -330,20 +330,6 @@ export const bookBlock = z.object({
330
330
  buttonLabel: z.string().max(40).optional(),
331
331
  });
332
332
 
333
- /** A members' page from the Ferst Members module, written in the portal: only signed-in members
334
- * of the organisation read it. The build renders a placeholder (and the title, when given); the
335
- * visitor's browser asks the site for the page (`/ferst-api/members/pages/<id>`), and the platform
336
- * checks who is signed in. Nothing members-only is ever in the build or the repo (lib/members).
337
- * List a site's members' pages with `npx ferst-modules`. */
338
- export const membersContentBlock = z.object({
339
- type: z.literal('membersContent'),
340
- enabled: z.boolean().default(true),
341
- /** The page's id in the portal (e.g. `mpg_3f2a…`). */
342
- page: z.string().regex(/^mpg_[0-9a-f]{24}$/, 'a members’ page id from the portal, like mpg_ and 24 letters and digits'),
343
- /** Shown while the page loads and to visitors who can't read it. Left out: the page's own title, once it loads. */
344
- title: z.string().optional(),
345
- });
346
-
347
333
  /** A contact form recipe. `fields` is generic (any labelled input list) so the
348
334
  * same recipe serves a contact page, an enquiry form, a sign-up, etc. `action`
349
335
  * is optional: the core ships no backend, so with none it renders a standard
@@ -846,7 +832,6 @@ export type RecipeBlock =
846
832
  | z.infer<typeof formBlock>
847
833
  | z.infer<typeof payBlock>
848
834
  | z.infer<typeof bookBlock>
849
- | z.infer<typeof membersContentBlock>
850
835
  | z.infer<typeof accordionBlock>
851
836
  | z.infer<typeof tilesBlock>
852
837
  | z.infer<typeof bannerBlock>
@@ -993,7 +978,6 @@ export const blockSchema = z.discriminatedUnion(
993
978
  formBlock,
994
979
  payBlock,
995
980
  bookBlock,
996
- membersContentBlock,
997
981
  accordionBlock,
998
982
  tilesBlock,
999
983
  bannerBlock,
@@ -1084,8 +1068,7 @@ export const blockTypes = (
1084
1068
  blockSchema as unknown as { options: ReadonlyArray<{ shape: { type: { value: BlockType } } }> }
1085
1069
  ).options.map((o) => o.shape.type.value);
1086
1070
 
1087
- /** Blocks whose content comes from the Ferst platform (a form, an item to pay for, an offer to book: at build
1088
- * time; a members' page: in the visitor's browser). The public showcase can't render them without the
1071
+ /** Blocks whose content comes from the Ferst platform at build time (a form, an item to pay for, an offer to book). The public showcase can't render them without the
1089
1072
  * platform, so its galleries show the look through their local twin instead (`form` renders with the
1090
1073
  * contactForm recipe). */
1091
- export const platformBlockTypes: readonly BlockType[] = ['form', 'pay', 'book', 'membersContent'];
1074
+ export const platformBlockTypes: readonly BlockType[] = ['form', 'pay', 'book'];
@@ -166,8 +166,7 @@ export interface CookieScanInput {
166
166
  blockTypes?: Iterable<string>;
167
167
  /** True when the site has a Google Calendar configured (dedicated calendar page). */
168
168
  calendarConfigured?: boolean;
169
- /** True when members sign in on the site (the Ferst Members module): its sign-in cookie is listed.
170
- * A members' page block on the site lists it too. */
169
+ /** True when members sign in on the site (the Ferst Members module): its sign-in cookie is listed. */
171
170
  members?: boolean;
172
171
  }
173
172
 
@@ -198,7 +197,7 @@ const BY_TYPE: Record<string, string[]> = {
198
197
  /** Report the cookie uses actually active on a site, grouped by category. */
199
198
  export function scanCookieUses(input: CookieScanInput): CookiePolicyModel {
200
199
  const necessary = NECESSARY.map((u) => ({ ...u }));
201
- const signsIn = input.members === true || (input.blocks ? allBlocks(input.blocks).some((b) => b.type === 'membersContent') : false);
200
+ const signsIn = input.members === true;
202
201
  if (signsIn) necessary.push({ ...MEMBERS_SESSION });
203
202
  if (!input.blocks && input.blockTypes) {
204
203
  const types = new Set(input.blockTypes);
@@ -31,7 +31,6 @@ const QUESTIONS: Record<string, RecipeQuestion | null> = {
31
31
  form: note('Form', 'This shows one of your organisation’s forms. Choose or create it in the portal under Forms.'),
32
32
  pay: note('Payment', 'This takes a payment for one of the things your sites take payment for. Set what it’s for and its price in the portal, under Payments.'),
33
33
  book: note('Booking', 'This lets visitors book a time for one of your offers. Set the offer, who gives it and their opening hours in the portal, under Events and bookings.'),
34
- membersContent: note('Members’ page', 'This shows one of your members’ pages to members who are signed in. Write it, and choose the sites it’s shown on, in the portal under Members.'),
35
34
  accordion: ask('Expandable sections', 'What information should people be able to open up and read here?', 'Give each topic a short heading and the detail that goes under it.'),
36
35
  tiles: ask('Quick links', 'Where do visitors most often want to go from here?', 'List the places or tasks, a few words each, for example: opening times, book now, prices.'),
37
36
  banner: ask('Banner', 'What message deserves a bold band across the page?', 'A short statement or invitation, and where it should lead if anywhere.'),
@@ -14,7 +14,6 @@ export const recipes: GalleryEntry[] = [
14
14
  { type: 'gallery', description: 'A responsive grid of images with optional captions.', block: { type: 'gallery', columns: 3, images: [{ src: '/placeholder.svg', alt: 'One', caption: 'One' }, { src: '/placeholder.svg', alt: 'Two', caption: 'Two' }, { src: '/placeholder.svg', alt: 'Three', caption: 'Three' }] } },
15
15
  { type: 'testimonial', description: 'A centred quotation with author, role and an optional avatar.', block: { type: 'testimonial', quote: 'The showcase made the whole model click in a minute.', author: 'A. Client', role: 'Parish administrator' } },
16
16
  { type: 'contactForm', description: 'An accessible contact form in a centred column — labelled fields, a submit and an optional note. Fields are generic, so it also serves enquiry / sign-up forms.', block: { type: 'contactForm', title: 'Send us a message', intro: 'We usually reply within a day.', note: 'Demo form — the showcase has no backend; a real client points its action at their own endpoint.' } },
17
- { type: 'membersContent', description: 'A members’ page from the Members module, written in the portal and read only by the organisation’s signed-in members. The build holds a placeholder, never the words: the visitor’s browser asks the site (`/ferst-api/members/pages/<id>`) and the platform decides. Signed out, it offers “Sign in”; someone whose membership doesn’t include it is told so. The showcase has no members service, so here it says it can’t be shown (on your own computer: that sign-in works on the published site).', block: { type: 'membersContent', page: 'mpg_000000000000000000000000', title: 'For members' } },
18
17
  { type: 'accordion', description: 'Generic expand/collapse rows (title + body) — native, accessible, no JavaScript. FAQ’s domain-free sibling.', block: { type: 'accordion', title: 'How it works', items: [{ heading: 'Composable', body: 'Pages are ordered blocks stored as JSON.' }, { heading: 'Consistent', body: 'Recipes lock a good layout so quality can’t drift.' }] } },
19
18
  { type: 'tiles', description: 'A card grid with five looks — here “elevated” (soft shadow, lifts on hover) with the optional pointer-following spotlight. Radius / stroke / elevation come from the global surface tokens.', block: { type: 'tiles', variant: 'elevated', columns: 3, spotlight: true, tiles: [{ icon: 'sparkle', eyebrow: 'Level 1', title: 'Primitives', text: 'The raw ingredients.', href: '#' }, { icon: 'book-open', eyebrow: 'Level 2', title: 'Recipes', text: 'Curated compositions.', href: '#' }, { icon: 'shield', eyebrow: 'Level 3', title: 'Templates', text: 'Whole pages.', href: '#' }] } },
20
19
  { type: 'tiles', description: 'The “gradient” variant — brand → a derived accent-2 (an OKLCH hue-shift of your one brand colour), light text.', block: { type: 'tiles', variant: 'gradient', columns: 3, tiles: [{ icon: 'flame', title: 'Vibrant', text: 'One brand colour, a harmonious gradient.' }, { icon: 'sparkle', title: 'Derived', text: 'Accent-2 is computed, not configured.' }, { icon: 'heart', title: 'On-brand', text: 'Always harmonises with your hue.' }] } },
package/lib/members.ts CHANGED
@@ -1,134 +1,88 @@
1
- /**
2
- * Members: people who sign in on an organisation's sites (the Ferst Members module). The site
3
- * reaches the platform's members service only through its own address, `/ferst-api/…` (a Pages
4
- * Function the site template carries), so the session is a first-party cookie and nothing here
5
- * needs CORS. Every call is same-origin, `credentials: 'same-origin'`, JSON.
6
- *
7
- * Nothing a member reads is ever in the build: a members' page is a placeholder until the visitor's
8
- * browser asks for it, and the platform decides, per request, whether they may read it.
9
- *
10
- * The browser scripts (MembersContent, the header's account link) are thin; the decisions are
11
- * here, pure, so they're unit-tested.
12
- */
13
-
14
- /** Where a site's members service is, on the site's own address. */
15
- export const MEMBERS_API = '/ferst-api/members';
16
- /** The signed-in person, or `401 signed_out`. */
17
- export const MEMBERS_ME = `${MEMBERS_API}/me`;
18
- /** The members' account page: signing in, and the member's own details. */
19
- export const ACCOUNT_PATH = '/account';
20
-
21
- /** A members' page's id, as the portal makes them. */
22
- export const MEMBERS_PAGE_ID = /^mpg_[0-9a-f]{24}$/;
23
-
24
- /** Where the browser reads a members' page. */
25
- export function membersPageUrl(page: string): string {
26
- return `${MEMBERS_API}/pages/${encodeURIComponent(page)}`;
27
- }
28
-
29
- /** The account page, coming back here once signed in. */
30
- export function signInHref(here: string): string {
31
- return `${ACCOUNT_PATH}?next=${encodeURIComponent(here)}`;
32
- }
33
-
34
- /** An answer from the members service: its status, and its JSON body (null when it isn't JSON). */
35
- export interface MembersAnswer {
36
- status: number;
37
- body: Record<string, unknown> | null;
38
- }
39
-
40
- /** Read a response as a MembersAnswer. Anything but JSON (a "page not found" page) has no body. */
41
- export async function readMembersAnswer(res: Response): Promise<MembersAnswer> {
42
- const json = /application\/json/i.test(res.headers.get('Content-Type') ?? '');
43
- let body: Record<string, unknown> | null = null;
44
- if (json) {
45
- try {
46
- const parsed: unknown = await res.json();
47
- body = parsed && typeof parsed === 'object' ? (parsed as Record<string, unknown>) : null;
48
- } catch {
49
- body = null;
50
- }
51
- }
52
- return { status: res.status, body };
53
- }
54
-
55
- /** What a membersContent block shows. */
56
- export type MembersPageView =
57
- | { kind: 'page'; title: string; html: string }
58
- /** 401: "This is for members. Sign in to read it". */
59
- | { kind: 'sign-in' }
60
- /** 403 not_for_you: a guest, someone waiting for approval, or a page for other members. */
61
- | { kind: 'not-included' }
62
- /** Anything else: the page is gone, Members is off for the site, the service is down. */
63
- | { kind: 'unavailable' }
64
- /** Running on a computer (`astro dev` / `astro preview`), where the site has no /ferst-api. */
65
- | { kind: 'local' };
66
-
67
- /**
68
- * What to show for the answer to `GET /ferst-api/members/pages/:id`. `local` is true when the site
69
- * runs on the author's own computer: there the answer is the dev server's "page not found", not the
70
- * service's, so the block says sign-in works on the published site.
71
- */
72
- export function membersPageView(answer: MembersAnswer | null, local = false): MembersPageView {
73
- if (!answer || !answer.body) return local ? { kind: 'local' } : { kind: 'unavailable' };
74
- const { status, body } = answer;
75
- if (status === 200 && typeof body.html === 'string') {
76
- return { kind: 'page', title: typeof body.title === 'string' ? body.title : '', html: body.html };
77
- }
78
- if (status === 401) return { kind: 'sign-in' };
79
- // 403 is also the answer when Members isn't on for the site (`module_off`): not about them.
80
- if (status === 403 && body.error === 'not_for_you') return { kind: 'not-included' };
81
- return { kind: 'unavailable' };
82
- }
83
-
84
- /** The words a members' page shows when it can't show the page itself. */
85
- export const MEMBERS_PAGE_TEXT = {
86
- signIn: { before: 'This is for members.', link: 'Sign in', after: 'to read it.' },
87
- notIncluded: 'This isn’t included in your membership.',
88
- unavailable: 'This can’t be shown right now.',
89
- local: 'Sign-in works on the published site.',
90
- } as const;
91
-
92
- /** The first word of a person's name, for the header ("Sam" for "Sam Hill"). */
93
- export function firstName(displayName: unknown): string {
94
- if (typeof displayName !== 'string') return '';
95
- return displayName.trim().split(/\s+/)[0] ?? '';
96
- }
97
-
98
- /**
99
- * The header's account link, from the answer to `GET /ferst-api/members/me`: the member's first
100
- * name (or "Your account" when they have none yet), "Sign in" when signed out, and null (leave the
101
- * build's "Account") when the service can't say.
102
- */
103
- export function accountLinkText(answer: MembersAnswer | null): string | null {
104
- if (!answer || !answer.body) return null;
105
- if (answer.status === 401) return 'Sign in';
106
- if (answer.status !== 200) return null;
107
- const member = answer.body.member as { display_name?: unknown } | undefined;
108
- if (!member || typeof member !== 'object') return null;
109
- return firstName(member.display_name) || 'Your account';
110
- }
111
-
112
- /**
113
- * The header's account link without a flicker (0.17.1): the build says "Sign in" (most visitors
114
- * aren't signed in), and a tiny inline script puts back the label this browser last saw before the
115
- * page paints, under this key. The answer from `/me` still has the last word, and is remembered.
116
- */
117
- export const ACCOUNT_LABEL_KEY = 'ferst:account-label';
118
-
119
- /** A remembered label worth showing: one short line of plain text, as accountLinkText makes them. */
120
- export function rememberedLabel(v: unknown): string | null {
121
- if (typeof v !== 'string') return null;
122
- const t = v.trim();
123
- return t && t.length <= 40 && !/[\n\r<>]/.test(t) ? t : null;
124
- }
125
-
126
- /** Remember the link's label for the next page (nothing, where the browser keeps no storage). */
127
- export function rememberAccountLabel(text: string): void {
128
- try { localStorage.setItem(ACCOUNT_LABEL_KEY, text); } catch { /* private mode, storage off */ }
129
- }
130
-
131
- /** True on the author's own computer, where `/ferst-api` isn't there (no Pages Functions). */
132
- export function isLocalHost(hostname: string): boolean {
133
- return /^(localhost|127\.0\.0\.1|\[::1\]|::1)$/.test(hostname) || hostname.endsWith('.localhost');
134
- }
1
+ /**
2
+ * Members: people who sign in on an organisation's sites (the Ferst Members module). The site
3
+ * reaches the platform's members service only through its own address, `/ferst-api/…` (a Pages
4
+ * Function the site template carries), so the session is a first-party cookie and nothing here
5
+ * needs CORS. Every call is same-origin, `credentials: 'same-origin'`, JSON.
6
+ *
7
+ * Nothing a member reads is ever in the build.
8
+ *
9
+ * The browser scripts (the header's account link, the account page) are thin; the decisions are
10
+ * here, pure, so they're unit-tested.
11
+ */
12
+
13
+ /** Where a site's members service is, on the site's own address. */
14
+ export const MEMBERS_API = '/ferst-api/members';
15
+ /** The signed-in person, or `401 signed_out`. */
16
+ export const MEMBERS_ME = `${MEMBERS_API}/me`;
17
+ /** The members' account page: signing in, and the member's own details. */
18
+ export const ACCOUNT_PATH = '/account';
19
+
20
+ /** The account page, coming back here once signed in. */
21
+ export function signInHref(here: string): string {
22
+ return `${ACCOUNT_PATH}?next=${encodeURIComponent(here)}`;
23
+ }
24
+
25
+ /** An answer from the members service: its status, and its JSON body (null when it isn't JSON). */
26
+ export interface MembersAnswer {
27
+ status: number;
28
+ body: Record<string, unknown> | null;
29
+ }
30
+
31
+ /** Read a response as a MembersAnswer. Anything but JSON (a "page not found" page) has no body. */
32
+ export async function readMembersAnswer(res: Response): Promise<MembersAnswer> {
33
+ const json = /application\/json/i.test(res.headers.get('Content-Type') ?? '');
34
+ let body: Record<string, unknown> | null = null;
35
+ if (json) {
36
+ try {
37
+ const parsed: unknown = await res.json();
38
+ body = parsed && typeof parsed === 'object' ? (parsed as Record<string, unknown>) : null;
39
+ } catch {
40
+ body = null;
41
+ }
42
+ }
43
+ return { status: res.status, body };
44
+ }
45
+
46
+ /** The first word of a person's name, for the header ("Sam" for "Sam Hill"). */
47
+ export function firstName(displayName: unknown): string {
48
+ if (typeof displayName !== 'string') return '';
49
+ return displayName.trim().split(/\s+/)[0] ?? '';
50
+ }
51
+
52
+ /**
53
+ * The header's account link, from the answer to `GET /ferst-api/members/me`: the member's first
54
+ * name (or "Your account" when they have none yet), "Sign in" when signed out, and null (leave the
55
+ * build's "Account") when the service can't say.
56
+ */
57
+ export function accountLinkText(answer: MembersAnswer | null): string | null {
58
+ if (!answer || !answer.body) return null;
59
+ if (answer.status === 401) return 'Sign in';
60
+ if (answer.status !== 200) return null;
61
+ const member = answer.body.member as { display_name?: unknown } | undefined;
62
+ if (!member || typeof member !== 'object') return null;
63
+ return firstName(member.display_name) || 'Your account';
64
+ }
65
+
66
+ /**
67
+ * The header's account link without a flicker (0.17.1): the build says "Sign in" (most visitors
68
+ * aren't signed in), and a tiny inline script puts back the label this browser last saw before the
69
+ * page paints, under this key. The answer from `/me` still has the last word, and is remembered.
70
+ */
71
+ export const ACCOUNT_LABEL_KEY = 'ferst:account-label';
72
+
73
+ /** A remembered label worth showing: one short line of plain text, as accountLinkText makes them. */
74
+ export function rememberedLabel(v: unknown): string | null {
75
+ if (typeof v !== 'string') return null;
76
+ const t = v.trim();
77
+ return t && t.length <= 40 && !/[\n\r<>]/.test(t) ? t : null;
78
+ }
79
+
80
+ /** Remember the link's label for the next page (nothing, where the browser keeps no storage). */
81
+ export function rememberAccountLabel(text: string): void {
82
+ try { localStorage.setItem(ACCOUNT_LABEL_KEY, text); } catch { /* private mode, storage off */ }
83
+ }
84
+
85
+ /** True on the author's own computer, where `/ferst-api` isn't there (no Pages Functions). */
86
+ export function isLocalHost(hostname: string): boolean {
87
+ return /^(localhost|127\.0\.0\.1|\[::1\]|::1)$/.test(hostname) || hostname.endsWith('.localhost');
88
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ferst-core",
3
- "version": "0.17.1",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "description": "Ferst Core — the shared, brand-agnostic client-site system: Astro components, layouts, content schemas, the layered config resolver, and a neutral styling architecture that every client overrides.",
6
6
  "license": "BUSL-1.1",
@@ -1,176 +0,0 @@
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>