@nickpaustian/tela 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +50 -2
- package/bin/tela.ts +160 -0
- package/lib/index.js +751 -0
- package/lib/vite.js +64 -0
- package/package.json +71 -4
- package/routes/_layout.html +15 -0
- package/routes/_plain.html +17 -0
- package/routes/collections/[collection]/[id].html +3 -0
- package/routes/collections/[collection]/index.html +3 -0
- package/routes/index.html +3 -0
- package/routes/login.html +6 -0
- package/routes/media.html +3 -0
- package/routes/unpublished.html +3 -0
- package/scripts/check-components.ts +9 -0
- package/scripts/create-user.ts +50 -0
- package/scripts/media-words.ts +79 -0
- package/scripts/set-password.ts +72 -0
- package/src/api.ts +172 -0
- package/src/auth/login.ts +41 -0
- package/src/auth/sessions.ts +131 -0
- package/src/auth/setup.ts +47 -0
- package/src/collections/exhibitions/StatusSummary.lsp +76 -0
- package/src/collections/exhibitions/panels.ts +53 -0
- package/src/collections/exhibitions/schema.ts +203 -0
- package/src/collections/index.ts +20 -0
- package/src/collections/people/schema.ts +16 -0
- package/src/collections/users/schema.ts +18 -0
- package/src/collections/venues/schema.ts +37 -0
- package/src/components/BlockField.lsp +275 -0
- package/src/components/CharacterCount.lsp +161 -0
- package/src/components/ChoiceField.lsp +129 -0
- package/src/components/ChoiceSummary.lsp +32 -0
- package/src/components/CollectionList.lsp +100 -0
- package/src/components/DateField.lsp +46 -0
- package/src/components/DateRangeField.lsp +174 -0
- package/src/components/EntryCompare.lsp +815 -0
- package/src/components/EntryEditor.lsp +2948 -0
- package/src/components/EntryList.lsp +913 -0
- package/src/components/Field.lsp +293 -0
- package/src/components/FilterBar.lsp +237 -0
- package/src/components/GroupField.lsp +290 -0
- package/src/components/LoginForm.lsp +321 -0
- package/src/components/MarkdownField.lsp +1858 -0
- package/src/components/MediaLibrary.lsp +119 -0
- package/src/components/MediaPickerField.lsp +326 -0
- package/src/components/MediaUpload.lsp +226 -0
- package/src/components/NoteField.lsp +31 -0
- package/src/components/NumberField.lsp +37 -0
- package/src/components/ReferenceField.lsp +588 -0
- package/src/components/ReferenceSummary.lsp +87 -0
- package/src/components/RepeaterField.lsp +1517 -0
- package/src/components/SharePreviewField.lsp +631 -0
- package/src/components/Sidebar.lsp +467 -0
- package/src/components/SlugField.lsp +183 -0
- package/src/components/TextField.lsp +36 -0
- package/src/components/ThumbnailSummary.lsp +75 -0
- package/src/components/UnpublishedList.lsp +272 -0
- package/src/components/UseWordsField.lsp +59 -0
- package/src/components/chips.css +32 -0
- package/src/components/control-focus.css +13 -0
- package/src/components/control.css +32 -0
- package/src/components/disclosure.css +42 -0
- package/src/components/reorder.ts +184 -0
- package/src/components/visibility.ts +33 -0
- package/src/config/check.ts +122 -0
- package/src/config/components.ts +232 -0
- package/src/config/fields.ts +103 -0
- package/src/config/icons.ts +122 -0
- package/src/config/load.ts +17 -0
- package/src/config/navigation.ts +54 -0
- package/src/config/permissions.ts +418 -0
- package/src/config/seo.ts +163 -0
- package/src/config/types.ts +1384 -0
- package/src/content/access.ts +212 -0
- package/src/content/anchors.ts +34 -0
- package/src/content/changes.ts +139 -0
- package/src/content/collections.ts +20 -0
- package/src/content/compare-page.ts +206 -0
- package/src/content/compare.ts +269 -0
- package/src/content/counter.ts +139 -0
- package/src/content/derive-values.ts +117 -0
- package/src/content/derive.ts +108 -0
- package/src/content/dialect-extras.ts +110 -0
- package/src/content/entries.ts +349 -0
- package/src/content/entry.ts +155 -0
- package/src/content/export.ts +508 -0
- package/src/content/filters.ts +113 -0
- package/src/content/git.ts +216 -0
- package/src/content/governing.ts +23 -0
- package/src/content/history.ts +160 -0
- package/src/content/links.ts +55 -0
- package/src/content/markdown.ts +270 -0
- package/src/content/person.ts +24 -0
- package/src/content/preview.ts +31 -0
- package/src/content/references.ts +490 -0
- package/src/content/releases.ts +350 -0
- package/src/content/richtext.ts +885 -0
- package/src/content/rules.ts +274 -0
- package/src/content/sharing.ts +237 -0
- package/src/content/store.ts +142 -0
- package/src/content/summary.ts +409 -0
- package/src/content/surface-markdown.ts +169 -0
- package/src/content/unpublished.ts +115 -0
- package/src/content/url.ts +120 -0
- package/src/content/users.ts +235 -0
- package/src/content/validate.ts +305 -0
- package/src/content/visibility.ts +26 -0
- package/src/content/workflow.ts +531 -0
- package/src/db/client.ts +46 -0
- package/src/db/migrate.ts +122 -0
- package/src/db/migrations/001-initial.sql +69 -0
- package/src/db/migrations/002-releases.sql +58 -0
- package/src/db/migrations/003-soft-delete.sql +15 -0
- package/src/db/migrations/004-roles.sql +10 -0
- package/src/db/migrations/005-approvals.sql +55 -0
- package/src/db/migrations/006-version-author.sql +9 -0
- package/src/db/migrations/007-draft-saves.sql +17 -0
- package/src/editor.ts +11 -0
- package/src/index.ts +32 -0
- package/src/main.ts +74 -0
- package/src/media/image.ts +111 -0
- package/src/media/index.ts +147 -0
- package/src/media/local.ts +82 -0
- package/src/media/pseudolux.ts +504 -0
- package/src/media/s3.ts +154 -0
- package/src/media/sigv4.ts +157 -0
- package/src/media/store.ts +298 -0
- package/src/media-library.ts +177 -0
- package/src/project.ts +46 -0
- package/src/server/index.ts +2034 -0
- package/src/server/library-routes.ts +496 -0
- package/src/styles/base.css +197 -0
- package/src/styles/fonts/LICENSE-inter.txt +93 -0
- package/src/styles/fonts/inter-latin-ext-wght-italic.woff2 +0 -0
- package/src/styles/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
- package/src/styles/fonts/inter-latin-wght-italic.woff2 +0 -0
- package/src/styles/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/src/styles/fonts.css +40 -0
- package/src/styles/icons.css +63 -0
- package/src/styles/tokens.css +177 -0
- package/src/styles/type-icons.css +50 -0
- package/src/styles/ui.css +605 -0
- package/src/tooltip.ts +343 -0
- package/src/types.d.ts +7 -0
- package/src/ui.ts +252 -0
- package/src/vite.ts +77 -0
- package/src/waiting.ts +24 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,751 @@
|
|
|
1
|
+
// src/config/fields.ts
|
|
2
|
+
function slugField({ from = "title", label = "Slug" } = {}) {
|
|
3
|
+
return {
|
|
4
|
+
name: "slug",
|
|
5
|
+
type: "text",
|
|
6
|
+
component: "slug",
|
|
7
|
+
from,
|
|
8
|
+
label,
|
|
9
|
+
required: true,
|
|
10
|
+
unique: true,
|
|
11
|
+
patterns: [
|
|
12
|
+
{
|
|
13
|
+
pattern: "^[a-z0-9-]+$",
|
|
14
|
+
message: "Use lowercase letters, numbers and hyphens."
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
pattern: "^[a-z0-9](?:.*[a-z0-9])?$",
|
|
18
|
+
message: "A slug cannot begin or end with a hyphen."
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
pattern: "^(?!.*--).*$",
|
|
22
|
+
message: "Use a single hyphen between words."
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function imageUse(name, label, options = {}) {
|
|
28
|
+
return {
|
|
29
|
+
name,
|
|
30
|
+
label,
|
|
31
|
+
type: "block",
|
|
32
|
+
fields: [
|
|
33
|
+
{
|
|
34
|
+
name: "picture",
|
|
35
|
+
type: "reference",
|
|
36
|
+
to: "media",
|
|
37
|
+
label: "Picture",
|
|
38
|
+
...options.required ? { required: true } : {},
|
|
39
|
+
...options.picker ? { component: "mediaPicker" } : {},
|
|
40
|
+
options: { singular: "an image", ...options.hint ? { hint: options.hint } : {} }
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "alt",
|
|
44
|
+
type: "text",
|
|
45
|
+
label: "Alt text for this use",
|
|
46
|
+
component: "useWords",
|
|
47
|
+
maxLength: 500,
|
|
48
|
+
when: { field: "picture", set: true },
|
|
49
|
+
options: { from: "picture", word: "altText" }
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "credit",
|
|
53
|
+
type: "text",
|
|
54
|
+
label: "Credit for this use",
|
|
55
|
+
component: "useWords",
|
|
56
|
+
maxLength: 300,
|
|
57
|
+
when: { field: "picture", set: true },
|
|
58
|
+
options: { from: "picture", word: "credit" }
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// src/config/seo.ts
|
|
65
|
+
var SEO_FIELDS = {
|
|
66
|
+
title: "metaTitle",
|
|
67
|
+
description: "metaDescription",
|
|
68
|
+
image: "shareImage",
|
|
69
|
+
hidden: "noindex",
|
|
70
|
+
preview: "sharing"
|
|
71
|
+
};
|
|
72
|
+
var lower = (label) => label.charAt(0).toLowerCase() + label.slice(1);
|
|
73
|
+
function seoGroup(collection, siteName) {
|
|
74
|
+
if (!collection.seo)
|
|
75
|
+
return null;
|
|
76
|
+
const options = collection.seo === true ? {} : collection.seo;
|
|
77
|
+
const at = `Collection "${collection.name}" seo`;
|
|
78
|
+
const named = (name) => {
|
|
79
|
+
const field = collection.fields.find((one) => one.name === name);
|
|
80
|
+
if (!field)
|
|
81
|
+
throw new Error(`${at}: falls back to "${name}", which is not one of its fields.`);
|
|
82
|
+
return field;
|
|
83
|
+
};
|
|
84
|
+
const labelOf = (name) => lower(named(name).label ?? name);
|
|
85
|
+
const titleField = collection.titleField ?? "title";
|
|
86
|
+
const suffix = options.titleSuffix === false ? "" : options.titleSuffix ?? (siteName ? ` | ${siteName}` : "");
|
|
87
|
+
const describedBy = options.description?.fallback ?? [];
|
|
88
|
+
const image = options.image === false ? null : options.image ?? {};
|
|
89
|
+
const picturedBy = image?.fallback ?? [];
|
|
90
|
+
for (const name of [...describedBy, ...picturedBy])
|
|
91
|
+
named(name);
|
|
92
|
+
const fields = [
|
|
93
|
+
{
|
|
94
|
+
name: SEO_FIELDS.title,
|
|
95
|
+
type: "text",
|
|
96
|
+
label: "Title for search results",
|
|
97
|
+
maxLength: 70,
|
|
98
|
+
counter: { target: options.title?.target ?? 60, ...suffix ? { adds: suffix } : {} },
|
|
99
|
+
options: {
|
|
100
|
+
hint: options.title?.hint ?? `Leave empty to use the ${collection.fields.some((one) => one.name === titleField) ? labelOf(titleField) : "title"}.`
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: SEO_FIELDS.description,
|
|
105
|
+
type: "text",
|
|
106
|
+
label: "Description for search results",
|
|
107
|
+
maxLength: 160,
|
|
108
|
+
counter: { target: options.description?.target ?? [120, 160] },
|
|
109
|
+
options: {
|
|
110
|
+
hint: options.description?.hint ?? (describedBy.length ? `Leave empty to use the ${labelOf(describedBy[0])}.` : "Leave empty and search engines choose their own.")
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
];
|
|
114
|
+
if (image) {
|
|
115
|
+
fields.push(imageUse(SEO_FIELDS.image, "Image for sharing", {
|
|
116
|
+
...options.picker ? { picker: true } : {},
|
|
117
|
+
hint: image.hint ?? "Shown when a link to this is shared. Wide, at least 1200 × 630 pixels." + (picturedBy.length ? ` Leave empty to use the ${labelOf(picturedBy[0])}.` : "")
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
if (options.hidden !== false) {
|
|
121
|
+
fields.push({
|
|
122
|
+
name: SEO_FIELDS.hidden,
|
|
123
|
+
type: "boolean",
|
|
124
|
+
component: "toggle",
|
|
125
|
+
label: "Search engines",
|
|
126
|
+
options: { on: "Hidden from search engines", off: "Search engines can find this" }
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (options.preview !== false) {
|
|
130
|
+
fields.push({
|
|
131
|
+
name: SEO_FIELDS.preview,
|
|
132
|
+
type: "note",
|
|
133
|
+
component: "sharePreview",
|
|
134
|
+
label: "How it looks when found or shared",
|
|
135
|
+
options: {
|
|
136
|
+
...siteName ? { siteName } : {},
|
|
137
|
+
...suffix ? { titleSuffix: suffix } : {},
|
|
138
|
+
title: [SEO_FIELDS.title, titleField],
|
|
139
|
+
description: [SEO_FIELDS.description, ...describedBy],
|
|
140
|
+
image: image ? [SEO_FIELDS.image, ...picturedBy] : [],
|
|
141
|
+
hidden: SEO_FIELDS.hidden
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
name: "seo",
|
|
147
|
+
type: "group",
|
|
148
|
+
label: options.label ?? "Search and sharing",
|
|
149
|
+
collapsed: options.collapsed ?? true,
|
|
150
|
+
fields
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function withSeo(collection, siteName) {
|
|
154
|
+
if (!collection.seo || collection.fields.some((one) => one.name === "seo"))
|
|
155
|
+
return collection;
|
|
156
|
+
const group = seoGroup(collection, siteName);
|
|
157
|
+
return group ? { ...collection, fields: [...collection.fields, group] } : collection;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// src/content/markdown.ts
|
|
161
|
+
var TOOLS = [
|
|
162
|
+
{ name: "heading", label: "Heading", glyph: "H", icon: "" },
|
|
163
|
+
{ name: "bold", label: "Bold", glyph: "B", icon: "bold", shortcut: "b" },
|
|
164
|
+
{ name: "italic", label: "Italic", glyph: "I", icon: "italic", shortcut: "i" },
|
|
165
|
+
{ name: "underline", label: "Underline", glyph: "U", icon: "underline", shortcut: "u" },
|
|
166
|
+
{ name: "link", label: "Link", glyph: "\uD83D\uDD17", icon: "link", shortcut: "k" },
|
|
167
|
+
{ name: "bullet", label: "Bulleted list", glyph: "•", icon: "list-bulleted", group: true },
|
|
168
|
+
{ name: "numbered", label: "Numbered list", glyph: "1.", icon: "list-numbered" },
|
|
169
|
+
{ name: "quote", label: "Quote", glyph: "❝", icon: "quote" },
|
|
170
|
+
{ name: "code", label: "Code", glyph: "</>", icon: "" },
|
|
171
|
+
{ name: "caption", label: "Caption", glyph: "c", icon: "" },
|
|
172
|
+
{ name: "lead", label: "Lead paragraph", glyph: "P", icon: "" },
|
|
173
|
+
{ name: "clear", label: "Clear formatting", glyph: "Tx", icon: "clear", group: true }
|
|
174
|
+
];
|
|
175
|
+
var TOOL_NAMES = TOOLS.map((tool) => tool.name);
|
|
176
|
+
|
|
177
|
+
// src/config/permissions.ts
|
|
178
|
+
var ACTIONS = [
|
|
179
|
+
"read",
|
|
180
|
+
"create",
|
|
181
|
+
"update",
|
|
182
|
+
"delete",
|
|
183
|
+
"restore",
|
|
184
|
+
"publish",
|
|
185
|
+
"unpublish",
|
|
186
|
+
"submit",
|
|
187
|
+
"approve",
|
|
188
|
+
"viewDeleted",
|
|
189
|
+
"purge"
|
|
190
|
+
];
|
|
191
|
+
var EDITOR_ACTIONS = [
|
|
192
|
+
"read",
|
|
193
|
+
"create",
|
|
194
|
+
"update",
|
|
195
|
+
"delete",
|
|
196
|
+
"restore",
|
|
197
|
+
"publish",
|
|
198
|
+
"unpublish",
|
|
199
|
+
"submit"
|
|
200
|
+
];
|
|
201
|
+
var GOVERNING = ["users", "groups"];
|
|
202
|
+
function rolesFor(collections, declared) {
|
|
203
|
+
if (declared)
|
|
204
|
+
return declared;
|
|
205
|
+
const editor = {};
|
|
206
|
+
for (const collection of collections) {
|
|
207
|
+
if (GOVERNING.includes(collection.name))
|
|
208
|
+
continue;
|
|
209
|
+
editor[collection.name] = EDITOR_ACTIONS;
|
|
210
|
+
}
|
|
211
|
+
return { admin: "*", editor };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// src/media/image.ts
|
|
215
|
+
var publishImage = (value, info, src, sizes) => {
|
|
216
|
+
const override = (one) => {
|
|
217
|
+
const trimmed = (one ?? "").trim();
|
|
218
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
219
|
+
};
|
|
220
|
+
const alt = override(value.alt) ?? info?.altText ?? "";
|
|
221
|
+
const credit = override(value.credit) ?? info?.credit;
|
|
222
|
+
return {
|
|
223
|
+
src,
|
|
224
|
+
alt,
|
|
225
|
+
...sizes ? { sizes } : {},
|
|
226
|
+
...info?.palette ? { palette: info.palette } : {},
|
|
227
|
+
...info?.width !== undefined ? { width: info.width } : {},
|
|
228
|
+
...info?.height !== undefined ? { height: info.height } : {},
|
|
229
|
+
...credit !== undefined ? { credit } : {}
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// src/config/types.ts
|
|
234
|
+
var STORAGE_TYPES = {
|
|
235
|
+
text: (v) => typeof v === "string",
|
|
236
|
+
markdown: (v) => typeof v === "string",
|
|
237
|
+
date: (v) => typeof v === "string" && /^\d{4}-\d{2}-\d{2}$/.test(v),
|
|
238
|
+
number: (v) => typeof v === "number" && Number.isFinite(v),
|
|
239
|
+
boolean: (v) => typeof v === "boolean",
|
|
240
|
+
repeater: (v) => Array.isArray(v),
|
|
241
|
+
reference: (v) => typeof v === "string" || Array.isArray(v) && v.every((one) => typeof one === "string"),
|
|
242
|
+
block: (v) => typeof v === "object" && v !== null && !Array.isArray(v)
|
|
243
|
+
};
|
|
244
|
+
var LAYOUT_TYPES = {
|
|
245
|
+
group: true,
|
|
246
|
+
note: true
|
|
247
|
+
};
|
|
248
|
+
function withoutBaseClashes(fields, taken = USER_BASE_FIELDS) {
|
|
249
|
+
const base = new Set(taken.map((field) => field.name));
|
|
250
|
+
for (const field of fields) {
|
|
251
|
+
if (base.has(field.name)) {
|
|
252
|
+
throw new Error(`users already has a field called "${field.name}". ` + `Remove it, or name yours something else.`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return fields;
|
|
256
|
+
}
|
|
257
|
+
var USER_NAME_FIELDS = [
|
|
258
|
+
{ name: "firstName", type: "text", label: "First name", required: true, maxLength: 80, searchable: true },
|
|
259
|
+
{ name: "lastName", type: "text", label: "Last name", required: true, maxLength: 80, searchable: true, sortable: true }
|
|
260
|
+
];
|
|
261
|
+
var USER_BASE_FIELDS = [
|
|
262
|
+
{
|
|
263
|
+
name: "email",
|
|
264
|
+
type: "text",
|
|
265
|
+
label: "Email",
|
|
266
|
+
required: true,
|
|
267
|
+
unique: true,
|
|
268
|
+
patterns: [
|
|
269
|
+
{ pattern: "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$", message: "That is not an email address." }
|
|
270
|
+
]
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: "role",
|
|
274
|
+
type: "text",
|
|
275
|
+
component: "choice",
|
|
276
|
+
label: "Role",
|
|
277
|
+
required: true,
|
|
278
|
+
filterable: true,
|
|
279
|
+
choices: [
|
|
280
|
+
{ value: "editor", label: "Editor" },
|
|
281
|
+
{ value: "admin", label: "Admin" }
|
|
282
|
+
]
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
name: "groups",
|
|
286
|
+
type: "reference",
|
|
287
|
+
to: "groups",
|
|
288
|
+
many: true,
|
|
289
|
+
label: "Groups",
|
|
290
|
+
filterable: true
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
name: "permissions",
|
|
294
|
+
type: "repeater",
|
|
295
|
+
label: "Permission exceptions",
|
|
296
|
+
of: []
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
name: "password",
|
|
300
|
+
type: "text",
|
|
301
|
+
label: "Password",
|
|
302
|
+
writeOnly: true,
|
|
303
|
+
minLength: 12,
|
|
304
|
+
options: { secret: true }
|
|
305
|
+
}
|
|
306
|
+
];
|
|
307
|
+
var BLOCK_KEY = "block";
|
|
308
|
+
var LABEL_KEY = "internalLabel";
|
|
309
|
+
function checkFields(fields, path, known = new Set) {
|
|
310
|
+
for (const field of fields) {
|
|
311
|
+
const where = `${path}.${field.name}`;
|
|
312
|
+
if (!STORAGE_TYPES[field.type] && !LAYOUT_TYPES[field.type]) {
|
|
313
|
+
throw new Error(`${where}: "${field.type}" is not a storage type. ` + `Use one of ${Object.keys(STORAGE_TYPES).join(", ")}, and name the ` + `component with \`component\` if a custom one renders it.`);
|
|
314
|
+
}
|
|
315
|
+
if (field.fields)
|
|
316
|
+
checkFields(field.fields, where, known);
|
|
317
|
+
for (const tool of field.tools ?? []) {
|
|
318
|
+
if (!TOOL_NAMES.includes(tool)) {
|
|
319
|
+
throw new Error(`${where}: "${tool}" is not a formatting tool. ` + `Use one of ${TOOL_NAMES.join(", ")}.`);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (field.type === "reference") {
|
|
323
|
+
if (!field.to) {
|
|
324
|
+
throw new Error(`${where}: a reference needs \`to\`, naming the collection it points at.`);
|
|
325
|
+
}
|
|
326
|
+
if (!known.has(field.to)) {
|
|
327
|
+
throw new Error(`${where}: points at "${field.to}", which is not a collection. ` + `Declared: ${[...known].join(", ")}.`);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (field.name === BLOCK_KEY) {
|
|
331
|
+
throw new Error(`${where}: "${BLOCK_KEY}" is reserved - it is how a row records which ` + `shape it is.`);
|
|
332
|
+
}
|
|
333
|
+
if (field.name === LABEL_KEY) {
|
|
334
|
+
throw new Error(`${where}: "${LABEL_KEY}" is reserved - it is a row's name for editors.`);
|
|
335
|
+
}
|
|
336
|
+
if (field.of && field.blocks) {
|
|
337
|
+
throw new Error(`${where}: declare \`of\` or \`blocks\`, not both. \`of\` is the ` + `one-shape shorthand.`);
|
|
338
|
+
}
|
|
339
|
+
for (const key of Object.keys(field.derive ?? {})) {
|
|
340
|
+
const parts = field.fields ?? [];
|
|
341
|
+
if (parts.some((part) => part.name === key)) {
|
|
342
|
+
throw new Error(`${where}: "${key}" is both a part and something derived from the ` + `parts. One would quietly overwrite the other.`);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
if (field.of)
|
|
346
|
+
checkFields(field.of, where, known);
|
|
347
|
+
const seen = new Set;
|
|
348
|
+
for (const block of field.blocks ?? []) {
|
|
349
|
+
if (seen.has(block.name)) {
|
|
350
|
+
throw new Error(`${where}: two blocks are both named "${block.name}".`);
|
|
351
|
+
}
|
|
352
|
+
seen.add(block.name);
|
|
353
|
+
checkFields(block.fields, `${where}[${block.name}]`, known);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
var BUILT_IN = ["users", "groups", "media"];
|
|
358
|
+
function checkWorkflow(collection) {
|
|
359
|
+
const workflow = collection.workflow;
|
|
360
|
+
if (!workflow)
|
|
361
|
+
return;
|
|
362
|
+
const where = `${collection.name}.workflow`;
|
|
363
|
+
if (collection.publishable === false) {
|
|
364
|
+
throw new Error(`${where}: this collection is not publishable, so nothing here is ever ` + `signed off. Remove the workflow, or make the collection publishable.`);
|
|
365
|
+
}
|
|
366
|
+
if (!workflow.stages?.length) {
|
|
367
|
+
throw new Error(`${where}: a workflow with no stages is the same as no workflow. ` + `Remove it, or give it a stage.`);
|
|
368
|
+
}
|
|
369
|
+
const seen = new Set;
|
|
370
|
+
for (const [index, stage] of workflow.stages.entries()) {
|
|
371
|
+
const at = `${where}.stages[${index}]`;
|
|
372
|
+
if (!stage.name?.trim()) {
|
|
373
|
+
throw new Error(`${at}: every stage needs a name - it is what the editor shows and what each decision is recorded against.`);
|
|
374
|
+
}
|
|
375
|
+
const key = stage.name.trim().toLowerCase();
|
|
376
|
+
if (seen.has(key)) {
|
|
377
|
+
throw new Error(`${at}: two stages are both called "${stage.name}".`);
|
|
378
|
+
}
|
|
379
|
+
seen.add(key);
|
|
380
|
+
if (!stage.approvers?.length) {
|
|
381
|
+
throw new Error(`${at} ("${stage.name}"): names no approvers, so nothing can ever satisfy it.`);
|
|
382
|
+
}
|
|
383
|
+
if (stage.require && stage.require !== "all" && stage.require !== "any") {
|
|
384
|
+
throw new Error(`${at} ("${stage.name}"): require is "${stage.require}", which is neither "all" nor "any".`);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function defineConfig(config) {
|
|
389
|
+
const known = new Set([...config.collections.map((one) => one.name), ...BUILT_IN]);
|
|
390
|
+
const declaredCollections = config.collections.map((one) => withSeo(one, config.siteName));
|
|
391
|
+
for (const collection of declaredCollections) {
|
|
392
|
+
checkFields(collection.fields, collection.name, known);
|
|
393
|
+
checkWorkflow(collection);
|
|
394
|
+
}
|
|
395
|
+
const declared = declaredCollections.find((c) => c.name === "users");
|
|
396
|
+
const [address, ...access] = USER_BASE_FIELDS;
|
|
397
|
+
const userFields = config.userNames ? [address, ...USER_NAME_FIELDS, ...access] : USER_BASE_FIELDS;
|
|
398
|
+
const users = {
|
|
399
|
+
name: "users",
|
|
400
|
+
icon: declared?.icon ?? "person",
|
|
401
|
+
label: declared?.label ?? "Users",
|
|
402
|
+
titleField: declared?.titleField,
|
|
403
|
+
...declared?.summary ? { summary: declared.summary } : config.userNames && !declared?.titleField ? { summary: { title: "{firstName} {lastName}", subtitle: "email" } } : {},
|
|
404
|
+
publishable: declared?.publishable ?? false,
|
|
405
|
+
fields: [...userFields, ...withoutBaseClashes(declared?.fields ?? [], userFields)]
|
|
406
|
+
};
|
|
407
|
+
const declaredGroups = declaredCollections.find((c) => c.name === "groups");
|
|
408
|
+
const declaredMedia = declaredCollections.find((c) => c.name === "media");
|
|
409
|
+
const built = new Set(BUILT_IN);
|
|
410
|
+
const collections = [
|
|
411
|
+
...declaredCollections.filter((c) => !built.has(c.name)),
|
|
412
|
+
mediaCollection(declaredMedia, { library: config.media === "pseudolux" }),
|
|
413
|
+
groupsCollection(declaredGroups),
|
|
414
|
+
users
|
|
415
|
+
];
|
|
416
|
+
users.fields = users.fields.map((field) => field.name === "permissions" ? permissionsField(collections) : field);
|
|
417
|
+
const groups = collections.find((one) => one.name === "groups");
|
|
418
|
+
groups.fields = groups.fields.map((field) => {
|
|
419
|
+
if (field.name === "grants") {
|
|
420
|
+
return { ...permissionsField(collections), name: "grants", label: "Grants" };
|
|
421
|
+
}
|
|
422
|
+
if (field.name === "scope") {
|
|
423
|
+
return {
|
|
424
|
+
...field,
|
|
425
|
+
of: field.of.map((inner) => inner.name === "collection" ? {
|
|
426
|
+
...inner,
|
|
427
|
+
choices: collections.map((one) => ({
|
|
428
|
+
value: one.name,
|
|
429
|
+
label: one.label ?? one.name
|
|
430
|
+
}))
|
|
431
|
+
} : inner)
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
return field;
|
|
435
|
+
});
|
|
436
|
+
checkNavigation(config.navigation, collections);
|
|
437
|
+
return {
|
|
438
|
+
collections,
|
|
439
|
+
roles: rolesFor(collections, config.roles),
|
|
440
|
+
navigation: config.navigation,
|
|
441
|
+
media: config.media,
|
|
442
|
+
...config.overrides ? { overrides: config.overrides } : {},
|
|
443
|
+
...config.site ? { site: config.site } : {},
|
|
444
|
+
...config.siteName ? { siteName: config.siteName } : {},
|
|
445
|
+
...config.userNames ? { userNames: true } : {}
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
function checkNavigation(sections, collections) {
|
|
449
|
+
if (!sections)
|
|
450
|
+
return;
|
|
451
|
+
const known = new Set(collections.map((one) => one.name));
|
|
452
|
+
for (const section of sections) {
|
|
453
|
+
for (const name of section.collections) {
|
|
454
|
+
if (!known.has(name)) {
|
|
455
|
+
throw new Error(`Navigation section "${section.heading}" lists "${name}", ` + `which is not a collection. Declared: ${[...known].join(", ")}.`);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
function mediaCollection(declared, options = {}) {
|
|
461
|
+
const ownWords = !options.library;
|
|
462
|
+
return {
|
|
463
|
+
name: "media",
|
|
464
|
+
icon: declared?.icon ?? "image",
|
|
465
|
+
label: declared?.label ?? "Media",
|
|
466
|
+
titleField: "title",
|
|
467
|
+
publishable: false,
|
|
468
|
+
uploads: true,
|
|
469
|
+
referencedAs: (data, resolve) => {
|
|
470
|
+
const key = data.file ? String(data.file) : "";
|
|
471
|
+
const info = (key ? resolve.info(key) : null) ?? {
|
|
472
|
+
...typeof data.width === "number" ? { width: data.width } : {},
|
|
473
|
+
...typeof data.height === "number" ? { height: data.height } : {}
|
|
474
|
+
};
|
|
475
|
+
return publishImage({
|
|
476
|
+
key,
|
|
477
|
+
...ownWords && data.alt ? { alt: String(data.alt) } : {},
|
|
478
|
+
...ownWords && data.credit ? { credit: String(data.credit) } : {}
|
|
479
|
+
}, info, key ? resolve.url(key) : "", key ? resolve.urlTemplate?.(key) ?? null : null);
|
|
480
|
+
},
|
|
481
|
+
summary: {
|
|
482
|
+
media: { component: "thumbnail", from: "file" },
|
|
483
|
+
subtitle: ownWords ? "{alt}" : "{file}"
|
|
484
|
+
},
|
|
485
|
+
fields: [
|
|
486
|
+
{ name: "title", type: "text", label: "Name", required: true, searchable: true },
|
|
487
|
+
...ownWords ? [
|
|
488
|
+
{
|
|
489
|
+
name: "alt",
|
|
490
|
+
type: "text",
|
|
491
|
+
label: "Alt text",
|
|
492
|
+
legend: "What the picture shows, for somebody who cannot see it.",
|
|
493
|
+
searchable: true
|
|
494
|
+
},
|
|
495
|
+
{ name: "credit", type: "text", label: "Credit" }
|
|
496
|
+
] : [],
|
|
497
|
+
{ name: "file", type: "text", label: "File", readOnly: true },
|
|
498
|
+
{ name: "contentType", type: "text", label: "Type", readOnly: true, filterable: true },
|
|
499
|
+
{ name: "size", type: "number", label: "Size", readOnly: true, sortable: true },
|
|
500
|
+
{ name: "width", type: "number", label: "Width", readOnly: true },
|
|
501
|
+
{ name: "height", type: "number", label: "Height", readOnly: true },
|
|
502
|
+
...declared?.fields ?? []
|
|
503
|
+
]
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
function groupsCollection(declared) {
|
|
507
|
+
return {
|
|
508
|
+
name: "groups",
|
|
509
|
+
icon: declared?.icon ?? "people",
|
|
510
|
+
label: declared?.label ?? "Groups",
|
|
511
|
+
titleField: "title",
|
|
512
|
+
publishable: false,
|
|
513
|
+
summary: { subtitle: "{purpose}" },
|
|
514
|
+
fields: [
|
|
515
|
+
{ name: "title", type: "text", label: "Name", required: true, searchable: true },
|
|
516
|
+
{ name: "purpose", type: "text", label: "What it is for", searchable: true },
|
|
517
|
+
{
|
|
518
|
+
name: "grants",
|
|
519
|
+
type: "repeater",
|
|
520
|
+
label: "Grants",
|
|
521
|
+
legend: "What members may do. Leave empty and this group only narrows what members already had. A deny applies to every entry, not only those in scope.",
|
|
522
|
+
of: []
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
name: "scope",
|
|
526
|
+
type: "repeater",
|
|
527
|
+
label: "Scope",
|
|
528
|
+
legend: "Which entries this group is about. With grants above, it is how far those grants reach; on its own, it is a limit on everything a member can do here. A field named here has to be filterable.",
|
|
529
|
+
of: [
|
|
530
|
+
{ name: "collection", type: "text", component: "choice", label: "Collection", required: true },
|
|
531
|
+
{ name: "field", type: "text", label: "Field", required: true },
|
|
532
|
+
{ name: "value", type: "text", label: "Is", required: true }
|
|
533
|
+
]
|
|
534
|
+
},
|
|
535
|
+
...declared?.fields ?? []
|
|
536
|
+
]
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
function permissionsField(collections) {
|
|
540
|
+
return {
|
|
541
|
+
name: "permissions",
|
|
542
|
+
type: "repeater",
|
|
543
|
+
label: "Permission exceptions",
|
|
544
|
+
legend: "Overrides for this account only. A deny cannot be undone by anything else.",
|
|
545
|
+
of: [
|
|
546
|
+
{
|
|
547
|
+
name: "effect",
|
|
548
|
+
type: "text",
|
|
549
|
+
component: "choice",
|
|
550
|
+
label: "Effect",
|
|
551
|
+
required: true,
|
|
552
|
+
choices: [
|
|
553
|
+
{ value: "allow", label: "Allow" },
|
|
554
|
+
{ value: "deny", label: "Deny" }
|
|
555
|
+
]
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
name: "action",
|
|
559
|
+
type: "text",
|
|
560
|
+
component: "choice",
|
|
561
|
+
label: "Action",
|
|
562
|
+
required: true,
|
|
563
|
+
choices: ACTIONS.map((action) => ({ value: action, label: action }))
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
name: "collection",
|
|
567
|
+
type: "text",
|
|
568
|
+
component: "choice",
|
|
569
|
+
label: "Collection",
|
|
570
|
+
required: true,
|
|
571
|
+
choices: [
|
|
572
|
+
{ value: "*", label: "Every collection" },
|
|
573
|
+
...collections.map((one) => ({
|
|
574
|
+
value: one.name,
|
|
575
|
+
label: one.label ?? one.name
|
|
576
|
+
}))
|
|
577
|
+
]
|
|
578
|
+
}
|
|
579
|
+
]
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
function dateRange({
|
|
583
|
+
legend,
|
|
584
|
+
duration,
|
|
585
|
+
start,
|
|
586
|
+
end
|
|
587
|
+
}) {
|
|
588
|
+
return [
|
|
589
|
+
{
|
|
590
|
+
...start,
|
|
591
|
+
legend,
|
|
592
|
+
type: "date",
|
|
593
|
+
component: "daterange",
|
|
594
|
+
end: end.name,
|
|
595
|
+
...duration ? { options: { ...start.options, duration: true } } : {}
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
...end,
|
|
599
|
+
type: "date",
|
|
600
|
+
after: start.name
|
|
601
|
+
}
|
|
602
|
+
];
|
|
603
|
+
}
|
|
604
|
+
function splitBlock({
|
|
605
|
+
name,
|
|
606
|
+
label,
|
|
607
|
+
description,
|
|
608
|
+
cells,
|
|
609
|
+
of,
|
|
610
|
+
layouts
|
|
611
|
+
}) {
|
|
612
|
+
const min = typeof cells === "number" ? cells : cells.min;
|
|
613
|
+
const max = typeof cells === "number" ? cells : cells.max;
|
|
614
|
+
return {
|
|
615
|
+
name,
|
|
616
|
+
label,
|
|
617
|
+
description,
|
|
618
|
+
fields: [
|
|
619
|
+
...layouts && layouts.length > 1 ? [
|
|
620
|
+
{
|
|
621
|
+
name: "layout",
|
|
622
|
+
type: "text",
|
|
623
|
+
component: "choice",
|
|
624
|
+
label: "Layout",
|
|
625
|
+
choices: layouts,
|
|
626
|
+
required: true
|
|
627
|
+
}
|
|
628
|
+
] : [],
|
|
629
|
+
{
|
|
630
|
+
name: "cells",
|
|
631
|
+
type: "repeater",
|
|
632
|
+
label: "Cells",
|
|
633
|
+
blocks: of,
|
|
634
|
+
...min !== undefined ? { minRows: min } : {},
|
|
635
|
+
...max !== undefined ? { maxRows: max } : {}
|
|
636
|
+
}
|
|
637
|
+
]
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
// src/content/person.ts
|
|
641
|
+
var text = (value) => typeof value === "string" ? value.trim() : "";
|
|
642
|
+
function personName(person) {
|
|
643
|
+
const full = [text(person?.firstName), text(person?.lastName)].filter(Boolean).join(" ");
|
|
644
|
+
return full || text(person?.name) || text(person?.email);
|
|
645
|
+
}
|
|
646
|
+
function initialsOf(person) {
|
|
647
|
+
const first = text(person?.firstName);
|
|
648
|
+
const last = text(person?.lastName);
|
|
649
|
+
if (first && last)
|
|
650
|
+
return (first[0] + last[0]).toUpperCase();
|
|
651
|
+
const words = personName(person).split("@")[0].split(/[\s._-]+/).filter(Boolean);
|
|
652
|
+
const letters = words.length > 1 ? words[0][0] + words[words.length - 1][0] : (words[0] ?? "").slice(0, 2);
|
|
653
|
+
return letters.toUpperCase();
|
|
654
|
+
}
|
|
655
|
+
// src/config/icons.ts
|
|
656
|
+
var DEFAULT_ICON = "page";
|
|
657
|
+
var TYPE_ICONS = [
|
|
658
|
+
{ id: "page", name: "Page", group: "Writing and pages", keywords: ["basic", "web page"], path: "M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8zM14 3v5h5" },
|
|
659
|
+
{ id: "document", name: "Document", group: "Writing and pages", keywords: ["file", "report", "policy"], path: "M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8zM14 3v5h5M9 13h6M9 17h6M9 9h2" },
|
|
660
|
+
{ id: "story", name: "Story", group: "Writing and pages", keywords: ["article", "feature", "book"], path: "M4 19.5A2.5 2.5 0 0 1 6.5 17H20V3H6.5A2.5 2.5 0 0 0 4 5.5zM4 19.5A2.5 2.5 0 0 0 6.5 22H20v-5" },
|
|
661
|
+
{ id: "news", name: "News", group: "Writing and pages", keywords: ["media release", "update"], path: "M5 4h10a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2zM17 8h3a1 1 0 0 1 1 1v9a2 2 0 0 1-4 0M7 8h6M7 12h6M7 16h4" },
|
|
662
|
+
{ id: "post", name: "Post", group: "Writing and pages", keywords: ["blog", "opinion", "write"], path: "M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z" },
|
|
663
|
+
{ id: "quote", name: "Quote", group: "Writing and pages", keywords: ["testimonial", "saying"], path: "M5 7h4v4c0 3-2 5-4 6M14 7h4v4c0 3-2 5-4 6" },
|
|
664
|
+
{ id: "faq", name: "Question", group: "Writing and pages", keywords: ["FAQ", "help", "answer"], path: "M21 12a9 9 0 0 1-13.5 7.8L3 21l1.2-4.5A9 9 0 1 1 21 12zM9.5 9.5a2.5 2.5 0 1 1 3.5 2.3c-.6.3-1 .8-1 1.5M12 16.5h.01" },
|
|
665
|
+
{ id: "layout", name: "Landing page", group: "Writing and pages", keywords: ["hub", "section", "home"], path: "M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2zM3 9h18M9 9v12" },
|
|
666
|
+
{ id: "event", name: "Event", group: "Events and learning", keywords: ["calendar", "programme", "whats on"], path: "M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2zM16 2v4M8 2v4M3 10h18M8 14h.01M12 14h.01M16 14h.01M8 18h.01M12 18h.01" },
|
|
667
|
+
{ id: "ticket", name: "Ticket", group: "Events and learning", keywords: ["booking", "admission", "show"], path: "M3 7a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v3a2 2 0 0 0 0 4v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-3a2 2 0 0 0 0-4zM14 6v2M14 11v2M14 16v2" },
|
|
668
|
+
{ id: "exhibition", name: "Exhibition", group: "Events and learning", keywords: ["display", "gallery", "show"], path: "M4 4h16a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-16a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2zM7 8h10a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-10a1 1 0 0 1 -1 -1v-6a1 1 0 0 1 1 -1z" },
|
|
669
|
+
{ id: "course", name: "Course", group: "Events and learning", keywords: ["class", "workshop", "learning"], path: "M22 10 12 5 2 10l10 5 10-5zM6 12v5c3 2 9 2 12 0v-5M22 10v6" },
|
|
670
|
+
{ id: "idea", name: "Idea", group: "Events and learning", keywords: ["tip", "insight", "lightbulb"], path: "M9 18h6M10 22h4M12 2a7 7 0 0 0-4 12.7c.6.5 1 1.3 1 2.1V17h6v-.2c0-.8.4-1.6 1-2.1A7 7 0 0 0 12 2z" },
|
|
671
|
+
{ id: "hours", name: "Opening hours", group: "Events and learning", keywords: ["time", "clock", "schedule"], path: "M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0M12 7v5l3 2" },
|
|
672
|
+
{ id: "announcement", name: "Announcement", group: "Events and learning", keywords: ["alert", "notice", "megaphone"], path: "M3 11v3a1 1 0 0 0 1 1h3l5 4V6L7 10H4a1 1 0 0 0-1 1zM16 9a4 4 0 0 1 0 6M19 6a8 8 0 0 1 0 12" },
|
|
673
|
+
{ id: "award", name: "Award", group: "Events and learning", keywords: ["prize", "fellowship", "medal"], path: "M6 9a6 6 0 1 0 12 0a6 6 0 1 0 -12 0M8.5 14 7 22l5-3 5 3-1.5-8" },
|
|
674
|
+
{ id: "image", name: "Image", group: "Media and collections", keywords: ["picture", "photo"], path: "M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2zM7 9a2 2 0 1 0 4 0a2 2 0 1 0 -4 0m21 15-5-5L5 21" },
|
|
675
|
+
{ id: "gallery", name: "Gallery", group: "Media and collections", keywords: ["album", "set", "photos"], path: "M9 3h10a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2zM3 7v12a2 2 0 0 0 2 2h12m4-8-4-4-6 6" },
|
|
676
|
+
{ id: "video", name: "Video", group: "Media and collections", keywords: ["film", "recording"], path: "M4 5h10a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2zm16 10 6-4v12l-6-4" },
|
|
677
|
+
{ id: "audio", name: "Audio", group: "Media and collections", keywords: ["podcast", "oral history", "talk"], path: "M12 2h0a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3zM5 11a7 7 0 0 0 14 0M12 18v4M8 22h8" },
|
|
678
|
+
{ id: "item", name: "Collection item", group: "Media and collections", keywords: ["object", "archive", "record"], path: "M3 3h18a1 1 0 0 1 1 1v3a1 1 0 0 1 -1 1h-18a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1zM4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8M10 12h4" },
|
|
679
|
+
{ id: "map", name: "Map", group: "Media and collections", keywords: ["guide", "trail", "place"], path: "M9 4 3 6v14l6-2 6 2 6-2V4l-6 2zM9 4v14M15 6v14" },
|
|
680
|
+
{ id: "research", name: "Research guide", group: "Media and collections", keywords: ["search", "discover", "find"], path: "M4 11a7 7 0 1 0 14 0a7 7 0 1 0 -14 0m20 20-3.5-3.5" },
|
|
681
|
+
{ id: "data", name: "Dataset", group: "Media and collections", keywords: ["database", "records", "open data"], path: "M4 6a8 3 0 1 0 16 0a8 3 0 1 0-16 0M4 6v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3" },
|
|
682
|
+
{ id: "person", name: "Person", group: "People and places", keywords: ["staff", "author", "profile"], path: "M8 8a4 4 0 1 0 8 0a4 4 0 1 0 -8 0M4 21a8 8 0 0 1 16 0" },
|
|
683
|
+
{ id: "people", name: "People", group: "People and places", keywords: ["team", "group", "community"], path: "M5 8a4 4 0 1 0 8 0a4 4 0 1 0 -8 0M2 21a7 7 0 0 1 14 0M17 4a4 4 0 0 1 0 8M22 21a7 7 0 0 0-4-6" },
|
|
684
|
+
{ id: "organisation", name: "Organisation", group: "People and places", keywords: ["partner", "company", "building"], path: "M6 2h12a2 2 0 0 1 2 2v16a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-16a2 2 0 0 1 2 -2zM9 22v-4h6v4M8 6h.01M12 6h.01M16 6h.01M8 10h.01M12 10h.01M16 10h.01M8 14h.01M12 14h.01M16 14h.01" },
|
|
685
|
+
{ id: "venue", name: "Venue", group: "People and places", keywords: ["library", "museum", "institution"], path: "M3 9.5 12 4l9 5.5zM5 10v8M9.5 10v8M14.5 10v8M19 10v8M3 21h18" },
|
|
686
|
+
{ id: "room", name: "Room", group: "People and places", keywords: ["space", "hire", "door"], path: "M4 21h16M6 21V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v17M14 12h.01" },
|
|
687
|
+
{ id: "location", name: "Location", group: "People and places", keywords: ["address", "branch", "pin"], path: "M20 10c0 6-8 12-8 12S4 16 4 10a8 8 0 0 1 16 0zM9 10a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" },
|
|
688
|
+
{ id: "contact", name: "Contact", group: "People and places", keywords: ["email", "newsletter", "mail"], path: "M4 4h16a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-16a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2zm22 7-10 6L2 7" },
|
|
689
|
+
{ id: "accessibility", name: "Accessibility", group: "People and places", keywords: ["access", "inclusion"], path: "M10.5 4.5a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0 -3 0M5 8.5l7 1 7-1M12 9.5v5l-3 6.5M12 14.5l3 6.5" },
|
|
690
|
+
{ id: "category", name: "Category", group: "Organising", keywords: ["tag", "label", "type"], path: "M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0L3 13V3h10l7.6 7.6a2 2 0 0 1 0 2.8zM6 7.5a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0 -3 0" },
|
|
691
|
+
{ id: "topic", name: "Topic", group: "Organising", keywords: ["subject", "theme", "hashtag"], path: "M4 9h16M4 15h16M10 3 8 21M16 3l-2 18" },
|
|
692
|
+
{ id: "folder", name: "Folder", group: "Organising", keywords: ["section", "area"], path: "M3 6a2 2 0 0 1 2-2h4l2 3h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" },
|
|
693
|
+
{ id: "collection", name: "Collection", group: "Organising", keywords: ["set", "layers", "series"], path: "M12 2 2 7l10 5 10-5zM2 12l10 5 10-5M2 17l10 5 10-5" },
|
|
694
|
+
{ id: "list", name: "List", group: "Organising", keywords: ["series", "index", "menu"], path: "M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01" },
|
|
695
|
+
{ id: "featured", name: "Featured", group: "Organising", keywords: ["highlight", "star", "pick"], path: "M12 3l2.8 5.7 6.2.9-4.5 4.4 1 6.2L12 17.3l-5.5 2.9 1-6.2L3 9.6l6.2-.9z" },
|
|
696
|
+
{ id: "bookmark", name: "Bookmark", group: "Organising", keywords: ["saved", "reading list"], path: "M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z" },
|
|
697
|
+
{ id: "flag", name: "Flag", group: "Organising", keywords: ["campaign", "milestone"], path: "M4 22V4M4 4h12l-2 4 2 4H4" },
|
|
698
|
+
{ id: "job", name: "Job", group: "Services and site", keywords: ["career", "vacancy", "role"], path: "M4 7h16a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-16a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2zM16 7V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2M2 13h20" },
|
|
699
|
+
{ id: "shop", name: "Shop item", group: "Services and site", keywords: ["product", "merchandise", "bag"], path: "M6 7h12l1 14H5zM9 7a3 3 0 0 1 6 0" },
|
|
700
|
+
{ id: "gift", name: "Support us", group: "Services and site", keywords: ["donate", "gift", "giving"], path: "M4 8h16a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-2a1 1 0 0 1 1 -1zM5 12v8a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-8M12 8v13M12 8c-2.5 0-4-1-4-2.5S9.5 3 12 8zM12 8c2.5 0 4-1 4-2.5S14.5 3 12 8z" },
|
|
701
|
+
{ id: "heart", name: "Membership", group: "Services and site", keywords: ["members", "friends", "favourite"], path: "M12 20s-8-4.7-8-10.5A4.5 4.5 0 0 1 12 7a4.5 4.5 0 0 1 8 2.5C20 15.3 12 20 12 20z" },
|
|
702
|
+
{ id: "form", name: "Form", group: "Services and site", keywords: ["application", "survey", "clipboard"], path: "M7 4h10a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2zM10 2h4a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-2a1 1 0 0 1 1 -1zM9 12h6M9 16h4" },
|
|
703
|
+
{ id: "cafe", name: "Café", group: "Services and site", keywords: ["food", "drink", "dining"], path: "M4 8h13v6a5 5 0 0 1-5 5H9a5 5 0 0 1-5-5zM17 10h1.5a2.5 2.5 0 0 1 0 5H17M8 2v3M12 2v3" },
|
|
704
|
+
{ id: "site", name: "Website", group: "Services and site", keywords: ["global", "language", "web"], path: "M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18" },
|
|
705
|
+
{ id: "settings", name: "Settings", group: "Services and site", keywords: ["options", "configuration"], path: "M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3M1 14h6M9 8h6M17 16h6" }
|
|
706
|
+
];
|
|
707
|
+
var known = new Set(TYPE_ICONS.map((icon) => icon.id));
|
|
708
|
+
function isTypeIcon(id) {
|
|
709
|
+
return typeof id === "string" && known.has(id);
|
|
710
|
+
}
|
|
711
|
+
function plain(word) {
|
|
712
|
+
const lower = word.toLowerCase().trim();
|
|
713
|
+
if (lower.endsWith("ies"))
|
|
714
|
+
return lower.slice(0, -3) + "y";
|
|
715
|
+
return lower.endsWith("s") && !lower.endsWith("ss") ? lower.slice(0, -1) : lower;
|
|
716
|
+
}
|
|
717
|
+
function suggestIcon(...names) {
|
|
718
|
+
const phrases = names.filter((name) => Boolean(name)).map(plain);
|
|
719
|
+
const words = phrases.flatMap((phrase) => phrase.split(/[^a-z0-9]+/).filter(Boolean).map(plain));
|
|
720
|
+
for (const candidates of [phrases, words]) {
|
|
721
|
+
for (const own of [true, false]) {
|
|
722
|
+
for (const candidate of candidates) {
|
|
723
|
+
const found = TYPE_ICONS.find((icon) => own ? plain(icon.id) === candidate || plain(icon.name) === candidate : icon.keywords.some((keyword) => plain(keyword) === candidate));
|
|
724
|
+
if (found)
|
|
725
|
+
return found.id;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
return null;
|
|
730
|
+
}
|
|
731
|
+
function iconFor(collection) {
|
|
732
|
+
if (isTypeIcon(collection.icon))
|
|
733
|
+
return collection.icon;
|
|
734
|
+
return suggestIcon(collection.name, collection.label) ?? DEFAULT_ICON;
|
|
735
|
+
}
|
|
736
|
+
export {
|
|
737
|
+
BUILT_IN,
|
|
738
|
+
LAYOUT_TYPES,
|
|
739
|
+
SEO_FIELDS,
|
|
740
|
+
STORAGE_TYPES,
|
|
741
|
+
TYPE_ICONS,
|
|
742
|
+
dateRange,
|
|
743
|
+
defineConfig,
|
|
744
|
+
iconFor,
|
|
745
|
+
imageUse,
|
|
746
|
+
initialsOf,
|
|
747
|
+
personName,
|
|
748
|
+
slugField,
|
|
749
|
+
splitBlock,
|
|
750
|
+
suggestIcon
|
|
751
|
+
};
|