@perkyzz/emvb 0.2.1 → 0.4.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 +4 -2
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/package.json +3 -1
- package/src/admin/access/role.ts +9 -3
- package/src/admin/api.ts +17 -7
- package/src/admin/content-api.ts +7 -51
- package/src/admin/content-item.ts +22 -0
- package/src/admin/design-api.ts +30 -0
- package/src/admin/editor/A11yCopilot.tsx +126 -0
- package/src/admin/editor/CommandPalette.tsx +118 -0
- package/src/admin/editor/Editor.tsx +188 -152
- package/src/admin/editor/EditorOverlay.tsx +9 -1
- package/src/admin/editor/PerfMeter.tsx +121 -0
- package/src/admin/editor/ShareLink.tsx +164 -0
- package/src/admin/editor/ShortcutsDialog.tsx +4 -1
- package/src/admin/editor/Timeline.tsx +287 -0
- package/src/admin/editor/TopBar.tsx +4 -0
- package/src/admin/editor/canvas/CanvasFrame.tsx +62 -370
- package/src/admin/editor/canvas/DeviceBar.tsx +4 -1
- package/src/admin/editor/canvas/SelectionOverlay.tsx +87 -47
- package/src/admin/editor/canvas/canvas-scale.ts +20 -0
- package/src/admin/editor/canvas/drop-line.ts +24 -0
- package/src/admin/editor/canvas/use-canvas-dnd.ts +207 -0
- package/src/admin/editor/canvas/use-canvas-session.ts +216 -0
- package/src/admin/editor/collection-previews.ts +114 -0
- package/src/admin/editor/editor-chrome.tsx +346 -0
- package/src/admin/editor/editor-commands.ts +360 -0
- package/src/admin/editor/editor-css.ts +5 -3
- package/src/admin/editor/element-chrome.ts +89 -0
- package/src/admin/editor/feature-css.ts +105 -0
- package/src/admin/editor/host.ts +35 -0
- package/src/admin/editor/icons/IconLibraryDialog.tsx +64 -218
- package/src/admin/editor/icons/library.ts +29 -19
- package/src/admin/editor/icons/use-icon-library.ts +315 -0
- package/src/admin/editor/live-data.tsx +71 -0
- package/src/admin/editor/palette-items.ts +136 -0
- package/src/admin/editor/palette.ts +68 -0
- package/src/admin/editor/panels/AddPanel.tsx +48 -68
- package/src/admin/editor/panels/ClassesSection.tsx +5 -1
- package/src/admin/editor/panels/ColorControl.tsx +2 -10
- package/src/admin/editor/panels/ElementPanel.tsx +74 -102
- package/src/admin/editor/panels/LayersPanel.tsx +72 -63
- package/src/admin/editor/panels/LeftPanel.tsx +4 -1
- package/src/admin/editor/panels/SettingsPanel.tsx +13 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +18 -10
- package/src/admin/editor/panels/TokenScales.tsx +168 -0
- package/src/admin/editor/panels/VariableSection.tsx +10 -14
- package/src/admin/editor/panels/inline-error.tsx +11 -0
- package/src/admin/editor/panels/settings/AdvancedFields.tsx +87 -1
- package/src/admin/editor/panels/settings/AudienceEditor.tsx +285 -0
- package/src/admin/editor/panels/settings/BindingsEditor.tsx +221 -0
- package/src/admin/editor/panels/settings/ClassChipInput.tsx +1 -1
- package/src/admin/editor/panels/settings/DraftTextField.tsx +4 -0
- package/src/admin/editor/panels/settings/EffectsControls.tsx +2 -2
- package/src/admin/editor/panels/settings/FormBindControl.tsx +8 -4
- package/src/admin/editor/panels/settings/ItemList.tsx +34 -1
- package/src/admin/editor/panels/settings/MotionControl.tsx +252 -0
- package/src/admin/editor/panels/settings/StateSwitcher.tsx +1 -1
- package/src/admin/editor/panels/settings/StyleRow.tsx +26 -2
- package/src/admin/editor/panels/settings/StyleSources.tsx +94 -0
- package/src/admin/editor/panels/settings/VariableBinding.tsx +1 -1
- package/src/admin/editor/panels/settings/VariantEditor.tsx +83 -0
- package/src/admin/editor/panels/settings/form-names.ts +7 -11
- package/src/admin/editor/panels/settings/length-units.ts +16 -5
- package/src/admin/editor/panels/settings/style-sections.ts +7 -2
- package/src/admin/editor/panels/style-target.ts +105 -0
- package/src/admin/editor/section-templates.ts +43 -21
- package/src/admin/editor/shortcuts.ts +6 -1
- package/src/admin/editor/store.ts +10 -1
- package/src/admin/editor/useClipboardActions.ts +1 -1
- package/src/admin/editor/useEditorCommands.ts +61 -13
- package/src/admin/editor/useEditorData.ts +7 -1
- package/src/admin/editor/useEditorShortcuts.ts +30 -14
- package/src/admin/editor/useNodeActions.ts +44 -16
- package/src/admin/forms-api.ts +17 -6
- package/src/admin/icon-uploads-api.ts +18 -0
- package/src/admin/theme-api.ts +5 -18
- package/src/admin/ui.ts +4 -4
- package/src/astro/content-port.ts +24 -0
- package/src/astro/forms/EmVBFormsClient.astro +11 -0
- package/src/astro/forms/EmVBFormsRuntime.astro +6 -7
- package/src/astro/forms/client.ts +1 -0
- package/src/astro/forms-definitions.ts +24 -11
- package/src/astro/index.ts +1 -0
- package/src/astro/render-session.ts +85 -0
- package/src/astro/request-data.ts +109 -0
- package/src/astro/resolve-theme.ts +184 -64
- package/src/astro/resolve.ts +63 -16
- package/src/astro/theme-posts.ts +48 -5
- package/src/astro/visitor.ts +204 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +282 -0
- package/src/core/arrange.ts +150 -34
- package/src/core/audience/rules.ts +124 -0
- package/src/core/audience/variants.ts +51 -0
- package/src/core/canvas-styles.ts +24 -0
- package/src/core/clipboard.ts +11 -32
- package/src/core/css/generate.ts +29 -2
- package/src/core/css/print.ts +12 -0
- package/src/core/css/scope.ts +3 -3
- package/src/core/css/trace.ts +169 -0
- package/src/core/css-keywords.ts +83 -0
- package/src/core/data/bindings.ts +255 -0
- package/src/core/design/classes.ts +13 -15
- package/src/core/design/diff.ts +55 -0
- package/src/core/design/merge.ts +127 -0
- package/src/core/design/tokens.ts +127 -0
- package/src/core/design/variables.ts +25 -21
- package/src/core/elements/dynamic-elements.ts +117 -2
- package/src/core/elements/form-elements.ts +1 -0
- package/src/core/elements/index.ts +185 -7
- package/src/core/forms/binding.ts +4 -13
- package/src/core/history/diff.ts +152 -0
- package/src/core/index.ts +121 -0
- package/src/core/local-style.ts +27 -0
- package/src/core/migrate/index.ts +12 -4
- package/src/core/nesting.ts +4 -22
- package/src/core/perf/meter.ts +160 -0
- package/src/core/perf/scripts.ts +61 -0
- package/src/core/recipes/index.ts +433 -0
- package/src/core/record.ts +3 -0
- package/src/core/render/context.ts +2 -0
- package/src/core/render/dynamic-post.ts +1 -2
- package/src/core/render/form.ts +133 -10
- package/src/core/render/index.ts +206 -17
- package/src/core/render/loop.ts +54 -7
- package/src/core/render/pagination.ts +9 -1
- package/src/core/render/vnode.ts +12 -2
- package/src/core/sanitize/css.ts +129 -80
- package/src/core/sanitize/motion.ts +129 -0
- package/src/core/sanitize/svg.ts +8 -3
- package/src/core/sanitize/url.ts +10 -1
- package/src/core/schema/design.ts +29 -8
- package/src/core/schema/layout.ts +291 -169
- package/src/core/schema/motion.ts +14 -0
- package/src/core/schema/style.ts +101 -66
- package/src/core/share/link.ts +187 -0
- package/src/core/tabs/presence.ts +7 -17
- package/src/core/theme/dynamic.ts +242 -32
- package/src/core/theme/float.ts +1 -1
- package/src/core/theme/pagination.ts +56 -0
- package/src/core/tree-ops.ts +57 -0
- package/src/index.ts +14 -2
- package/src/server/design-routes.ts +4 -1
- package/src/server/icon-routes.ts +68 -16
- package/src/server/plugin.ts +8 -2
- package/src/admin/editor/icons/sets/fontawesome.json +0 -1
- package/src/admin/editor/icons/sets/lucide.json +0 -1
- package/src/admin/editor/icons/sets/remix.json +0 -1
- package/src/admin/editor/icons/sets/tabler.json +0 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { emdashContent, type ContentPort } from "./content-port.ts";
|
|
2
|
+
import { siteFor } from "./render-session.ts";
|
|
3
|
+
import {
|
|
4
|
+
collectCollectionLoops,
|
|
5
|
+
layoutUsesSource,
|
|
6
|
+
paramsFromSearch,
|
|
7
|
+
siteBindingValues,
|
|
8
|
+
type CollectionLoop,
|
|
9
|
+
type Layout,
|
|
10
|
+
type ThemePostFields,
|
|
11
|
+
type VisitorInfo,
|
|
12
|
+
} from "../core/index.ts";
|
|
13
|
+
import { themePostFromEntry } from "./theme-posts.ts";
|
|
14
|
+
import { abArmsFor, visitorFor, type HostVisitor, type VisitorAstro } from "./visitor.ts";
|
|
15
|
+
|
|
16
|
+
type RequestData = {
|
|
17
|
+
site?: Record<string, string>;
|
|
18
|
+
params?: Record<string, string>;
|
|
19
|
+
origin?: string;
|
|
20
|
+
collections?: Record<string, ThemePostFields[]>;
|
|
21
|
+
abArms?: Record<string, "a" | "b">;
|
|
22
|
+
visitor?: VisitorInfo;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// D1/SQLite columns are snake_case, so orderBy names the columns as stored.
|
|
26
|
+
const ORDER_BY: Record<CollectionLoop["order"], Record<string, "asc" | "desc">> = {
|
|
27
|
+
newest: { published_at: "desc" },
|
|
28
|
+
oldest: { published_at: "asc" },
|
|
29
|
+
title: { title: "asc" },
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** Published entries for one collection Loop (W-308); a failing query lists nothing. */
|
|
33
|
+
async function loopEntries(loop: CollectionLoop, content: ContentPort): Promise<ThemePostFields[]> {
|
|
34
|
+
try {
|
|
35
|
+
const result = await content.getCollection(loop.collection, {
|
|
36
|
+
status: "published",
|
|
37
|
+
limit: loop.limit,
|
|
38
|
+
orderBy: ORDER_BY[loop.order],
|
|
39
|
+
// W-330: field and taxonomy filters; EmDash tells taxonomy names from fields itself.
|
|
40
|
+
...(loop.where ? { where: loop.where } : {}),
|
|
41
|
+
} as never);
|
|
42
|
+
return (result.entries ?? [])
|
|
43
|
+
.map((entry) =>
|
|
44
|
+
themePostFromEntry(entry as never, {
|
|
45
|
+
permalinkPrefix: `/${loop.collection}`,
|
|
46
|
+
...(loop.permalink ? { permalinkPattern: loop.permalink } : {}),
|
|
47
|
+
...(loop.imageField ? { imageField: loop.imageField } : {}),
|
|
48
|
+
...(loop.excerptField ? { excerptField: loop.excerptField } : {}),
|
|
49
|
+
}),
|
|
50
|
+
)
|
|
51
|
+
.filter((post): post is ThemePostFields => post !== null);
|
|
52
|
+
} catch {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The layout plus the synced sections and Loop items it pulls in. Their elements render with the
|
|
59
|
+
* same request data, so A/B tests, visitor rules, bindings and Loops inside them count too.
|
|
60
|
+
*/
|
|
61
|
+
function withTemplates(layout: Layout, templates: readonly Layout[]): Layout {
|
|
62
|
+
if (templates.length === 0) return layout;
|
|
63
|
+
const children = [...layout.root.children, ...templates.flatMap((t) => t.root.children)];
|
|
64
|
+
return { ...layout, root: { ...layout.root, children } };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Live values a layout needs on this request: site settings and URL parameters for bindings
|
|
69
|
+
* (W-307), entries for collection Loops (W-308), A/B arms (W-312) and the visitor (W-313).
|
|
70
|
+
* `templates` are the synced sections and Loop items the layout renders.
|
|
71
|
+
*/
|
|
72
|
+
export async function bindingDataFor(
|
|
73
|
+
page: Layout | null,
|
|
74
|
+
url: URL,
|
|
75
|
+
astro?: VisitorAstro,
|
|
76
|
+
templates: readonly Layout[] = [],
|
|
77
|
+
options: { visitor?: HostVisitor } = {},
|
|
78
|
+
content: ContentPort = emdashContent,
|
|
79
|
+
): Promise<RequestData> {
|
|
80
|
+
if (!page) return {};
|
|
81
|
+
const layout = withTemplates(page, templates);
|
|
82
|
+
const data: RequestData = {};
|
|
83
|
+
// W-312: the visitor's arm of each A/B test, picked here on the server.
|
|
84
|
+
const abArms = astro ? abArmsFor(layout, astro) : undefined;
|
|
85
|
+
if (abArms) data.abArms = abArms;
|
|
86
|
+
// W-313: what the server knows about the visitor, for visitor-aware elements.
|
|
87
|
+
const visitor = astro ? visitorFor(layout, astro, options.visitor) : undefined;
|
|
88
|
+
if (visitor) data.visitor = visitor;
|
|
89
|
+
const loops = collectCollectionLoops(layout);
|
|
90
|
+
if (loops.length > 0) {
|
|
91
|
+
const lists = await Promise.all(loops.map((loop) => loopEntries(loop, content)));
|
|
92
|
+
data.collections = Object.fromEntries(loops.map((loop, i) => [loop.nodeId, lists[i] ?? []]));
|
|
93
|
+
}
|
|
94
|
+
if (layoutUsesSource(layout.root, "param")) {
|
|
95
|
+
data.params = paramsFromSearch(url.searchParams);
|
|
96
|
+
// W-307: URL-parameter links and images stay on this origin unless allowed outside.
|
|
97
|
+
data.origin = url.origin;
|
|
98
|
+
}
|
|
99
|
+
if (layoutUsesSource(layout.root, "site")) {
|
|
100
|
+
try {
|
|
101
|
+
data.site = siteBindingValues(
|
|
102
|
+
await (astro ? siteFor(astro, () => content.getSiteSettings()) : content.getSiteSettings()),
|
|
103
|
+
);
|
|
104
|
+
} catch {
|
|
105
|
+
data.site = {};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return data;
|
|
109
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { emdashContent, type ContentPort } from "./content-port.ts";
|
|
2
|
+
import { formIdsInLayouts } from "./forms-definitions.ts";
|
|
3
3
|
import {
|
|
4
4
|
collectLoopItemPartIds,
|
|
5
|
+
escapeAttr,
|
|
5
6
|
collectSectionPartIds,
|
|
6
7
|
contentPartTypeForContext,
|
|
7
8
|
defaultConditions,
|
|
@@ -31,7 +32,10 @@ import {
|
|
|
31
32
|
type ArchivePagination,
|
|
32
33
|
} from "../core/index.ts";
|
|
33
34
|
import { THEME_PARTS_COLLECTION } from "../constants.ts";
|
|
34
|
-
import {
|
|
35
|
+
import { readLayout, renderStored, type RenderedPage } from "./render.ts";
|
|
36
|
+
import { designFor, formsFor, layoutFor, partsFor } from "./render-session.ts";
|
|
37
|
+
import type { HostVisitor, VisitorAstro } from "./visitor.ts";
|
|
38
|
+
import { bindingDataFor } from "./request-data.ts";
|
|
35
39
|
import { decodePathSegment, themeContextFrom } from "./theme-context.ts";
|
|
36
40
|
import { entryTimestamp, themePostFromEntry } from "./theme-posts.ts";
|
|
37
41
|
|
|
@@ -87,6 +91,8 @@ export type ResolvedThemeParts = {
|
|
|
87
91
|
needsTabsRuntime: boolean;
|
|
88
92
|
/** Hosts load `EmVBMenuRuntime` only when a winning part has a Menu dropdown (W-197). */
|
|
89
93
|
needsMenuRuntime: boolean;
|
|
94
|
+
/** Hosts load `EmVBFormsRuntime` only when a winning part renders a form. */
|
|
95
|
+
needsFormsRuntime: boolean;
|
|
90
96
|
/**
|
|
91
97
|
* True for an archive page past the last one (`/posts/page/9` with no posts there). Hosts
|
|
92
98
|
* answer 404 (W-221). Page 1 with no posts is not a 404.
|
|
@@ -108,7 +114,7 @@ export type ResolvedThemeParts = {
|
|
|
108
114
|
dir?: "ltr" | "rtl" | "auto";
|
|
109
115
|
};
|
|
110
116
|
|
|
111
|
-
type AstroLike = {
|
|
117
|
+
type AstroLike = VisitorAstro & {
|
|
112
118
|
url: URL;
|
|
113
119
|
locals: unknown;
|
|
114
120
|
props?: Record<string, unknown>;
|
|
@@ -159,16 +165,16 @@ const THEME_PARTS_PAGE = 50;
|
|
|
159
165
|
const THEME_PARTS_MAX_PAGES = 20;
|
|
160
166
|
|
|
161
167
|
/** Every published theme part, page by page; a failed page ends the read with what came before. */
|
|
162
|
-
async function
|
|
163
|
-
const entries: Awaited<ReturnType<
|
|
168
|
+
async function fetchPublishedThemeParts(content: ContentPort): Promise<StoredPart[]> {
|
|
169
|
+
const entries: Awaited<ReturnType<ContentPort["getCollection"]>>["entries"] = [];
|
|
164
170
|
let cursor: string | undefined;
|
|
165
171
|
for (let page = 0; page < THEME_PARTS_MAX_PAGES; page += 1) {
|
|
166
|
-
let result: Awaited<ReturnType<
|
|
172
|
+
let result: Awaited<ReturnType<ContentPort["getCollection"]>>;
|
|
167
173
|
try {
|
|
168
174
|
// No orderBy: D1/SQLite columns are snake_case and camelCase orderBy fails the query.
|
|
169
175
|
// Winners and popup order come from updatedAt in core/theme/conditions.ts.
|
|
170
176
|
// oxlint-disable-next-line no-await-in-loop -- each page needs the previous page's cursor
|
|
171
|
-
result = await
|
|
177
|
+
result = await content.getCollection(THEME_PARTS_COLLECTION, {
|
|
172
178
|
status: "published",
|
|
173
179
|
limit: THEME_PARTS_PAGE,
|
|
174
180
|
...(cursor ? { cursor } : {}),
|
|
@@ -184,9 +190,15 @@ async function loadPublishedThemeParts(): Promise<StoredPart[]> {
|
|
|
184
190
|
return entries.map(storedPartFrom).filter((part): part is StoredPart => part !== undefined);
|
|
185
191
|
}
|
|
186
192
|
|
|
193
|
+
function loadPublishedThemeParts(content: ContentPort, request?: object): Promise<StoredPart[]> {
|
|
194
|
+
const load = () => fetchPublishedThemeParts(content);
|
|
195
|
+
return request ? partsFor(request, load) : load();
|
|
196
|
+
}
|
|
197
|
+
|
|
187
198
|
async function loadLoopTemplates(
|
|
188
199
|
layout: Layout,
|
|
189
200
|
parts: StoredPart[],
|
|
201
|
+
request?: object,
|
|
190
202
|
): Promise<Record<string, Layout>> {
|
|
191
203
|
const ids = collectLoopItemPartIds(layout);
|
|
192
204
|
if (ids.length === 0) return {};
|
|
@@ -195,14 +207,18 @@ async function loadLoopTemplates(
|
|
|
195
207
|
for (const id of ids) {
|
|
196
208
|
const part = byId.get(id);
|
|
197
209
|
if (!part || part.partType !== "loop_item") continue;
|
|
198
|
-
const itemLayout =
|
|
210
|
+
const itemLayout = layoutFor(request, part.id, part.layout);
|
|
199
211
|
if (itemLayout) templates[id] = itemLayout;
|
|
200
212
|
}
|
|
201
213
|
return templates;
|
|
202
214
|
}
|
|
203
215
|
|
|
204
216
|
/** Section parts referenced by `layout`, including sections nested inside those parts. */
|
|
205
|
-
function loadSectionTemplates(
|
|
217
|
+
function loadSectionTemplates(
|
|
218
|
+
layout: Layout,
|
|
219
|
+
parts: StoredPart[],
|
|
220
|
+
request?: object,
|
|
221
|
+
): Record<string, Layout> {
|
|
206
222
|
const byId = new Map(parts.map((p) => [p.id, p]));
|
|
207
223
|
const templates: Record<string, Layout> = {};
|
|
208
224
|
const queue = collectSectionPartIds(layout);
|
|
@@ -213,7 +229,7 @@ function loadSectionTemplates(layout: Layout, parts: StoredPart[]): Record<strin
|
|
|
213
229
|
seen.add(id);
|
|
214
230
|
const part = byId.get(id);
|
|
215
231
|
if (!part || part.partType !== "section") continue;
|
|
216
|
-
const itemLayout =
|
|
232
|
+
const itemLayout = layoutFor(request, part.id, part.layout);
|
|
217
233
|
if (!itemLayout) continue;
|
|
218
234
|
templates[id] = itemLayout;
|
|
219
235
|
queue.push(...collectSectionPartIds(itemLayout));
|
|
@@ -221,13 +237,42 @@ function loadSectionTemplates(layout: Layout, parts: StoredPart[]): Record<strin
|
|
|
221
237
|
return templates;
|
|
222
238
|
}
|
|
223
239
|
|
|
224
|
-
/**
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
240
|
+
/** Section and loop-item layouts a layout references, including sections nested in those loop items. */
|
|
241
|
+
async function templatesFrom(
|
|
242
|
+
layout: Layout,
|
|
243
|
+
parts: StoredPart[],
|
|
244
|
+
request?: object,
|
|
245
|
+
): Promise<{ sectionTemplates: Record<string, Layout>; loopTemplates: Record<string, Layout> }> {
|
|
246
|
+
const loopTemplates = await loadLoopTemplates(layout, parts, request);
|
|
247
|
+
const sectionTemplates = loadSectionTemplates(layout, parts, request);
|
|
248
|
+
for (const item of Object.values(loopTemplates)) {
|
|
249
|
+
const nested = loadSectionTemplates(item, parts, request);
|
|
250
|
+
for (const [id, value] of Object.entries(nested)) {
|
|
251
|
+
if (!sectionTemplates[id]) sectionTemplates[id] = value;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return { sectionTemplates, loopTemplates };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** Published section and loop-item layouts a page references. */
|
|
258
|
+
export async function referencedTemplatesFor(
|
|
259
|
+
layout: Layout,
|
|
260
|
+
content: ContentPort = emdashContent,
|
|
261
|
+
request?: object,
|
|
262
|
+
): Promise<{
|
|
263
|
+
sectionTemplates: Record<string, Layout>;
|
|
264
|
+
loopTemplates: Record<string, Layout>;
|
|
265
|
+
}> {
|
|
266
|
+
if (collectSectionPartIds(layout).length === 0 && collectLoopItemPartIds(layout).length === 0) {
|
|
267
|
+
return { sectionTemplates: {}, loopTemplates: {} };
|
|
268
|
+
}
|
|
269
|
+
return templatesFrom(layout, await loadPublishedThemeParts(content, request), request);
|
|
228
270
|
}
|
|
229
271
|
|
|
230
|
-
async function loadSingularPost(
|
|
272
|
+
async function loadSingularPost(
|
|
273
|
+
ctx: ThemeRequestContext,
|
|
274
|
+
content: ContentPort,
|
|
275
|
+
): Promise<ThemePostFields | undefined> {
|
|
231
276
|
if (ctx.kind !== "singular" || ctx.collection !== "posts") return undefined;
|
|
232
277
|
const key = ctx.entryId || undefined;
|
|
233
278
|
// Prefer slug from path `/posts/{slug}` when entry id is missing.
|
|
@@ -235,7 +280,7 @@ async function loadSingularPost(ctx: ThemeRequestContext): Promise<ThemePostFiel
|
|
|
235
280
|
const lookup = key || (pathSlug ? decodePathSegment(pathSlug) : undefined);
|
|
236
281
|
if (!lookup) return undefined;
|
|
237
282
|
try {
|
|
238
|
-
const { entry } = await
|
|
283
|
+
const { entry } = await content.getEntry("posts", lookup);
|
|
239
284
|
if (!entry) return undefined;
|
|
240
285
|
return themePostFromEntry(entry) ?? undefined;
|
|
241
286
|
} catch {
|
|
@@ -244,9 +289,9 @@ async function loadSingularPost(ctx: ThemeRequestContext): Promise<ThemePostFiel
|
|
|
244
289
|
}
|
|
245
290
|
|
|
246
291
|
/** A taxonomy term's label for archive titles; the slug when the term can't be read (W-263). */
|
|
247
|
-
async function termLabel(taxonomy: string, slug: string): Promise<string> {
|
|
292
|
+
async function termLabel(taxonomy: string, slug: string, content: ContentPort): Promise<string> {
|
|
248
293
|
try {
|
|
249
|
-
const term = await getTerm(taxonomy, slug);
|
|
294
|
+
const term = await content.getTerm(taxonomy, slug);
|
|
250
295
|
return term?.label?.trim() || slug;
|
|
251
296
|
} catch {
|
|
252
297
|
return slug;
|
|
@@ -256,6 +301,7 @@ async function termLabel(taxonomy: string, slug: string): Promise<string> {
|
|
|
256
301
|
async function loadArchivePosts(
|
|
257
302
|
ctx: ThemeRequestContext,
|
|
258
303
|
perPage: number,
|
|
304
|
+
content: ContentPort,
|
|
259
305
|
): Promise<{
|
|
260
306
|
posts: ThemePostFields[];
|
|
261
307
|
archiveTitle?: string;
|
|
@@ -280,7 +326,7 @@ async function loadArchivePosts(
|
|
|
280
326
|
} else if (ctx.taxonomy?.type === "tag") {
|
|
281
327
|
filter.where = { tag: ctx.taxonomy.slug };
|
|
282
328
|
}
|
|
283
|
-
const result = await
|
|
329
|
+
const result = await content.getCollection("posts", filter);
|
|
284
330
|
if (result.error || !result.entries) return { posts: [] };
|
|
285
331
|
const hasMore = (result as { hasMore?: boolean }).hasMore === true;
|
|
286
332
|
const posts = result.entries
|
|
@@ -288,7 +334,7 @@ async function loadArchivePosts(
|
|
|
288
334
|
.filter((p): p is ThemePostFields => p !== null);
|
|
289
335
|
// W-263: a category or tag archive is titled by its term's label ("News"), not its slug.
|
|
290
336
|
const archiveTitle = ctx.taxonomy?.slug
|
|
291
|
-
? await termLabel(ctx.taxonomy.type, ctx.taxonomy.slug)
|
|
337
|
+
? await termLabel(ctx.taxonomy.type, ctx.taxonomy.slug, content)
|
|
292
338
|
: ctx.collection === "posts"
|
|
293
339
|
? "Posts"
|
|
294
340
|
: undefined;
|
|
@@ -303,20 +349,25 @@ async function buildDynamicForContent(
|
|
|
303
349
|
ctx: ThemeRequestContext,
|
|
304
350
|
layout: Layout,
|
|
305
351
|
parts: StoredPart[],
|
|
352
|
+
content: ContentPort,
|
|
353
|
+
request?: object,
|
|
306
354
|
): Promise<ThemeDynamicData | undefined> {
|
|
307
|
-
const loopTemplates = await
|
|
308
|
-
const sectionTemplates = loadSectionTemplates(layout, parts);
|
|
355
|
+
const { sectionTemplates, loopTemplates } = await templatesFrom(layout, parts, request);
|
|
309
356
|
const referenced: ThemeDynamicData = {
|
|
310
357
|
...(Object.keys(loopTemplates).length > 0 ? { loopTemplates } : {}),
|
|
311
358
|
...(Object.keys(sectionTemplates).length > 0 ? { sectionTemplates } : {}),
|
|
312
359
|
};
|
|
313
360
|
if (partType === "single_post") {
|
|
314
|
-
const post = await loadSingularPost(ctx);
|
|
361
|
+
const post = await loadSingularPost(ctx, content);
|
|
315
362
|
if (!post && Object.keys(referenced).length === 0) return undefined;
|
|
316
363
|
return { ...referenced, post };
|
|
317
364
|
}
|
|
318
365
|
if (partType === "archive") {
|
|
319
|
-
const { posts, archiveTitle, pagination } = await loadArchivePosts(
|
|
366
|
+
const { posts, archiveTitle, pagination } = await loadArchivePosts(
|
|
367
|
+
ctx,
|
|
368
|
+
loopPerPage(layout),
|
|
369
|
+
content,
|
|
370
|
+
);
|
|
320
371
|
return { ...referenced, posts, archiveTitle, ...(pagination ? { pagination } : {}) };
|
|
321
372
|
}
|
|
322
373
|
if (Object.keys(referenced).length > 0) return referenced;
|
|
@@ -331,6 +382,18 @@ async function buildDynamicForContent(
|
|
|
331
382
|
export async function resolveThemeParts(
|
|
332
383
|
astro: AstroLike,
|
|
333
384
|
ctx?: ThemeRequestContext,
|
|
385
|
+
/** What the host knows about the visitor: segments and facts Visitors rules use (W-329). */
|
|
386
|
+
options: { visitor?: HostVisitor } = {},
|
|
387
|
+
): Promise<ResolvedThemeParts> {
|
|
388
|
+
return resolveThemePartsWith(emdashContent, astro, ctx, options);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** Same as `resolveThemeParts`, with a content port so tests can pass a fake (W-359). */
|
|
392
|
+
export async function resolveThemePartsWith(
|
|
393
|
+
port: ContentPort,
|
|
394
|
+
astro: AstroLike,
|
|
395
|
+
ctx?: ThemeRequestContext,
|
|
396
|
+
options: { visitor?: HostVisitor } = {},
|
|
334
397
|
): Promise<ResolvedThemeParts> {
|
|
335
398
|
const context =
|
|
336
399
|
ctx ??
|
|
@@ -352,13 +415,14 @@ export async function resolveThemeParts(
|
|
|
352
415
|
needsFloatsRuntime: false,
|
|
353
416
|
needsTabsRuntime: false,
|
|
354
417
|
needsMenuRuntime: false,
|
|
418
|
+
needsFormsRuntime: false,
|
|
355
419
|
notFound: false,
|
|
356
420
|
...(context.kind === "archive" && !context.isSearch
|
|
357
421
|
? { canonicalPath: archivePagePath(context.path, context.page ?? 1) }
|
|
358
422
|
: {}),
|
|
359
423
|
};
|
|
360
424
|
|
|
361
|
-
const parts = await loadPublishedThemeParts();
|
|
425
|
+
const parts = await loadPublishedThemeParts(port, astro);
|
|
362
426
|
if (parts.length === 0) return empty;
|
|
363
427
|
|
|
364
428
|
const candidates: ThemePartCandidate[] = parts.map((part) => ({
|
|
@@ -385,19 +449,49 @@ export async function resolveThemeParts(
|
|
|
385
449
|
return empty;
|
|
386
450
|
}
|
|
387
451
|
|
|
388
|
-
const handler =
|
|
389
|
-
const design = await
|
|
452
|
+
const handler = port.pluginHandler(astro.locals as never);
|
|
453
|
+
const design = await designFor(astro, handler, astro.url);
|
|
390
454
|
|
|
391
455
|
const byId = new Map(parts.map((part) => [part.id, part]));
|
|
392
456
|
const rendered: RenderedPage[] = [];
|
|
393
|
-
|
|
394
|
-
|
|
457
|
+
// W-307: bound fields in a part read site settings and URL parameters too.
|
|
458
|
+
// W-312/W-313: synced sections and Loop items the part uses count too.
|
|
459
|
+
const boundFor = (stored: StoredPart, referenced: ThemeDynamicData | undefined) =>
|
|
460
|
+
bindingDataFor(
|
|
461
|
+
readLayout(stored.layout),
|
|
462
|
+
astro.url,
|
|
463
|
+
astro,
|
|
464
|
+
[
|
|
465
|
+
...Object.values(referenced?.sectionTemplates ?? {}),
|
|
466
|
+
...Object.values(referenced?.loopTemplates ?? {}),
|
|
467
|
+
],
|
|
468
|
+
options.visitor ? { visitor: options.visitor } : {},
|
|
469
|
+
port,
|
|
470
|
+
);
|
|
471
|
+
const renderOne = async (
|
|
472
|
+
stored: StoredPart,
|
|
473
|
+
partDynamic: ThemeDynamicData | undefined,
|
|
474
|
+
bound: Awaited<ReturnType<typeof bindingDataFor>>,
|
|
475
|
+
) => {
|
|
476
|
+
const dynamic = Object.keys(bound).length > 0 ? { ...partDynamic, ...bound } : partDynamic;
|
|
477
|
+
const formDefinitions = await formsFor(
|
|
478
|
+
astro,
|
|
479
|
+
handler,
|
|
480
|
+
astro.url,
|
|
481
|
+
formIdsInLayouts([
|
|
482
|
+
readLayout(stored.layout),
|
|
483
|
+
...Object.values(dynamic?.sectionTemplates ?? {}),
|
|
484
|
+
...Object.values(dynamic?.loopTemplates ?? {}),
|
|
485
|
+
]),
|
|
486
|
+
);
|
|
487
|
+
const page = renderStored(stored.layout, design, stored.id, formDefinitions, dynamic);
|
|
395
488
|
rendered.push(page);
|
|
396
489
|
// W-216: a header or footer part is the page's banner or contentinfo landmark (hosts put it
|
|
397
490
|
// straight in <body> instead of their own <header>/<footer>).
|
|
398
491
|
const tag = WRAPPER_TAGS[stored.partType] ?? "div";
|
|
492
|
+
const partId = escapeAttr(stored.id);
|
|
399
493
|
const html = page.html
|
|
400
|
-
? `<${tag} class="emvb-theme-${stored.partType}" data-emvb-theme-part="${
|
|
494
|
+
? `<${tag} class="emvb-theme-${stored.partType}" data-emvb-theme-part="${partId}">${page.html}</${tag}>`
|
|
401
495
|
: "";
|
|
402
496
|
return { html, css: page.css };
|
|
403
497
|
};
|
|
@@ -405,8 +499,9 @@ export async function resolveThemeParts(
|
|
|
405
499
|
/** Synced sections and loop items a part uses, for every part type (W-200). */
|
|
406
500
|
const templatesFor = async (stored: StoredPart): Promise<ThemeDynamicData | undefined> => {
|
|
407
501
|
const layout = readLayout(stored.layout);
|
|
408
|
-
const sectionTemplates
|
|
409
|
-
|
|
502
|
+
const { sectionTemplates, loopTemplates } = layout
|
|
503
|
+
? await templatesFrom(layout, parts, astro)
|
|
504
|
+
: { sectionTemplates: {}, loopTemplates: {} };
|
|
410
505
|
return Object.keys(sectionTemplates).length > 0 || Object.keys(loopTemplates).length > 0
|
|
411
506
|
? {
|
|
412
507
|
...(Object.keys(loopTemplates).length > 0 ? { loopTemplates } : {}),
|
|
@@ -428,7 +523,7 @@ export async function resolveThemeParts(
|
|
|
428
523
|
layout && winner === contentWinner
|
|
429
524
|
? {
|
|
430
525
|
...referenced,
|
|
431
|
-
...(await buildDynamicForContent(stored.partType, context, layout, parts)),
|
|
526
|
+
...(await buildDynamicForContent(stored.partType, context, layout, parts, port, astro)),
|
|
432
527
|
}
|
|
433
528
|
: referenced;
|
|
434
529
|
// A page past the last one has no posts; the host answers 404 (W-221).
|
|
@@ -438,7 +533,7 @@ export async function resolveThemeParts(
|
|
|
438
533
|
if (winner === contentWinner && (dynamic?.pagination?.page ?? 1) > 1) {
|
|
439
534
|
pastLastPage = (dynamic?.posts ?? []).length === 0;
|
|
440
535
|
}
|
|
441
|
-
const { html, css } = renderOne(stored, dynamic);
|
|
536
|
+
const { html, css } = await renderOne(stored, dynamic, await boundFor(stored, referenced));
|
|
442
537
|
return { id: stored.id, title: stored.title, partType: stored.partType, html, css };
|
|
443
538
|
};
|
|
444
539
|
|
|
@@ -454,36 +549,60 @@ export async function resolveThemeParts(
|
|
|
454
549
|
extraParts.map(async (stored) => [stored.id, await templatesFor(stored)] as const),
|
|
455
550
|
),
|
|
456
551
|
);
|
|
552
|
+
const extraBound = new Map(
|
|
553
|
+
await Promise.all(
|
|
554
|
+
extraParts.map(
|
|
555
|
+
async (stored) =>
|
|
556
|
+
[stored.id, await boundFor(stored, extraTemplates.get(stored.id))] as const,
|
|
557
|
+
),
|
|
558
|
+
),
|
|
559
|
+
);
|
|
457
560
|
|
|
458
|
-
const popups
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
561
|
+
const popups = (
|
|
562
|
+
await Promise.all(
|
|
563
|
+
popupMatches.map(async (match) => {
|
|
564
|
+
const stored = byId.get(match.id);
|
|
565
|
+
if (!stored) return null;
|
|
566
|
+
const { html, css } = await renderOne(
|
|
567
|
+
stored,
|
|
568
|
+
extraTemplates.get(stored.id),
|
|
569
|
+
extraBound.get(stored.id) ?? {},
|
|
570
|
+
);
|
|
571
|
+
const popup: RenderedPopup = {
|
|
572
|
+
id: stored.id,
|
|
573
|
+
title: stored.title,
|
|
574
|
+
html: wrapPopupMarkup(stored.id, html, stored.triggers),
|
|
575
|
+
css,
|
|
576
|
+
triggers: stored.triggers,
|
|
577
|
+
};
|
|
578
|
+
return popup;
|
|
579
|
+
}),
|
|
580
|
+
)
|
|
581
|
+
).filter((popup): popup is RenderedPopup => popup !== null);
|
|
582
|
+
|
|
583
|
+
const floats = (
|
|
584
|
+
await Promise.all(
|
|
585
|
+
floatMatches.map(async (match) => {
|
|
586
|
+
const stored = byId.get(match.id);
|
|
587
|
+
if (!stored) return null;
|
|
588
|
+
const { html, css } = await renderOne(
|
|
589
|
+
stored,
|
|
590
|
+
extraTemplates.get(stored.id),
|
|
591
|
+
extraBound.get(stored.id) ?? {},
|
|
592
|
+
);
|
|
593
|
+
const layout = readLayout(stored.layout);
|
|
594
|
+
const surface = !layout || !floatHasOwnSurface(layout, design);
|
|
595
|
+
const item: RenderedFloat = {
|
|
596
|
+
id: stored.id,
|
|
597
|
+
title: stored.title,
|
|
598
|
+
html: wrapFloatMarkup(stored.id, stored.title, html, stored.float, surface),
|
|
599
|
+
css,
|
|
600
|
+
settings: stored.float,
|
|
601
|
+
};
|
|
602
|
+
return item;
|
|
603
|
+
}),
|
|
604
|
+
)
|
|
605
|
+
).filter((item): item is RenderedFloat => item !== null);
|
|
487
606
|
|
|
488
607
|
const cssParts = [
|
|
489
608
|
header?.css,
|
|
@@ -506,6 +625,7 @@ export async function resolveThemeParts(
|
|
|
506
625
|
needsFloatsRuntime: floats.length > 0,
|
|
507
626
|
needsTabsRuntime: rendered.some((page) => page.needsTabsRuntime),
|
|
508
627
|
needsMenuRuntime: rendered.some((page) => page.needsMenuRuntime),
|
|
628
|
+
needsFormsRuntime: rendered.some((page) => page.needsFormsRuntime),
|
|
509
629
|
notFound: pastLastPage,
|
|
510
630
|
...(design.direction ? { dir: design.direction } : {}),
|
|
511
631
|
...(archiveInfo?.title ? { archiveTitle: archiveInfo.title } : {}),
|
package/src/astro/resolve.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { decodeSlug, getEmDashEntry } from "emdash";
|
|
2
|
-
import { getPublicPluginApiRouteHandler } from "emdash/plugin-utils";
|
|
3
1
|
import { PAGES_COLLECTION } from "../constants.ts";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { emdashContent, type ContentPort } from "./content-port.ts";
|
|
3
|
+
import { formIdsInLayouts } from "./forms-definitions.ts";
|
|
4
|
+
import { readLayout, renderStored, type RenderedPage } from "./render.ts";
|
|
5
|
+
import { designFor, formsFor } from "./render-session.ts";
|
|
6
|
+
import { bindingDataFor } from "./request-data.ts";
|
|
7
|
+
import type { HostVisitor, VisitorAstro } from "./visitor.ts";
|
|
8
|
+
import { referencedTemplatesFor } from "./resolve-theme.ts";
|
|
7
9
|
|
|
8
|
-
type EmDashEntry = NonNullable<Awaited<ReturnType<
|
|
10
|
+
type EmDashEntry = NonNullable<Awaited<ReturnType<ContentPort["getEntry"]>>["entry"]>;
|
|
9
11
|
|
|
10
12
|
export type ResolvedEmVBPage = RenderedPage & {
|
|
11
13
|
/** The EmDash entry, for `getSeoMeta` and the host's layout. */
|
|
@@ -16,7 +18,7 @@ export type ResolvedEmVBPage = RenderedPage & {
|
|
|
16
18
|
isPreview: boolean;
|
|
17
19
|
};
|
|
18
20
|
|
|
19
|
-
type AstroLike = {
|
|
21
|
+
type AstroLike = VisitorAstro & {
|
|
20
22
|
params: Record<string, string | undefined>;
|
|
21
23
|
url: URL;
|
|
22
24
|
locals: unknown;
|
|
@@ -25,16 +27,37 @@ type AstroLike = {
|
|
|
25
27
|
/**
|
|
26
28
|
* Looks up the published EmVB page for this request's slug (or its draft under a preview token),
|
|
27
29
|
* so a host route can try EmVB first and fall through to its own content (R-030, R-052).
|
|
30
|
+
* A fixed route such as `/` passes the page's slug explicitly: `{ slug: "home" }`.
|
|
28
31
|
*/
|
|
29
32
|
export async function resolveEmVBPage(
|
|
30
33
|
astro: AstroLike,
|
|
31
|
-
options: {
|
|
34
|
+
options: {
|
|
35
|
+
/** The route parameter that holds the URL-encoded slug (default `"slug"`). */
|
|
36
|
+
param?: string;
|
|
37
|
+
/** The page's slug, used as-is (not URL-decoded) in place of the route parameter. */
|
|
38
|
+
slug?: string;
|
|
39
|
+
/** What the host knows about the visitor: segments and facts Visitors rules use (W-329). */
|
|
40
|
+
visitor?: HostVisitor;
|
|
41
|
+
} = {},
|
|
32
42
|
): Promise<ResolvedEmVBPage | null> {
|
|
33
|
-
|
|
43
|
+
return resolveEmVBPageWith(emdashContent, astro, options);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Same as `resolveEmVBPage`, with a content port so tests can pass a fake (W-359). */
|
|
47
|
+
export async function resolveEmVBPageWith(
|
|
48
|
+
content: ContentPort,
|
|
49
|
+
astro: AstroLike,
|
|
50
|
+
options: {
|
|
51
|
+
param?: string;
|
|
52
|
+
slug?: string;
|
|
53
|
+
visitor?: HostVisitor;
|
|
54
|
+
} = {},
|
|
55
|
+
): Promise<ResolvedEmVBPage | null> {
|
|
56
|
+
const slug = options.slug ?? content.decodeSlug(astro.params[options.param ?? "slug"]);
|
|
34
57
|
if (!slug) return null;
|
|
35
|
-
let found: Awaited<ReturnType<
|
|
58
|
+
let found: Awaited<ReturnType<ContentPort["getEntry"]>>;
|
|
36
59
|
try {
|
|
37
|
-
found = await
|
|
60
|
+
found = await content.getEntry(PAGES_COLLECTION, slug);
|
|
38
61
|
} catch {
|
|
39
62
|
// No emvb_pages collection yet (EmVB not set up): not an EmVB page.
|
|
40
63
|
return null;
|
|
@@ -42,20 +65,44 @@ export async function resolveEmVBPage(
|
|
|
42
65
|
const entry = found.entry;
|
|
43
66
|
if (!entry) return null;
|
|
44
67
|
const data = entry.data as Record<string, unknown>;
|
|
45
|
-
const handler =
|
|
46
|
-
const design = await
|
|
68
|
+
const handler = content.pluginHandler(astro.locals as never);
|
|
69
|
+
const design = await designFor(astro, handler, astro.url);
|
|
47
70
|
const layout = readLayout(data["layout"]);
|
|
71
|
+
const referenced = layout
|
|
72
|
+
? await referencedTemplatesFor(layout, content, astro)
|
|
73
|
+
: { sectionTemplates: {}, loopTemplates: {} };
|
|
74
|
+
const { sectionTemplates, loopTemplates } = referenced;
|
|
48
75
|
const formDefinitions = layout
|
|
49
|
-
? await
|
|
76
|
+
? await formsFor(
|
|
77
|
+
astro,
|
|
78
|
+
handler,
|
|
79
|
+
astro.url,
|
|
80
|
+
formIdsInLayouts([
|
|
81
|
+
layout,
|
|
82
|
+
...Object.values(sectionTemplates),
|
|
83
|
+
...Object.values(loopTemplates),
|
|
84
|
+
]),
|
|
85
|
+
)
|
|
50
86
|
: undefined;
|
|
51
|
-
const
|
|
87
|
+
const dynamic = {
|
|
88
|
+
...(Object.keys(sectionTemplates).length > 0 ? { sectionTemplates } : {}),
|
|
89
|
+
...(Object.keys(loopTemplates).length > 0 ? { loopTemplates } : {}),
|
|
90
|
+
...(await bindingDataFor(
|
|
91
|
+
layout,
|
|
92
|
+
astro.url,
|
|
93
|
+
astro,
|
|
94
|
+
Object.values(sectionTemplates),
|
|
95
|
+
options.visitor ? { visitor: options.visitor } : {},
|
|
96
|
+
content,
|
|
97
|
+
)),
|
|
98
|
+
};
|
|
52
99
|
return {
|
|
53
100
|
...renderStored(
|
|
54
101
|
data["layout"],
|
|
55
102
|
design,
|
|
56
103
|
String(data["id"] ?? slug),
|
|
57
104
|
formDefinitions,
|
|
58
|
-
Object.keys(
|
|
105
|
+
Object.keys(dynamic).length > 0 ? dynamic : undefined,
|
|
59
106
|
),
|
|
60
107
|
entry,
|
|
61
108
|
title: typeof data["title"] === "string" ? data["title"] : "",
|