@mwam/sdk 0.4.0 → 0.5.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 +58 -0
- package/dist/index.d.ts +3601 -138
- package/dist/index.js +267 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,6 +5,39 @@ var noNul = (s) => !s.includes("\0");
|
|
|
5
5
|
var NUL_ISSUE = { message: "must not contain the NUL character (U+0000)" };
|
|
6
6
|
var storableString = () => z.string().refine(noNul, NUL_ISSUE);
|
|
7
7
|
|
|
8
|
+
// ../schemas/src/content/layout.ts
|
|
9
|
+
var SECTION_LAYOUTS = ["one", "halves", "wideLeft", "wideRight", "thirds", "mainSidebar", "sidebarMain"];
|
|
10
|
+
var ROW_LAYOUTS = ["halves", "thirds", "wideLeft", "wideRight"];
|
|
11
|
+
var COLUMN_COUNT = {
|
|
12
|
+
one: 1,
|
|
13
|
+
halves: 2,
|
|
14
|
+
wideLeft: 2,
|
|
15
|
+
wideRight: 2,
|
|
16
|
+
thirds: 3,
|
|
17
|
+
mainSidebar: 2,
|
|
18
|
+
sidebarMain: 2
|
|
19
|
+
};
|
|
20
|
+
new Map(Object.entries(COLUMN_COUNT));
|
|
21
|
+
var SECTION_WIDTHS = ["contained", "full"];
|
|
22
|
+
var SECTION_SPACINGS = ["s", "m", "l"];
|
|
23
|
+
var BACKGROUNDS = ["bg-1", "bg-2", "bg-3", "bg-4", "bg-5", "bg-6"];
|
|
24
|
+
var COLUMN_ALIGNS = ["top", "middle"];
|
|
25
|
+
var SNIPPET_KINDS = ["teacher", "dates", "schedule", "booking", "gallery", "place"];
|
|
26
|
+
var BOOKING_PHONE = ["inline", "bar"];
|
|
27
|
+
var BUTTON_VARIANTS = ["primary", "secondary"];
|
|
28
|
+
var MAX_BUTTON_LABEL = 80;
|
|
29
|
+
var LAYOUT_TYPES = ["section", "column", "row", "subcolumn", "snippet", "button"];
|
|
30
|
+
new Set(LAYOUT_TYPES);
|
|
31
|
+
var PARENTS = {
|
|
32
|
+
section: ["doc"],
|
|
33
|
+
column: ["section"],
|
|
34
|
+
row: ["column"],
|
|
35
|
+
subcolumn: ["row"],
|
|
36
|
+
snippet: ["column", "subcolumn"],
|
|
37
|
+
button: ["column", "subcolumn"]
|
|
38
|
+
};
|
|
39
|
+
new Map(Object.entries(PARENTS));
|
|
40
|
+
|
|
8
41
|
// ../schemas/src/content/nodes.ts
|
|
9
42
|
var markSchema = z.discriminatedUnion("type", [
|
|
10
43
|
z.object({ type: z.literal("bold") }),
|
|
@@ -26,6 +59,9 @@ var imageBlock = imageRef.extend({
|
|
|
26
59
|
caption: storableString().nullable().optional(),
|
|
27
60
|
align: z.enum(ALIGNMENTS).optional()
|
|
28
61
|
});
|
|
62
|
+
var MAX_HTML_SECTION = 2e5;
|
|
63
|
+
var nodeId = z.string().regex(/^[A-Za-z0-9_-]{1,64}$/, "A node id is letters, digits, - and _").nullable().optional();
|
|
64
|
+
var align = z.enum(COLUMN_ALIGNS);
|
|
29
65
|
var nodeSchema = z.lazy(
|
|
30
66
|
() => z.discriminatedUnion("type", [
|
|
31
67
|
textNode,
|
|
@@ -39,7 +75,29 @@ var nodeSchema = z.lazy(
|
|
|
39
75
|
z.object({ type: z.literal("listItem"), content: z.array(nodeSchema).optional() }),
|
|
40
76
|
z.object({ type: z.literal("image"), attrs: imageBlock }),
|
|
41
77
|
z.object({ type: z.literal("beforeAfter"), attrs: z.object({ before: imageRef, after: imageRef, caption: storableString().nullable() }) }),
|
|
42
|
-
z.object({ type: z.literal("eventCard"), attrs: z.object({ eventId: storableString() }) })
|
|
78
|
+
z.object({ type: z.literal("eventCard"), attrs: z.object({ eventId: storableString() }) }),
|
|
79
|
+
z.object({ type: z.literal("htmlSection"), attrs: z.object({ html: storableString().pipe(z.string().max(MAX_HTML_SECTION, `An HTML section can be at most ${MAX_HTML_SECTION} characters`)) }) }),
|
|
80
|
+
z.object({
|
|
81
|
+
type: z.literal("section"),
|
|
82
|
+
attrs: z.object({ id: nodeId, layout: z.enum(SECTION_LAYOUTS), width: z.enum(SECTION_WIDTHS), background: z.enum(BACKGROUNDS).nullable(), spacing: z.enum(SECTION_SPACINGS) }),
|
|
83
|
+
content: z.array(nodeSchema).optional()
|
|
84
|
+
}),
|
|
85
|
+
z.object({ type: z.literal("column"), attrs: z.object({ id: nodeId, sticky: z.boolean(), align }), content: z.array(nodeSchema).optional() }),
|
|
86
|
+
z.object({ type: z.literal("row"), attrs: z.object({ id: nodeId, layout: z.enum(ROW_LAYOUTS) }), content: z.array(nodeSchema).optional() }),
|
|
87
|
+
z.object({ type: z.literal("subcolumn"), attrs: z.object({ id: nodeId, align }), content: z.array(nodeSchema).optional() }),
|
|
88
|
+
z.object({
|
|
89
|
+
type: z.literal("snippet"),
|
|
90
|
+
attrs: z.object({ id: nodeId, kind: z.enum(SNIPPET_KINDS), ref: storableString().pipe(z.string().max(200)).nullable(), phone: z.enum(BOOKING_PHONE).nullable() })
|
|
91
|
+
}),
|
|
92
|
+
z.object({
|
|
93
|
+
type: z.literal("button"),
|
|
94
|
+
attrs: z.object({
|
|
95
|
+
id: nodeId,
|
|
96
|
+
label: storableString().pipe(z.string().trim().min(1, "A button needs words").max(MAX_BUTTON_LABEL, `A button's words can be at most ${MAX_BUTTON_LABEL} characters`)),
|
|
97
|
+
href: storableString().pipe(z.string().max(2e3)),
|
|
98
|
+
variant: z.enum(BUTTON_VARIANTS)
|
|
99
|
+
})
|
|
100
|
+
})
|
|
43
101
|
])
|
|
44
102
|
);
|
|
45
103
|
var MAX_DEPTH = 100;
|
|
@@ -76,6 +134,138 @@ var docSchema = z.unknown().superRefine((value, ctx) => {
|
|
|
76
134
|
const refused = outOfBounds(value);
|
|
77
135
|
if (refused !== null) ctx.addIssue({ code: z.ZodIssueCode.custom, message: refused });
|
|
78
136
|
}).pipe(docShape);
|
|
137
|
+
|
|
138
|
+
// ../schemas/src/content/url.ts
|
|
139
|
+
var ALLOWED = /* @__PURE__ */ new Set(["http:", "https:", "mailto:"]);
|
|
140
|
+
function safeUrl(raw) {
|
|
141
|
+
const probe = Array.from(raw).filter((ch) => (ch.codePointAt(0) ?? 0) > 32).join("").toLowerCase();
|
|
142
|
+
if (probe.replace(/\\/g, "/").startsWith("//")) return null;
|
|
143
|
+
if (raw.startsWith("/") || raw.startsWith("#")) return raw;
|
|
144
|
+
const colon = probe.indexOf(":");
|
|
145
|
+
if (colon === -1) return raw;
|
|
146
|
+
const delim = [probe.indexOf("/"), probe.indexOf("?"), probe.indexOf("#")].filter((i) => i !== -1);
|
|
147
|
+
if (delim.some((i) => i < colon)) return raw;
|
|
148
|
+
if (!ALLOWED.has(probe.slice(0, colon + 1))) return null;
|
|
149
|
+
return raw;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ../schemas/src/content/render.ts
|
|
153
|
+
var BUTTON_CLASS = {
|
|
154
|
+
primary: "mwam-button mwam-button--primary",
|
|
155
|
+
secondary: "mwam-button mwam-button--secondary"
|
|
156
|
+
};
|
|
157
|
+
new Map(Object.entries(BUTTON_CLASS));
|
|
158
|
+
var WIDTH_CLASS = {
|
|
159
|
+
small: "mwam-image--small",
|
|
160
|
+
medium: "mwam-image--medium",
|
|
161
|
+
wide: "mwam-image--wide",
|
|
162
|
+
full: "mwam-image--full"
|
|
163
|
+
};
|
|
164
|
+
var ALIGN_CLASS = { center: "mwam-align-center", right: "mwam-align-right" };
|
|
165
|
+
new Map(Object.entries(WIDTH_CLASS));
|
|
166
|
+
new Map(Object.entries(ALIGN_CLASS));
|
|
167
|
+
var esc = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
168
|
+
|
|
169
|
+
// ../schemas/src/content/page-html.ts
|
|
170
|
+
var COLS_CLASS = {
|
|
171
|
+
one: "mwam-cols--one",
|
|
172
|
+
halves: "mwam-cols--halves",
|
|
173
|
+
wideLeft: "mwam-cols--wide-left",
|
|
174
|
+
wideRight: "mwam-cols--wide-right",
|
|
175
|
+
thirds: "mwam-cols--thirds",
|
|
176
|
+
mainSidebar: "mwam-cols--main-sidebar",
|
|
177
|
+
sidebarMain: "mwam-cols--sidebar-main"
|
|
178
|
+
};
|
|
179
|
+
var WIDTH_CLASS2 = { contained: "mwam-section--contained", full: "mwam-section--full" };
|
|
180
|
+
var SPACE_CLASS = { s: "mwam-section--space-s", m: "mwam-section--space-m", l: "mwam-section--space-l" };
|
|
181
|
+
var BG_CLASS = Object.fromEntries(BACKGROUNDS.map((k) => [k, `mwam-${k}`]));
|
|
182
|
+
var SNIPPET_CLASS = Object.fromEntries(SNIPPET_KINDS.map((k) => [k, `mwam-snippet--${k}`]));
|
|
183
|
+
var BUTTON_CLASS2 = { primary: "mwam-button mwam-button--primary", secondary: "mwam-button mwam-button--secondary" };
|
|
184
|
+
var lookup = (table) => {
|
|
185
|
+
const map = new Map(Object.entries(table));
|
|
186
|
+
return (value) => map.get(value) ?? null;
|
|
187
|
+
};
|
|
188
|
+
var colsClass = lookup(COLS_CLASS);
|
|
189
|
+
var widthClass2 = lookup(WIDTH_CLASS2);
|
|
190
|
+
var spaceClass = lookup(SPACE_CLASS);
|
|
191
|
+
var bgClass = lookup(BG_CLASS);
|
|
192
|
+
var snippetClass = lookup(SNIPPET_CLASS);
|
|
193
|
+
var buttonClass2 = lookup(BUTTON_CLASS2);
|
|
194
|
+
var classes = (...names) => names.filter((n) => typeof n === "string" && n !== "").join(" ");
|
|
195
|
+
function block(b, opts) {
|
|
196
|
+
switch (b.type) {
|
|
197
|
+
case "html":
|
|
198
|
+
return typeof b["html"] === "string" ? b["html"] : "";
|
|
199
|
+
case "button": {
|
|
200
|
+
const href = safeUrl(String(b["href"] ?? ""));
|
|
201
|
+
if (href === null) return "";
|
|
202
|
+
return `<p class="mwam-button-row"><a class="${buttonClass2(b["variant"]) ?? "mwam-button mwam-button--primary"}" href="${esc(href)}">${esc(String(b["label"] ?? ""))}</a></p>`;
|
|
203
|
+
}
|
|
204
|
+
case "row": {
|
|
205
|
+
const cols = Array.isArray(b["columns"]) ? b["columns"] : [];
|
|
206
|
+
return `<div class="${classes("mwam-row", "mwam-cols", colsClass(b["layout"]))}">` + cols.map((c) => `<div class="${classes("mwam-col", c.align === "middle" && "mwam-col--middle")}">` + (Array.isArray(c.blocks) ? c.blocks.map((x) => block(x, opts)).join("") : "") + "</div>").join("") + "</div>";
|
|
207
|
+
}
|
|
208
|
+
case "snippet": {
|
|
209
|
+
const drawn = opts.snippet?.(b) ?? null;
|
|
210
|
+
const cls = classes("mwam-snippet", snippetClass(b["kind"]), b["phone"] === "bar" && "mwam-snippet--phone-bar");
|
|
211
|
+
return `<div class="${cls}">${drawn ?? ""}</div>`;
|
|
212
|
+
}
|
|
213
|
+
default:
|
|
214
|
+
return "";
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function pageHtml(page, opts = {}) {
|
|
218
|
+
return `<div class="mwam-page">` + page.sections.map((s) => {
|
|
219
|
+
const cls = classes("mwam-section", widthClass2(s.width), spaceClass(s.spacing), bgClass(s.background));
|
|
220
|
+
const cols = s.columns.map((c) => `<div class="${classes("mwam-col", c.sticky && "mwam-col--sticky", c.align === "middle" && "mwam-col--middle")}">` + c.blocks.map((b) => block(b, opts)).join("") + "</div>").join("");
|
|
221
|
+
return `<section class="${cls}"><div class="mwam-section__inner"><div class="${classes("mwam-cols", colsClass(s.layout))}">${cols}</div></div></section>`;
|
|
222
|
+
}).join("") + "</div>";
|
|
223
|
+
}
|
|
224
|
+
var CSS_VAR = /^--[A-Za-z0-9_-]{1,64}$/;
|
|
225
|
+
var HEX = /^#[0-9A-Fa-f]{6}$/;
|
|
226
|
+
var clamp = (n, lo, hi, fallback) => typeof n === "number" && Number.isFinite(n) ? Math.min(hi, Math.max(lo, Math.round(n))) : fallback;
|
|
227
|
+
function layoutCss(opts = {}) {
|
|
228
|
+
const bp = clamp(opts.breakpoint, 320, 2400, 900);
|
|
229
|
+
const top = clamp(opts.stickyTop, 0, 400, 24);
|
|
230
|
+
const palette = (opts.palette ?? []).flatMap((p) => {
|
|
231
|
+
const cls = bgClass(p.key);
|
|
232
|
+
if (cls === null || !HEX.test(p.color) || !HEX.test(p.text)) return [];
|
|
233
|
+
const value = p.cssVar !== null && CSS_VAR.test(p.cssVar) ? `var(${p.cssVar}, ${p.color})` : p.color;
|
|
234
|
+
return [`.${cls}{background-color:${value};color:${p.text}}`];
|
|
235
|
+
});
|
|
236
|
+
return [
|
|
237
|
+
".mwam-page{display:block}",
|
|
238
|
+
".mwam-section{padding-block:var(--mwam-space-m,3rem)}",
|
|
239
|
+
".mwam-section--space-s{padding-block:var(--mwam-space-s,1.5rem)}",
|
|
240
|
+
".mwam-section--space-l{padding-block:var(--mwam-space-l,5rem)}",
|
|
241
|
+
".mwam-section__inner{box-sizing:border-box;margin-inline:auto;max-width:var(--mwam-measure,75rem);padding-inline:var(--mwam-gutter,1.5rem)}",
|
|
242
|
+
".mwam-section--full>.mwam-section__inner{max-width:none}",
|
|
243
|
+
".mwam-cols{display:grid;gap:var(--mwam-gap,2rem);grid-template-columns:minmax(0,1fr);align-items:start}",
|
|
244
|
+
".mwam-row{margin-block:1rem}",
|
|
245
|
+
".mwam-col{min-width:0}",
|
|
246
|
+
".mwam-col--middle{align-self:center}",
|
|
247
|
+
".mwam-col>:first-child{margin-top:0}",
|
|
248
|
+
".mwam-button-row{margin-block:1rem}",
|
|
249
|
+
".mwam-button{display:inline-block;padding:.75em 1.5em;border-radius:999px;text-decoration:none;border:2px solid currentColor}",
|
|
250
|
+
".mwam-button--primary{background:var(--mwam-accent,#2b2118);color:var(--mwam-on-accent,#fff);border-color:var(--mwam-accent,#2b2118)}",
|
|
251
|
+
`@media (min-width:${String(bp)}px){`,
|
|
252
|
+
".mwam-cols--halves{grid-template-columns:repeat(2,minmax(0,1fr))}",
|
|
253
|
+
".mwam-cols--thirds{grid-template-columns:repeat(3,minmax(0,1fr))}",
|
|
254
|
+
".mwam-cols--wide-left{grid-template-columns:minmax(0,2fr) minmax(0,1fr)}",
|
|
255
|
+
".mwam-cols--wide-right{grid-template-columns:minmax(0,1fr) minmax(0,2fr)}",
|
|
256
|
+
".mwam-cols--main-sidebar{grid-template-columns:minmax(0,1fr) var(--mwam-sidebar,22.5rem)}",
|
|
257
|
+
".mwam-cols--sidebar-main{grid-template-columns:var(--mwam-sidebar,22.5rem) minmax(0,1fr)}",
|
|
258
|
+
`.mwam-col--sticky{position:sticky;top:var(--mwam-sticky-top,${String(top)}px)}`,
|
|
259
|
+
"}",
|
|
260
|
+
`@media (max-width:${String(bp - 1)}px){`,
|
|
261
|
+
// On a phone the booking card set to "bar" is pinned to the bottom of the screen, as WMC's
|
|
262
|
+
// is, and the page leaves room under its last words for it.
|
|
263
|
+
".mwam-snippet--phone-bar{position:fixed;left:0;right:0;bottom:0;z-index:5;margin:0;background:var(--mwam-bar-bg,#fff);box-shadow:0 -1px 0 rgba(0,0,0,.12)}",
|
|
264
|
+
".mwam-page:has(.mwam-snippet--phone-bar){padding-bottom:var(--mwam-bar-room,10rem)}",
|
|
265
|
+
"}",
|
|
266
|
+
...palette
|
|
267
|
+
].join("\n");
|
|
268
|
+
}
|
|
79
269
|
var objectBody = { required_error: "A JSON object body is required", invalid_type_error: "The body must be a JSON object" };
|
|
80
270
|
var EVENT_CATEGORIES = ["MEDITATION", "RETREAT", "DHAMMA_CLASS", "CEREMONY", "OTHER"];
|
|
81
271
|
var ATTENDANCE_MODES = ["OFFLINE", "ONLINE", "MIXED"];
|
|
@@ -90,6 +280,7 @@ var registrationModeSchema = z.enum(REGISTRATION_MODES);
|
|
|
90
280
|
var EVENT_TITLE_MAX = 200;
|
|
91
281
|
var EVENT_SUMMARY_MAX = 500;
|
|
92
282
|
var SEGMENT_LABEL_MAX = 120;
|
|
283
|
+
var SEGMENTS_MAX = 50;
|
|
93
284
|
var SESSION_MAX_MINUTES = 24 * 60;
|
|
94
285
|
var text = (max) => z.string().trim().max(max).refine(noNul, NUL_ISSUE);
|
|
95
286
|
var eventSlugSchema = z.string().min(1).max(120).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "Use lowercase letters, numbers and single hyphens");
|
|
@@ -211,7 +402,7 @@ z.object({
|
|
|
211
402
|
/** Where a DONATION event's amount starts; null starts at the least. */
|
|
212
403
|
suggestedCents: priceCentsSchema.nullable().optional(),
|
|
213
404
|
/** The whole running order at once: a list is a set, not a delta. Omitted leaves it alone. */
|
|
214
|
-
segments: z.array(segmentInput).max(
|
|
405
|
+
segments: z.array(segmentInput).max(SEGMENTS_MAX).optional(),
|
|
215
406
|
/**
|
|
216
407
|
* The `updatedAt` this edit was made against, passed back exactly as the API gave it.
|
|
217
408
|
* Optional, as on a post: without it a PATCH is last-write-wins; with it, the write is
|
|
@@ -378,6 +569,66 @@ var publicEventSummarySchema = z.object({
|
|
|
378
569
|
var publicSessionRowSchema = publicSessionSchema.extend({ event: publicEventSummarySchema });
|
|
379
570
|
var publicSessionListSchema = z.object({ sessions: z.array(publicSessionRowSchema) });
|
|
380
571
|
var publicEventGallerySchema = publicGallerySchema.omit({ event: true });
|
|
572
|
+
var publicTeacherSchema = z.object({
|
|
573
|
+
id: z.string(),
|
|
574
|
+
name: z.string(),
|
|
575
|
+
/** How they are addressed — "Venerable" — written before the name, or null. */
|
|
576
|
+
title: z.string().nullable(),
|
|
577
|
+
bio: z.string().nullable(),
|
|
578
|
+
photo: publicCoverSchema.nullable()
|
|
579
|
+
});
|
|
580
|
+
var publicSnippetBlock = z.object({
|
|
581
|
+
type: z.literal("snippet"),
|
|
582
|
+
/** teacher, dates, schedule, booking, gallery or place. Skip a kind you do not know. */
|
|
583
|
+
kind: z.string(),
|
|
584
|
+
/** The booking card on a phone: where it is, or pinned to the bottom of the screen. */
|
|
585
|
+
phone: z.enum(BOOKING_PHONE).nullable(),
|
|
586
|
+
teacher: publicTeacherSchema.nullable().optional(),
|
|
587
|
+
gallery: publicEventGallerySchema.nullable().optional()
|
|
588
|
+
});
|
|
589
|
+
var publicHtmlBlock = z.object({ type: z.literal("html"), html: z.string() });
|
|
590
|
+
var publicButtonBlock = z.object({ type: z.literal("button"), label: z.string(), href: z.string(), variant: z.enum(BUTTON_VARIANTS) });
|
|
591
|
+
var publicOtherBlock = z.object({ type: z.string() }).passthrough();
|
|
592
|
+
var publicLeafBlock = z.union([publicHtmlBlock, publicButtonBlock, publicSnippetBlock, publicOtherBlock]);
|
|
593
|
+
var publicRowBlock = z.object({
|
|
594
|
+
type: z.literal("row"),
|
|
595
|
+
layout: z.enum(ROW_LAYOUTS),
|
|
596
|
+
columns: z.array(z.object({ align: z.enum(COLUMN_ALIGNS), blocks: z.array(publicLeafBlock) }))
|
|
597
|
+
});
|
|
598
|
+
var publicPageBlock = z.union([publicHtmlBlock, publicButtonBlock, publicSnippetBlock, publicRowBlock, publicOtherBlock]);
|
|
599
|
+
var publicPageSchema = z.object({
|
|
600
|
+
sections: z.array(z.object({
|
|
601
|
+
id: z.string().nullable(),
|
|
602
|
+
/** How the columns share the width. Phones stack them, in order. */
|
|
603
|
+
layout: z.enum(SECTION_LAYOUTS),
|
|
604
|
+
width: z.enum(SECTION_WIDTHS),
|
|
605
|
+
/** One of `style.palette`'s keys, or none. */
|
|
606
|
+
background: z.enum(BACKGROUNDS).nullable(),
|
|
607
|
+
spacing: z.enum(SECTION_SPACINGS),
|
|
608
|
+
columns: z.array(z.object({
|
|
609
|
+
/** Stays in view while the rest of the section scrolls past, on a wide screen. */
|
|
610
|
+
sticky: z.boolean(),
|
|
611
|
+
align: z.enum(COLUMN_ALIGNS),
|
|
612
|
+
blocks: z.array(publicPageBlock)
|
|
613
|
+
}))
|
|
614
|
+
})),
|
|
615
|
+
/** The monastery's own colours and measures, learned from its website (Website style). */
|
|
616
|
+
style: z.object({
|
|
617
|
+
palette: z.array(z.object({
|
|
618
|
+
key: z.enum(BACKGROUNDS),
|
|
619
|
+
/** The site's own CSS variable for it, when it has one. */
|
|
620
|
+
cssVar: z.string().nullable(),
|
|
621
|
+
/** The colour itself, as #rrggbb. */
|
|
622
|
+
color: z.string(),
|
|
623
|
+
/** The text colour that reads on it, as #rrggbb. */
|
|
624
|
+
text: z.string()
|
|
625
|
+
})),
|
|
626
|
+
/** Below this width, in CSS pixels, the site stacks columns. Null: the site's own choice. */
|
|
627
|
+
breakpoint: z.number().int().nullable(),
|
|
628
|
+
/** How far below the top a sticky column stops, in CSS pixels — under the site's header. */
|
|
629
|
+
stickyTop: z.number().int().nullable()
|
|
630
|
+
})
|
|
631
|
+
});
|
|
381
632
|
var publicEventDetailSchema = publicEventSummarySchema.extend({
|
|
382
633
|
bodyHtml: z.string(),
|
|
383
634
|
teacherName: z.string().nullable(),
|
|
@@ -387,7 +638,11 @@ var publicEventDetailSchema = publicEventSummarySchema.extend({
|
|
|
387
638
|
/** Minutes from the session's start — the running order, not clock times. */
|
|
388
639
|
segments: z.array(z.object({ startsMinute: z.number().int(), endsMinute: z.number().int(), label: z.string() })),
|
|
389
640
|
/** Galleries linked to this event in the CRM, published ones only, newest first. */
|
|
390
|
-
galleries: z.array(publicEventGallerySchema)
|
|
641
|
+
galleries: z.array(publicEventGallerySchema),
|
|
642
|
+
/** The page, laid out — or null for a plain description, which is `bodyHtml`. Draw this in place of the description and any sidebar of your own. */
|
|
643
|
+
page: publicPageSchema.nullable(),
|
|
644
|
+
/** The teachers the page shows, in the order it first shows them. */
|
|
645
|
+
teachers: z.array(publicTeacherSchema)
|
|
391
646
|
});
|
|
392
647
|
var publicSeriesSchema = publicSeriesRefSchema.extend({
|
|
393
648
|
summary: z.string().nullable(),
|
|
@@ -856,6 +1111,14 @@ function eventJsonLd(session, event, opts = { url: "" }) {
|
|
|
856
1111
|
}
|
|
857
1112
|
},
|
|
858
1113
|
...opts.organizer === void 0 ? {} : { organizer: { "@type": "Organization", ...opts.organizer } },
|
|
1114
|
+
// The teachers the event's page shows, as schema.org's performers: who leads it.
|
|
1115
|
+
...event.teachers === void 0 || event.teachers.length === 0 ? {} : {
|
|
1116
|
+
performer: event.teachers.map((t) => ({
|
|
1117
|
+
"@type": "Person",
|
|
1118
|
+
name: t.title === null ? t.name : `${t.title} ${t.name}`,
|
|
1119
|
+
...t.photo === null ? {} : { image: t.photo.url }
|
|
1120
|
+
}))
|
|
1121
|
+
},
|
|
859
1122
|
// schema.org's own word for the programme an event belongs to. Only with a URL: a
|
|
860
1123
|
// superEvent Google cannot follow is a name with nothing behind it.
|
|
861
1124
|
...event.series === void 0 || event.series === null || opts.seriesUrl === void 0 ? {} : { superEvent: { "@type": "EventSeries", name: event.series.name, url: opts.seriesUrl } },
|
|
@@ -870,4 +1133,4 @@ function eventJsonLd(session, event, opts = { url: "" }) {
|
|
|
870
1133
|
};
|
|
871
1134
|
}
|
|
872
1135
|
|
|
873
|
-
export { DEFAULT_BASE_URL, MwamError, createClient, eventJsonLd };
|
|
1136
|
+
export { DEFAULT_BASE_URL, MwamError, createClient, eventJsonLd, layoutCss, pageHtml };
|