@nickpaustian/tela 0.1.1 → 0.1.3
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 +3 -3
- package/bin/tela.ts +10 -2
- package/lib/index.js +16 -0
- package/lib/vite.js +7 -5
- package/package.json +1 -1
- package/scripts/check-components.ts +1 -1
- package/src/components/PersonField.lsp +255 -0
- package/src/config/fields.ts +30 -0
- package/src/config/types.ts +6 -0
- package/src/content/entries.ts +1 -1
- package/src/content/person.ts +11 -0
- package/src/content/references.ts +17 -0
- package/src/content/users.ts +32 -0
- package/src/index.ts +1 -1
- package/src/project.ts +9 -6
- package/src/server/index.ts +23 -1
- package/src/vite.ts +1 -1
- package/src/collections/exhibitions/StatusSummary.lsp +0 -76
- package/src/collections/exhibitions/panels.ts +0 -53
- package/src/collections/exhibitions/schema.ts +0 -203
- package/src/collections/index.ts +0 -20
- package/src/collections/people/schema.ts +0 -16
- package/src/collections/users/schema.ts +0 -18
- package/src/collections/venues/schema.ts +0 -37
package/README.md
CHANGED
|
@@ -23,13 +23,13 @@ bunx tela build # checks components, builds the admin into ./dist
|
|
|
23
23
|
bunx tela create-user you@example.com # or open the admin: a fresh database offers to create the first admin
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
A project component with the same name as one of Tela's fails the build unless the project names it in `overrides`, which is how a project replaces an input on purpose.
|
|
26
|
+
A project component with the same name as one of Tela's fails the build unless the project names it in `overrides`, which is how a project replaces an input on purpose. Components are scanned from the project's `src`; `components: ["…"]` in the config adds other folders.
|
|
27
27
|
|
|
28
28
|
`tela dev` and `tela build` run Vite under Node 22.6 or later. The two entry points Vite's config loads (`@nickpaustian/tela` and `/vite`) ship compiled to `lib/`, since Node will not load TypeScript from `node_modules`; Bun reads the source. `bun run build:lib` rebuilds them, and packing does it first.
|
|
29
29
|
|
|
30
30
|
## Working on Tela and a project together
|
|
31
31
|
|
|
32
|
-
A linked Tela is live in the project with no build step
|
|
32
|
+
A linked Tela is live in the project with no build step: run from a checkout, the `tela` command compiles `lib/` before Vite reads it.
|
|
33
33
|
|
|
34
34
|
```sh
|
|
35
35
|
cd tela && bun link
|
|
@@ -40,7 +40,7 @@ Bun's `file:` protocol copies rather than links, so it is not what you want here
|
|
|
40
40
|
|
|
41
41
|
## Developing Tela itself
|
|
42
42
|
|
|
43
|
-
This repo is also a valid project: its `tela.config.ts` and `
|
|
43
|
+
This repo is also a valid project: its `tela.config.ts` and `example/` (collections and a component, named in the config's `components` so they are scanned like a project's `src`) are the example the tests run against. `example/` is not in the package.
|
|
44
44
|
|
|
45
45
|
```sh
|
|
46
46
|
docker compose up -d
|
package/bin/tela.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { existsSync } from "fs"
|
|
2
|
+
import { existsSync, realpathSync } from "fs"
|
|
3
3
|
import { createRequire } from "module"
|
|
4
|
-
import { dirname, resolve } from "path"
|
|
4
|
+
import { dirname, resolve, sep } from "path"
|
|
5
5
|
import { fileURLToPath } from "url"
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -96,6 +96,14 @@ async function vite(sub: "dev" | "build"): Promise<number> {
|
|
|
96
96
|
return 1
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
// Vite reads the compiled `lib/` for the entry points its config imports. An
|
|
100
|
+
// install ships it; a checkout (linked, or Tela itself) compiles it first,
|
|
101
|
+
// so a change there is live without a step to remember.
|
|
102
|
+
if (!realpathSync(TELA_ROOT).split(sep).includes("node_modules")) {
|
|
103
|
+
const built = await run(["bun", "run", "--silent", "build:lib"], TELA_ROOT, process.env)
|
|
104
|
+
if (built !== 0) return built
|
|
105
|
+
}
|
|
106
|
+
|
|
99
107
|
const options = ["--experimental-strip-types", "--disable-warning=ExperimentalWarning"]
|
|
100
108
|
const env = {
|
|
101
109
|
...process.env,
|
package/lib/index.js
CHANGED
|
@@ -60,6 +60,20 @@ function imageUse(name, label, options = {}) {
|
|
|
60
60
|
]
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
+
function person(name, label, options = {}) {
|
|
64
|
+
return {
|
|
65
|
+
name,
|
|
66
|
+
label,
|
|
67
|
+
type: "block",
|
|
68
|
+
component: "person",
|
|
69
|
+
...options.required ? { required: true } : {},
|
|
70
|
+
...options.hint ? { options: { hint: options.hint } } : {},
|
|
71
|
+
fields: [
|
|
72
|
+
{ name: "user", type: "reference", to: "users", label: "Person" },
|
|
73
|
+
{ name: "name", type: "text", label: "Name", maxLength: 200 }
|
|
74
|
+
]
|
|
75
|
+
};
|
|
76
|
+
}
|
|
63
77
|
|
|
64
78
|
// src/config/seo.ts
|
|
65
79
|
var SEO_FIELDS = {
|
|
@@ -440,6 +454,7 @@ function defineConfig(config) {
|
|
|
440
454
|
navigation: config.navigation,
|
|
441
455
|
media: config.media,
|
|
442
456
|
...config.overrides ? { overrides: config.overrides } : {},
|
|
457
|
+
...config.components ? { components: config.components } : {},
|
|
443
458
|
...config.site ? { site: config.site } : {},
|
|
444
459
|
...config.siteName ? { siteName: config.siteName } : {},
|
|
445
460
|
...config.userNames ? { userNames: true } : {}
|
|
@@ -744,6 +759,7 @@ export {
|
|
|
744
759
|
iconFor,
|
|
745
760
|
imageUse,
|
|
746
761
|
initialsOf,
|
|
762
|
+
person,
|
|
747
763
|
personName,
|
|
748
764
|
slugField,
|
|
749
765
|
splitBlock,
|
package/lib/vite.js
CHANGED
|
@@ -14,11 +14,13 @@ if (!existsSync(CONFIG_PATH)) {
|
|
|
14
14
|
}
|
|
15
15
|
var PROJECT_ROOT = dirname(CONFIG_PATH);
|
|
16
16
|
var DIST = resolve(PROJECT_ROOT, "dist");
|
|
17
|
-
function componentRoots() {
|
|
17
|
+
function componentRoots(extra = []) {
|
|
18
18
|
const roots = [resolve(TELA_ROOT, "src")];
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
roots.
|
|
19
|
+
for (const dir of ["src", ...extra]) {
|
|
20
|
+
const project = resolve(PROJECT_ROOT, dir);
|
|
21
|
+
if (!roots.includes(project))
|
|
22
|
+
roots.push(project);
|
|
23
|
+
}
|
|
22
24
|
return roots;
|
|
23
25
|
}
|
|
24
26
|
|
|
@@ -26,7 +28,7 @@ function componentRoots() {
|
|
|
26
28
|
var require2 = createRequire(import.meta.url);
|
|
27
29
|
var MEDIA_LIBRARY = dirname2(require2.resolve("@pseudolux-ui/media-library"));
|
|
28
30
|
function telaVite(config) {
|
|
29
|
-
const projectComponents = componentRoots().slice(1);
|
|
31
|
+
const projectComponents = componentRoots(config.components).slice(1);
|
|
30
32
|
return {
|
|
31
33
|
root: TELA_ROOT,
|
|
32
34
|
base: "/",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nickpaustian/tela",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "A Git-backed headless CMS: collections of fields in TypeScript, edited in a Lightspeed admin, published as JSON commits to a content repo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Nick Paustian",
|
|
@@ -5,5 +5,5 @@ import { componentRoots } from "../src/project.ts"
|
|
|
5
5
|
/**
|
|
6
6
|
* The pre-build check, runnable on its own. `tela check` is the same call.
|
|
7
7
|
*/
|
|
8
|
-
const ok = reportCheck(checkProject(config.collections, componentRoots(), config.overrides))
|
|
8
|
+
const ok = reportCheck(checkProject(config.collections, componentRoots(config.components), config.overrides))
|
|
9
9
|
if (!ok) process.exit(1)
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
<view>
|
|
2
|
+
<Field $field="props.field" $path="props.path" $controlId="'f-' + props.path">
|
|
3
|
+
<div class="person">
|
|
4
|
+
<div class="person-picked" $show="state.picked">
|
|
5
|
+
<span class="person-chip">
|
|
6
|
+
<span class="person-initials" aria-hidden="true">{{ state.initials }}</span>
|
|
7
|
+
<span class="person-name">{{ state.pickedName }}</span>
|
|
8
|
+
<span class="one-warning" $show="state.gone">No longer has an account. Choose again or type a name.</span>
|
|
9
|
+
</span>
|
|
10
|
+
<button
|
|
11
|
+
type="button"
|
|
12
|
+
class="btn btn-ghost btn-sm btn-icon"
|
|
13
|
+
$show="!state.readonly"
|
|
14
|
+
$aria-label="'Remove ' + state.pickedName"
|
|
15
|
+
@click="unpick"
|
|
16
|
+
>
|
|
17
|
+
<span class="icon icon-s icon-x" aria-hidden="true"></span>
|
|
18
|
+
</button>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<div class="person-entry" $show="!state.picked">
|
|
22
|
+
<input
|
|
23
|
+
class="input"
|
|
24
|
+
type="text"
|
|
25
|
+
role="combobox"
|
|
26
|
+
autocomplete="off"
|
|
27
|
+
aria-autocomplete="list"
|
|
28
|
+
$id="'f-' + props.path"
|
|
29
|
+
$aria-expanded="state.open ? 'true' : 'false'"
|
|
30
|
+
$aria-controls="'f-' + props.path + '-people'"
|
|
31
|
+
$aria-activedescendant="state.active >= 0 ? 'f-' + props.path + '-person-' + state.active : null"
|
|
32
|
+
$placeholder="state.placeholder"
|
|
33
|
+
$readonly="state.readonly"
|
|
34
|
+
$maxLength="200"
|
|
35
|
+
$model="state.typed"
|
|
36
|
+
@input="typed"
|
|
37
|
+
@keydown="key"
|
|
38
|
+
@blur="blurred"
|
|
39
|
+
/>
|
|
40
|
+
<ul
|
|
41
|
+
class="menu person-options"
|
|
42
|
+
role="listbox"
|
|
43
|
+
$id="'f-' + props.path + '-people'"
|
|
44
|
+
$show="state.open && state.results.length > 0"
|
|
45
|
+
>
|
|
46
|
+
<li
|
|
47
|
+
$for="one in state.results"
|
|
48
|
+
$key="one.id"
|
|
49
|
+
role="option"
|
|
50
|
+
class="menu-item"
|
|
51
|
+
$class="{ active: one.index === state.active }"
|
|
52
|
+
$id="'f-' + props.path + '-person-' + one.index"
|
|
53
|
+
$aria-selected="one.index === state.active ? 'true' : 'false'"
|
|
54
|
+
@pointerdown="choose($event, one)"
|
|
55
|
+
>{{ one.name }}</li>
|
|
56
|
+
</ul>
|
|
57
|
+
<p class="person-note" $show="state.typed && !state.open">Not one of the CMS's people, so it shows as typed.</p>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</Field>
|
|
61
|
+
</view>
|
|
62
|
+
|
|
63
|
+
<logic lang="ts">
|
|
64
|
+
import { defineProps, onMounted, reactive, shared } from '@lightspeed-js/core'
|
|
65
|
+
import { api } from '../api.ts'
|
|
66
|
+
import { initialsOf } from '../content/person.ts'
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Somebody named on an entry: one of the CMS's people, or a name as typed.
|
|
70
|
+
*
|
|
71
|
+
* One box. Typing asks `/api/people` for matching names - ids and names only,
|
|
72
|
+
* which any signed-in account may ask for - and picking one stores the
|
|
73
|
+
* account. Anything not picked is kept as typed. The two are never both set,
|
|
74
|
+
* so a site reads the account's name where there is one and the words where
|
|
75
|
+
* there is not.
|
|
76
|
+
*/
|
|
77
|
+
const props = defineProps({
|
|
78
|
+
field: { default: {} },
|
|
79
|
+
path: { default: '' },
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
const user = shared('entry:value:' + props.path + '.user')
|
|
83
|
+
const name = shared('entry:value:' + props.path + '.name')
|
|
84
|
+
const readonly = shared('entry:readonly')
|
|
85
|
+
|
|
86
|
+
const state = reactive({
|
|
87
|
+
picked: false,
|
|
88
|
+
pickedName: '',
|
|
89
|
+
initials: '',
|
|
90
|
+
gone: false,
|
|
91
|
+
typed: '',
|
|
92
|
+
results: [] as { id: string; name: string; index: number }[],
|
|
93
|
+
open: false,
|
|
94
|
+
active: -1,
|
|
95
|
+
readonly: false,
|
|
96
|
+
placeholder: props.field.options?.placeholder || 'Start typing a name',
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
let asked = ''
|
|
100
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
101
|
+
|
|
102
|
+
/** What the cells hold, shown: a picked account by its name, or the words. */
|
|
103
|
+
async function show() {
|
|
104
|
+
state.readonly = Boolean(props.field.readOnly || readonly.value)
|
|
105
|
+
const id = typeof user.value === 'string' ? user.value : ''
|
|
106
|
+
if (!id) {
|
|
107
|
+
state.picked = false
|
|
108
|
+
state.typed = typeof name.value === 'string' ? name.value : ''
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
state.picked = true
|
|
112
|
+
if (id === asked) return
|
|
113
|
+
asked = id
|
|
114
|
+
const result = await api.get<{ people: { id: string; name: string }[] }>('/api/people?ids=' + encodeURIComponent(id))
|
|
115
|
+
if (asked !== id) return
|
|
116
|
+
const found = result.ok ? result.data.people[0] : undefined
|
|
117
|
+
state.gone = !found
|
|
118
|
+
state.pickedName = found?.name ?? 'Somebody'
|
|
119
|
+
state.initials = found ? initialsOf({ name: found.name }) : '?'
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function typed() {
|
|
123
|
+
user.value = undefined
|
|
124
|
+
name.value = state.typed.trim() ? state.typed : undefined
|
|
125
|
+
clearTimeout(timer)
|
|
126
|
+
const words = state.typed.trim()
|
|
127
|
+
if (!words) {
|
|
128
|
+
close()
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
timer = setTimeout(() => search(words), 150)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function search(words: string) {
|
|
135
|
+
const result = await api.get<{ people: { id: string; name: string }[] }>(
|
|
136
|
+
'/api/people?limit=8&q=' + encodeURIComponent(words),
|
|
137
|
+
)
|
|
138
|
+
if (state.typed.trim() !== words) return
|
|
139
|
+
state.results = result.ok ? result.data.people.map((one, index) => ({ ...one, index })) : []
|
|
140
|
+
state.active = -1
|
|
141
|
+
state.open = state.results.length > 0
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function pick(one: { id: string; name: string }) {
|
|
145
|
+
asked = one.id
|
|
146
|
+
user.value = one.id
|
|
147
|
+
name.value = undefined
|
|
148
|
+
state.picked = true
|
|
149
|
+
state.gone = false
|
|
150
|
+
state.pickedName = one.name
|
|
151
|
+
state.initials = initialsOf({ name: one.name })
|
|
152
|
+
state.typed = ''
|
|
153
|
+
close()
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Before the input loses focus, or the click would land on nothing. */
|
|
157
|
+
function choose(event: PointerEvent, one: { id: string; name: string }) {
|
|
158
|
+
event.preventDefault()
|
|
159
|
+
pick(one)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function unpick() {
|
|
163
|
+
asked = ''
|
|
164
|
+
user.value = undefined
|
|
165
|
+
state.picked = false
|
|
166
|
+
state.pickedName = ''
|
|
167
|
+
state.typed = ''
|
|
168
|
+
requestAnimationFrame(() => document.getElementById('f-' + props.path)?.focus())
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function key(event: KeyboardEvent) {
|
|
172
|
+
if (!state.open) return
|
|
173
|
+
const last = state.results.length - 1
|
|
174
|
+
if (event.key === 'ArrowDown') {
|
|
175
|
+
event.preventDefault()
|
|
176
|
+
state.active = state.active >= last ? 0 : state.active + 1
|
|
177
|
+
} else if (event.key === 'ArrowUp') {
|
|
178
|
+
event.preventDefault()
|
|
179
|
+
state.active = state.active <= 0 ? last : state.active - 1
|
|
180
|
+
} else if (event.key === 'Enter' && state.active >= 0) {
|
|
181
|
+
event.preventDefault()
|
|
182
|
+
pick(state.results[state.active]!)
|
|
183
|
+
} else if (event.key === 'Escape') {
|
|
184
|
+
event.preventDefault()
|
|
185
|
+
close()
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function blurred() {
|
|
190
|
+
close()
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function close() {
|
|
194
|
+
state.open = false
|
|
195
|
+
state.active = -1
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
onMounted(() => {
|
|
199
|
+
user.subscribe(show)
|
|
200
|
+
name.subscribe(() => {
|
|
201
|
+
if (!state.picked && name.value !== state.typed) show()
|
|
202
|
+
})
|
|
203
|
+
readonly.subscribe(show)
|
|
204
|
+
show()
|
|
205
|
+
})
|
|
206
|
+
</logic>
|
|
207
|
+
|
|
208
|
+
<style>
|
|
209
|
+
.person {
|
|
210
|
+
position: relative;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.person-picked {
|
|
214
|
+
display: flex;
|
|
215
|
+
gap: 0.5rem;
|
|
216
|
+
align-items: center;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.person-chip {
|
|
220
|
+
display: inline-flex;
|
|
221
|
+
flex-wrap: wrap;
|
|
222
|
+
gap: 0.5rem;
|
|
223
|
+
align-items: center;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.person-initials {
|
|
227
|
+
display: inline-grid;
|
|
228
|
+
place-items: center;
|
|
229
|
+
inline-size: 1.75rem;
|
|
230
|
+
block-size: 1.75rem;
|
|
231
|
+
border-radius: 50%;
|
|
232
|
+
background: var(--surface-2);
|
|
233
|
+
font-size: 0.75rem;
|
|
234
|
+
font-weight: 600;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.person-options {
|
|
238
|
+
position: absolute;
|
|
239
|
+
inset-inline: 0;
|
|
240
|
+
z-index: 10;
|
|
241
|
+
margin: 0.25rem 0 0;
|
|
242
|
+
padding: 0.25rem;
|
|
243
|
+
list-style: none;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.person-options .active {
|
|
247
|
+
background: var(--surface-hover);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.person-note {
|
|
251
|
+
margin: 0.25rem 0 0;
|
|
252
|
+
color: var(--text-2);
|
|
253
|
+
font-size: 0.8125rem;
|
|
254
|
+
}
|
|
255
|
+
</style>
|
package/src/config/fields.ts
CHANGED
|
@@ -101,3 +101,33 @@ export function imageUse(
|
|
|
101
101
|
],
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Somebody named on an entry: one of the CMS's people, or a name typed in.
|
|
107
|
+
*
|
|
108
|
+
* A byline is usually a colleague, who has an account, and sometimes not - a
|
|
109
|
+
* guest writer, a team, "Margaret Chen and Dev Rao". One input offers both:
|
|
110
|
+
* typing suggests people by name, and anything not picked is kept as typed.
|
|
111
|
+
*
|
|
112
|
+
* Stored as `{ user }` or `{ name }`, never both. `user` is a reference to an
|
|
113
|
+
* account and publishes as `{ name }` only, so a site reads
|
|
114
|
+
* `value.user?.name ?? value.name`.
|
|
115
|
+
*/
|
|
116
|
+
export function person(
|
|
117
|
+
name: string,
|
|
118
|
+
label: string,
|
|
119
|
+
options: { hint?: string; required?: boolean } = {},
|
|
120
|
+
): Field {
|
|
121
|
+
return {
|
|
122
|
+
name,
|
|
123
|
+
label,
|
|
124
|
+
type: "block",
|
|
125
|
+
component: "person",
|
|
126
|
+
...(options.required ? { required: true } : {}),
|
|
127
|
+
...(options.hint ? { options: { hint: options.hint } } : {}),
|
|
128
|
+
fields: [
|
|
129
|
+
{ name: "user", type: "reference", to: "users", label: "Person" },
|
|
130
|
+
{ name: "name", type: "text", label: "Name", maxLength: 200 },
|
|
131
|
+
],
|
|
132
|
+
}
|
|
133
|
+
}
|
package/src/config/types.ts
CHANGED
|
@@ -653,6 +653,11 @@ export interface TelaConfig {
|
|
|
653
653
|
* the one the admin should use.
|
|
654
654
|
*/
|
|
655
655
|
overrides?: string[]
|
|
656
|
+
/**
|
|
657
|
+
* Folders of the project's own components outside its `src`, relative to
|
|
658
|
+
* the project. `src` is always scanned.
|
|
659
|
+
*/
|
|
660
|
+
components?: string[]
|
|
656
661
|
}
|
|
657
662
|
|
|
658
663
|
export interface NavSection {
|
|
@@ -1044,6 +1049,7 @@ export function defineConfig(config: TelaConfig): TelaConfig {
|
|
|
1044
1049
|
navigation: config.navigation,
|
|
1045
1050
|
media: config.media,
|
|
1046
1051
|
...(config.overrides ? { overrides: config.overrides } : {}),
|
|
1052
|
+
...(config.components ? { components: config.components } : {}),
|
|
1047
1053
|
...(config.site ? { site: config.site } : {}),
|
|
1048
1054
|
...(config.siteName ? { siteName: config.siteName } : {}),
|
|
1049
1055
|
...(config.userNames ? { userNames: true } : {}),
|
package/src/content/entries.ts
CHANGED
|
@@ -30,7 +30,7 @@ export interface Entry {
|
|
|
30
30
|
const MAX_LIMIT = 100
|
|
31
31
|
|
|
32
32
|
const ENTRY_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
|
|
33
|
-
const isEntryId = (id: string) => ENTRY_ID.test(id)
|
|
33
|
+
export const isEntryId = (id: string) => ENTRY_ID.test(id)
|
|
34
34
|
|
|
35
35
|
export async function listEntries(
|
|
36
36
|
collection: Collection,
|
package/src/content/person.ts
CHANGED
|
@@ -12,6 +12,17 @@ export function personName(person: Named): string {
|
|
|
12
12
|
return full || text(person?.name) || text(person?.email)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* What to call somebody in public: their name, or nothing.
|
|
17
|
+
*
|
|
18
|
+
* Unlike `personName`, never their address. This is what leaves the CMS - a
|
|
19
|
+
* byline on a published page, a name offered to an editor who may not read
|
|
20
|
+
* accounts - and an address is not something either should be given.
|
|
21
|
+
*/
|
|
22
|
+
export function publicName(person: Named): string {
|
|
23
|
+
return [text(person?.firstName), text(person?.lastName)].filter(Boolean).join(" ") || text(person?.name)
|
|
24
|
+
}
|
|
25
|
+
|
|
15
26
|
/** Two letters to stand for somebody where there is no room for the name. */
|
|
16
27
|
export function initialsOf(person: Named): string {
|
|
17
28
|
const first = text(person?.firstName)
|
|
@@ -5,6 +5,7 @@ import { findCollection } from "./collections.ts"
|
|
|
5
5
|
import { summarise } from "./summary.ts"
|
|
6
6
|
import { linkedEntries, withLinkSlugs } from "./links.ts"
|
|
7
7
|
import { media } from "../media/index.ts"
|
|
8
|
+
import { publicName } from "./person.ts"
|
|
8
9
|
import type { MediaStore, StoredInfo } from "../media/store.ts"
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -265,6 +266,22 @@ export async function publishedReferences(
|
|
|
265
266
|
if (row.live && row.data?.slug) resolved.set(String(row.id), row.data.slug)
|
|
266
267
|
}
|
|
267
268
|
|
|
269
|
+
// Accounts, which have their own table. One is somebody to name - a byline -
|
|
270
|
+
// so it publishes as its name and nothing else; one without a name is left
|
|
271
|
+
// out, like a reference to something unpublished.
|
|
272
|
+
const found = new Set(rows.map((row: any) => String(row.id)))
|
|
273
|
+
const rest = ids.filter((id) => !found.has(id))
|
|
274
|
+
if (rest.length) {
|
|
275
|
+
const people = await sql`
|
|
276
|
+
select id, data from users
|
|
277
|
+
where id = any(string_to_array(${rest.join(",")}, ',')::uuid[])
|
|
278
|
+
`
|
|
279
|
+
for (const person of people) {
|
|
280
|
+
const name = publicName(person.data)
|
|
281
|
+
if (name) resolved.set(String(person.id), { name })
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
268
285
|
return resolved
|
|
269
286
|
}
|
|
270
287
|
|
package/src/content/users.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { narrowing } from "./filters.ts"
|
|
|
3
3
|
import { sql } from "../db/client.ts"
|
|
4
4
|
import type { Collection } from "../config/types.ts"
|
|
5
5
|
import type { Entry, EntrySummary } from "./entries.ts"
|
|
6
|
+
import { publicName } from "./person.ts"
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Users, stored where authentication needs them.
|
|
@@ -121,6 +122,37 @@ export async function listUsers(
|
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Accounts as somebody to name: an id and a name, nothing else.
|
|
127
|
+
*
|
|
128
|
+
* For the person field, where an editor picks who wrote something. Editors
|
|
129
|
+
* may not read accounts - they are how permissions are held - so this answers
|
|
130
|
+
* any signed-in account but says only what a byline would. An account without
|
|
131
|
+
* a name is left out: there is nothing it could be called but its address.
|
|
132
|
+
*/
|
|
133
|
+
export async function peopleNamed({
|
|
134
|
+
search = "",
|
|
135
|
+
ids = [],
|
|
136
|
+
limit = 20,
|
|
137
|
+
}: { search?: string; ids?: string[]; limit?: number } = {}): Promise<{ id: string; name: string }[]> {
|
|
138
|
+
// Every word typed somewhere in the name, so "nick pau" finds Nick Paustian.
|
|
139
|
+
const patterns = search.trim().split(/\s+/).filter(Boolean).map((word) => `%${word}%`).join("\n")
|
|
140
|
+
const wanted = ids.join(",")
|
|
141
|
+
const rows = await sql`
|
|
142
|
+
select id, data from users
|
|
143
|
+
where (${wanted} = '' or id = any(string_to_array(${wanted}, ',')::uuid[]))
|
|
144
|
+
and not exists (
|
|
145
|
+
select 1 from unnest(string_to_array(nullif(${patterns}, ''), E'\n')) as pattern
|
|
146
|
+
where concat_ws(' ', data ->> 'firstName', data ->> 'lastName', data ->> 'name') not ilike pattern
|
|
147
|
+
)
|
|
148
|
+
order by lower(concat_ws(' ', data ->> 'firstName', data ->> 'lastName', data ->> 'name'))
|
|
149
|
+
limit ${Math.min(Math.max(limit, 1), MAX_LIMIT)}
|
|
150
|
+
`
|
|
151
|
+
return rows
|
|
152
|
+
.map((row: any) => ({ id: String(row.id), name: publicName(row.data) }))
|
|
153
|
+
.filter((one: { name: string }) => one.name)
|
|
154
|
+
}
|
|
155
|
+
|
|
124
156
|
export async function getUser(_: Collection, id: string): Promise<Entry | null> {
|
|
125
157
|
const rows = await sql`
|
|
126
158
|
select id, email, data, created_at, updated_at from users where id = ${id}
|
package/src/index.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type {
|
|
|
20
20
|
WorkflowStage,
|
|
21
21
|
NavSection,
|
|
22
22
|
} from "./config/types.ts"
|
|
23
|
-
export { imageUse, slugField } from "./config/fields.ts"
|
|
23
|
+
export { imageUse, person, slugField } from "./config/fields.ts"
|
|
24
24
|
export type { UrlRule } from "./content/url.ts"
|
|
25
25
|
export type { CounterSpec, Band, Tone } from "./content/counter.ts"
|
|
26
26
|
export type { SharingOptions } from "./content/sharing.ts"
|
package/src/project.ts
CHANGED
|
@@ -34,13 +34,16 @@ export const PROJECT_ROOT = dirname(CONFIG_PATH)
|
|
|
34
34
|
export const DIST = resolve(PROJECT_ROOT, "dist")
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* Where components come from: Tela's `src`,
|
|
38
|
-
* somewhere else
|
|
39
|
-
* collection that uses
|
|
37
|
+
* Where components come from: Tela's `src`, the project's when that is
|
|
38
|
+
* somewhere else, and any other folders the project's config names. All
|
|
39
|
+
* scanned whole, so a project's input can sit beside the collection that uses
|
|
40
|
+
* it.
|
|
40
41
|
*/
|
|
41
|
-
export function componentRoots(): string[] {
|
|
42
|
+
export function componentRoots(extra: string[] = []): string[] {
|
|
42
43
|
const roots = [resolve(TELA_ROOT, "src")]
|
|
43
|
-
const
|
|
44
|
-
|
|
44
|
+
for (const dir of ["src", ...extra]) {
|
|
45
|
+
const project = resolve(PROJECT_ROOT, dir)
|
|
46
|
+
if (!roots.includes(project)) roots.push(project)
|
|
47
|
+
}
|
|
45
48
|
return roots
|
|
46
49
|
}
|
package/src/server/index.ts
CHANGED
|
@@ -56,10 +56,11 @@ import { findCollection } from "../content/collections.ts"
|
|
|
56
56
|
import { createAndStage, storeFor, isPublishable } from "../content/store.ts"
|
|
57
57
|
import { withDerived } from "../content/derive-values.ts"
|
|
58
58
|
import { withoutSecrets } from "../config/components.ts"
|
|
59
|
-
import { countUsers } from "../content/users.ts"
|
|
59
|
+
import { countUsers, peopleNamed } from "../content/users.ts"
|
|
60
60
|
import { blocking, checkEverything, checkServerRules } from "../content/validate.ts"
|
|
61
61
|
import {
|
|
62
62
|
getEntry,
|
|
63
|
+
isEntryId,
|
|
63
64
|
isPublished,
|
|
64
65
|
purgeEntry,
|
|
65
66
|
} from "../content/entries.ts"
|
|
@@ -1187,6 +1188,27 @@ const server = Bun.serve({
|
|
|
1187
1188
|
* Unpublished ones are included and say so, since a link written now may
|
|
1188
1189
|
* go live with them.
|
|
1189
1190
|
*/
|
|
1191
|
+
/**
|
|
1192
|
+
* People to name on an entry: ids and names only, for anyone signed in.
|
|
1193
|
+
*
|
|
1194
|
+
* The person field asks this rather than `/api/entries/users`, which an
|
|
1195
|
+
* editor may not read - accounts are how permissions are held - and which
|
|
1196
|
+
* would hand over addresses and roles to offer a byline.
|
|
1197
|
+
*/
|
|
1198
|
+
"/api/people": {
|
|
1199
|
+
GET: authed(async (req: { params?: unknown } & Request) => {
|
|
1200
|
+
const params = new URL(req.url).searchParams
|
|
1201
|
+
const ids = (params.get("ids") ?? "").split(",").filter((one) => isEntryId(one))
|
|
1202
|
+
return json({
|
|
1203
|
+
people: await peopleNamed({
|
|
1204
|
+
search: params.get("q") ?? "",
|
|
1205
|
+
ids,
|
|
1206
|
+
limit: Number(params.get("limit") ?? 20) || 20,
|
|
1207
|
+
}),
|
|
1208
|
+
})
|
|
1209
|
+
}),
|
|
1210
|
+
},
|
|
1211
|
+
|
|
1190
1212
|
"/api/links": {
|
|
1191
1213
|
GET: authed(async (req: { params?: unknown } & Request, user) => {
|
|
1192
1214
|
const params = new URL(req.url).searchParams
|
package/src/vite.ts
CHANGED
|
@@ -30,7 +30,7 @@ const MEDIA_LIBRARY = dirname(require.resolve("@pseudolux-ui/media-library"))
|
|
|
30
30
|
* this bundles the whole thing statically and runs under Node too.
|
|
31
31
|
*/
|
|
32
32
|
export function telaVite(config: TelaConfig): UserConfig {
|
|
33
|
-
const projectComponents = componentRoots().slice(1)
|
|
33
|
+
const projectComponents = componentRoots(config.components).slice(1)
|
|
34
34
|
|
|
35
35
|
return {
|
|
36
36
|
root: TELA_ROOT,
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
<view>
|
|
2
|
-
<span class="status" $class="state.tone">{{ state.label }}</span>
|
|
3
|
-
</view>
|
|
4
|
-
|
|
5
|
-
<logic lang="ts">
|
|
6
|
-
import { defineProps, reactive } from '@lightspeed-js/core'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Whether a dated thing is on, over, or still to come.
|
|
10
|
-
*
|
|
11
|
-
* The summary-component contract: `value` is whatever the part named - the
|
|
12
|
-
* whole entry when it named nothing, which is this case. A status is not one
|
|
13
|
-
* field. It is an opening date and a closing one read together, which is
|
|
14
|
-
* exactly why a summary part is declared where it is consumed rather than on a
|
|
15
|
-
* field that could only ever know half of it.
|
|
16
|
-
*/
|
|
17
|
-
const props = defineProps({
|
|
18
|
-
value: { default: {} },
|
|
19
|
-
options: { default: {} },
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Compared as ISO text.
|
|
24
|
-
*
|
|
25
|
-
* Dates are `YYYY-MM-DD`, so string comparison is date comparison - no parsing,
|
|
26
|
-
* and no timezone deciding that a show closing today closed yesterday.
|
|
27
|
-
*/
|
|
28
|
-
function today() {
|
|
29
|
-
return new Date().toISOString().slice(0, 10)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function status() {
|
|
33
|
-
const opens = props.value?.[props.options?.opens || 'opens']
|
|
34
|
-
const closes = props.value?.[props.options?.closes || 'closes']
|
|
35
|
-
const now = today()
|
|
36
|
-
|
|
37
|
-
if (!opens) return { label: '', tone: '' }
|
|
38
|
-
if (opens > now) return { label: 'Upcoming', tone: 'upcoming' }
|
|
39
|
-
if (closes && closes < now) return { label: 'Closed', tone: 'closed' }
|
|
40
|
-
return { label: 'On now', tone: 'now' }
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const state = reactive(status())
|
|
44
|
-
</logic>
|
|
45
|
-
|
|
46
|
-
<style>
|
|
47
|
-
.status {
|
|
48
|
-
padding: 0.1rem 0.5rem;
|
|
49
|
-
border-radius: 999px;
|
|
50
|
-
font-size: 0.72rem;
|
|
51
|
-
font-weight: 600;
|
|
52
|
-
letter-spacing: 0.02em;
|
|
53
|
-
white-space: nowrap;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/* Empty when there is no opening date - nothing to say, and a blank pill says
|
|
57
|
-
something. */
|
|
58
|
-
.status:empty {
|
|
59
|
-
display: none;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.status.now {
|
|
63
|
-
background: #e4f6ea;
|
|
64
|
-
color: #1d6b3a;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.status.upcoming {
|
|
68
|
-
background: #e8effc;
|
|
69
|
-
color: #24518f;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.status.closed {
|
|
73
|
-
background: #f1f3f5;
|
|
74
|
-
color: #6b7683;
|
|
75
|
-
}
|
|
76
|
-
</style>
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { Block } from "../../config/types.ts"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* What a panel can be.
|
|
5
|
-
*
|
|
6
|
-
* Declared once and shared by both slots - a block is data, so offering the
|
|
7
|
-
* same set in two places is a reference rather than a copy. "Copy" and "Copy
|
|
8
|
-
* with a link" are two shapes rather than one with a conditional: the editor
|
|
9
|
-
* picks a thing, and what is required stays honest.
|
|
10
|
-
*/
|
|
11
|
-
export const PANELS: Block[] = [
|
|
12
|
-
{
|
|
13
|
-
name: "image",
|
|
14
|
-
label: "Image",
|
|
15
|
-
description: "A single picture.",
|
|
16
|
-
fields: [
|
|
17
|
-
// A reference to the library, not a typed path. Alt text travels with
|
|
18
|
-
// the picture rather than being retyped at every use - which is how it
|
|
19
|
-
// ends up missing on the third one.
|
|
20
|
-
{
|
|
21
|
-
name: "image",
|
|
22
|
-
type: "reference",
|
|
23
|
-
to: "media",
|
|
24
|
-
// Stored as a reference like any other; drawn as the library. Type and
|
|
25
|
-
// component are separate for exactly this - the shape in the database
|
|
26
|
-
// does not change because the way of choosing did.
|
|
27
|
-
component: "mediaPicker",
|
|
28
|
-
label: "Image",
|
|
29
|
-
required: true,
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: "copy",
|
|
35
|
-
label: "Copy",
|
|
36
|
-
description: "A heading and some text.",
|
|
37
|
-
fields: [
|
|
38
|
-
{ name: "heading", type: "text", label: "Heading" },
|
|
39
|
-
{ name: "body", type: "markdown", label: "Body" },
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: "copyCta",
|
|
44
|
-
label: "Copy with a link",
|
|
45
|
-
description: "Text, and a button that goes somewhere.",
|
|
46
|
-
fields: [
|
|
47
|
-
{ name: "heading", type: "text", label: "Heading" },
|
|
48
|
-
{ name: "body", type: "markdown", label: "Body" },
|
|
49
|
-
{ name: "label", type: "text", label: "Link text", required: true },
|
|
50
|
-
{ name: "href", type: "text", label: "Link target", required: true },
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
]
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { dateRange, splitBlock, type Collection } from "../../config/types.ts"
|
|
2
|
-
import { slugField } from "../../config/fields.ts"
|
|
3
|
-
import { PANELS } from "./panels.ts"
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Exhibition landing pages.
|
|
7
|
-
*
|
|
8
|
-
* A real content model rather than an invented one, so the gaps show up
|
|
9
|
-
* honestly: `image` has no field component yet, and the editor says so rather
|
|
10
|
-
* than pretending.
|
|
11
|
-
*
|
|
12
|
-
* Everything this collection needs lives beside this file - the panels it
|
|
13
|
-
* offers, and `StatusSummary.lsp`, which draws its "on now" pill. A component
|
|
14
|
-
* that only one collection uses belongs with that collection; the registry
|
|
15
|
-
* scans the whole source tree, so where a `.lsp` file sits is an organising
|
|
16
|
-
* decision rather than a technical one.
|
|
17
|
-
*/
|
|
18
|
-
export const exhibitions: Collection = {
|
|
19
|
-
name: "exhibitions",
|
|
20
|
-
label: "Exhibitions",
|
|
21
|
-
titleField: "title",
|
|
22
|
-
// How an exhibition is represented wherever something else has to show one:
|
|
23
|
-
// the listing, a reference picker, a chip on a chosen reference. Declared
|
|
24
|
-
// once, because four screens deciding for themselves is four screens that
|
|
25
|
-
// disagree.
|
|
26
|
-
summary: {
|
|
27
|
-
subtitle: "{subtitle}",
|
|
28
|
-
// A template, exactly like `derive` - and it drops the dash along with a
|
|
29
|
-
// closing date that is not there.
|
|
30
|
-
meta: ["{opens} - {closes}", { component: "status" }],
|
|
31
|
-
},
|
|
32
|
-
fields: [
|
|
33
|
-
{
|
|
34
|
-
name: "title",
|
|
35
|
-
type: "text",
|
|
36
|
-
label: "Title",
|
|
37
|
-
required: true,
|
|
38
|
-
maxLength: 120,
|
|
39
|
-
sortable: true,
|
|
40
|
-
searchable: true,
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
slugField(),
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
name: "subtitle",
|
|
47
|
-
type: "text",
|
|
48
|
-
label: "Subtitle",
|
|
49
|
-
maxLength: 160,
|
|
50
|
-
// Searchable, not filterable: nobody narrows a listing *to* a subtitle,
|
|
51
|
-
// but half of what somebody remembers about a show is in one.
|
|
52
|
-
searchable: true,
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
// Admin furniture: it says something useful and stores nothing.
|
|
56
|
-
{
|
|
57
|
-
name: "datesNote",
|
|
58
|
-
type: "note",
|
|
59
|
-
text: "Dates drive the listing order and the “on now” badge, so fill them in even for a show that has closed.",
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
// Sugar that expands to exactly two ordinary date fields - see `dateRange`.
|
|
63
|
-
...dateRange({
|
|
64
|
-
legend: "Dates",
|
|
65
|
-
duration: true,
|
|
66
|
-
start: {
|
|
67
|
-
name: "opens",
|
|
68
|
-
label: "Opens",
|
|
69
|
-
required: true,
|
|
70
|
-
sortable: true,
|
|
71
|
-
filterable: true,
|
|
72
|
-
},
|
|
73
|
-
end: { name: "closes", label: "Closes", sortable: true },
|
|
74
|
-
}),
|
|
75
|
-
|
|
76
|
-
// A composite: one object with a fixed shape, addressed as
|
|
77
|
-
// `credit.photographer` - and `credit.full` written beside the parts when
|
|
78
|
-
// it publishes, so every template that shows a credit shows the same thing
|
|
79
|
-
// without joining it itself.
|
|
80
|
-
{
|
|
81
|
-
name: "credit",
|
|
82
|
-
type: "block",
|
|
83
|
-
label: "Image credit",
|
|
84
|
-
fields: [
|
|
85
|
-
{ name: "photographer", type: "text", label: "Photographer" },
|
|
86
|
-
{ name: "year", type: "text", label: "Year" },
|
|
87
|
-
{ name: "collection", type: "text", label: "Collection" },
|
|
88
|
-
],
|
|
89
|
-
derive: {
|
|
90
|
-
full: "{photographer}, {year}. {collection}",
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
// A group arranges the form; these still store exactly where they did
|
|
95
|
-
// before it existed.
|
|
96
|
-
{
|
|
97
|
-
name: "details",
|
|
98
|
-
type: "group",
|
|
99
|
-
label: "Details",
|
|
100
|
-
collapsed: true,
|
|
101
|
-
// What it shows while it is shut. `reference` is a summary component,
|
|
102
|
-
// the same one a listing would use - and it is handed `to` from the
|
|
103
|
-
// field it previews, so this does not repeat what the field already
|
|
104
|
-
// says.
|
|
105
|
-
peek: [
|
|
106
|
-
{ component: "reference", from: "venue" },
|
|
107
|
-
{ component: "reference", from: "artists" },
|
|
108
|
-
],
|
|
109
|
-
fields: [
|
|
110
|
-
// Stored as the venue's id, published as its slug. The one-to-many side
|
|
111
|
-
// of the relationship: a venue holds no list of exhibitions, because a
|
|
112
|
-
// relationship recorded at both ends is one that can come to disagree
|
|
113
|
-
// with itself.
|
|
114
|
-
{
|
|
115
|
-
name: "venue",
|
|
116
|
-
type: "reference",
|
|
117
|
-
to: "venues",
|
|
118
|
-
label: "Venue",
|
|
119
|
-
filterable: true,
|
|
120
|
-
},
|
|
121
|
-
// And the many-to-many: an exhibition has artists, an artist has
|
|
122
|
-
// exhibitions, and neither field knows about the other.
|
|
123
|
-
{
|
|
124
|
-
name: "artists",
|
|
125
|
-
type: "reference",
|
|
126
|
-
to: "people",
|
|
127
|
-
many: true,
|
|
128
|
-
label: "Artists",
|
|
129
|
-
filterable: true,
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
// The block editor: a list whose rows each choose a shape. Each row records
|
|
135
|
-
// which one under `block`, so the content is legible without this file.
|
|
136
|
-
{
|
|
137
|
-
name: "sections",
|
|
138
|
-
type: "repeater",
|
|
139
|
-
label: "Sections",
|
|
140
|
-
blocks: [
|
|
141
|
-
{
|
|
142
|
-
name: "slider",
|
|
143
|
-
label: "Slider",
|
|
144
|
-
description: "A row of images that scrolls.",
|
|
145
|
-
fields: [
|
|
146
|
-
{ name: "title", type: "text", label: "Title" },
|
|
147
|
-
// A list inside a shape - and it is an ordinary repeater, rendered
|
|
148
|
-
// by the same registry one level further down.
|
|
149
|
-
{
|
|
150
|
-
name: "items",
|
|
151
|
-
type: "repeater",
|
|
152
|
-
label: "Slides",
|
|
153
|
-
of: [
|
|
154
|
-
{ name: "image", type: "reference", to: "media", label: "Image" },
|
|
155
|
-
{ name: "caption", type: "text", label: "Caption" },
|
|
156
|
-
],
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
},
|
|
160
|
-
// Two panels today, because the config says two. The same block with
|
|
161
|
-
// `cells: { min: 1 }` would be an open-ended grid.
|
|
162
|
-
splitBlock({
|
|
163
|
-
name: "twoPanel",
|
|
164
|
-
label: "Two panel",
|
|
165
|
-
description: "Two side-by-side panels, each a block of its own.",
|
|
166
|
-
cells: { min: 1, max: 5 },
|
|
167
|
-
of: PANELS,
|
|
168
|
-
layouts: [
|
|
169
|
-
{ value: "50-50", label: "Equal" },
|
|
170
|
-
{ value: "60-40", label: "Wider left" },
|
|
171
|
-
{ value: "40-60", label: "Wider right" },
|
|
172
|
-
],
|
|
173
|
-
}),
|
|
174
|
-
{
|
|
175
|
-
name: "content",
|
|
176
|
-
label: "Content",
|
|
177
|
-
description: "A heading and a body of text.",
|
|
178
|
-
fields: [
|
|
179
|
-
{ name: "heading", type: "text", label: "Heading" },
|
|
180
|
-
{
|
|
181
|
-
name: "body",
|
|
182
|
-
type: "markdown",
|
|
183
|
-
label: "Body",
|
|
184
|
-
tools: ["bold", "italic", "link"],
|
|
185
|
-
},
|
|
186
|
-
],
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
},
|
|
190
|
-
|
|
191
|
-
{
|
|
192
|
-
name: "body",
|
|
193
|
-
type: "markdown",
|
|
194
|
-
label: "About the exhibition",
|
|
195
|
-
// The long-form field, so it gets the long-form tools. Everything else on
|
|
196
|
-
// this model keeps the default two.
|
|
197
|
-
tools: ["bold", "italic", "heading", "link", "bullet", "quote"],
|
|
198
|
-
searchable: true,
|
|
199
|
-
},
|
|
200
|
-
],
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export default exhibitions
|
package/src/collections/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Collection } from "../config/types.ts"
|
|
2
|
-
import exhibitions from "./exhibitions/schema.ts"
|
|
3
|
-
import venues from "./venues/schema.ts"
|
|
4
|
-
import people from "./people/schema.ts"
|
|
5
|
-
import users from "./users/schema.ts"
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Every collection this CMS holds.
|
|
9
|
-
*
|
|
10
|
-
* One import for anything that needs the whole model, and a named one for
|
|
11
|
-
* anything that needs a particular collection - a test that wants `venues`
|
|
12
|
-
* should not have to know which folder it lives in.
|
|
13
|
-
*
|
|
14
|
-
* Listed rather than discovered from the filesystem. The order is the order of
|
|
15
|
-
* the admin's navigation, and a collection that exists because a file exists
|
|
16
|
-
* is a collection nobody decided to add.
|
|
17
|
-
*/
|
|
18
|
-
export const collections: Collection[] = [exhibitions, venues, people, users]
|
|
19
|
-
|
|
20
|
-
export { exhibitions, venues, people, users }
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Collection } from "../../config/types.ts"
|
|
2
|
-
import { slugField } from "../../config/fields.ts"
|
|
3
|
-
|
|
4
|
-
/** Artists, and anyone else an entry needs to name. */
|
|
5
|
-
export const people: Collection = {
|
|
6
|
-
name: "people",
|
|
7
|
-
label: "People",
|
|
8
|
-
titleField: "title",
|
|
9
|
-
fields: [
|
|
10
|
-
{ name: "title", type: "text", label: "Name", required: true, searchable: true },
|
|
11
|
-
slugField(),
|
|
12
|
-
{ name: "bio", type: "markdown", label: "Biography", searchable: true },
|
|
13
|
-
],
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default people
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Collection } from "../../config/types.ts"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Extending the built-in users collection.
|
|
5
|
-
*
|
|
6
|
-
* The same operation as adding a field to any other type. The base is an
|
|
7
|
-
* address, a password and a role: a name is useful *here*, because this CMS
|
|
8
|
-
* shows who edited what, and it is added like any other field.
|
|
9
|
-
*/
|
|
10
|
-
export const users: Collection = {
|
|
11
|
-
name: "users",
|
|
12
|
-
titleField: "name",
|
|
13
|
-
fields: [
|
|
14
|
-
{ name: "name", type: "text", label: "Name", required: true, searchable: true },
|
|
15
|
-
],
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default users
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Collection } from "../../config/types.ts"
|
|
2
|
-
import { slugField } from "../../config/fields.ts"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Somewhere an exhibition happens.
|
|
6
|
-
*
|
|
7
|
-
* Small on purpose. It exists to be pointed at, and what a venue *is* can grow
|
|
8
|
-
* without any of the entries referring to it changing.
|
|
9
|
-
*/
|
|
10
|
-
export const venues: Collection = {
|
|
11
|
-
name: "venues",
|
|
12
|
-
label: "Venues",
|
|
13
|
-
titleField: "title",
|
|
14
|
-
// Two venues can share a name; where they are is what tells them apart,
|
|
15
|
-
// which matters most in the picker where the name is all there is.
|
|
16
|
-
summary: { subtitle: "{address.suburb} {address.state}" },
|
|
17
|
-
fields: [
|
|
18
|
-
{ name: "title", type: "text", label: "Name", required: true, searchable: true },
|
|
19
|
-
slugField(),
|
|
20
|
-
{
|
|
21
|
-
name: "address",
|
|
22
|
-
type: "block",
|
|
23
|
-
label: "Address",
|
|
24
|
-
fields: [
|
|
25
|
-
{ name: "line1", type: "text", label: "Street" },
|
|
26
|
-
{ name: "suburb", type: "text", label: "Suburb", searchable: true },
|
|
27
|
-
{ name: "state", type: "text", label: "State" },
|
|
28
|
-
{ name: "postcode", type: "text", label: "Postcode" },
|
|
29
|
-
],
|
|
30
|
-
derive: {
|
|
31
|
-
full: "{line1}, {suburb} {state} {postcode}",
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default venues
|