@pirateandfox/pagestack 0.1.0-beta.6 → 0.1.0-beta.8

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.
Files changed (51) hide show
  1. package/README.md +73 -7
  2. package/index.mjs +41 -8
  3. package/package.json +1 -1
  4. package/src/client/auth.ts +5 -5
  5. package/src/client/collection.ts +6 -6
  6. package/src/client/editor.ts +105 -105
  7. package/src/client/form.ts +49 -29
  8. package/src/client/global.ts +4 -4
  9. package/src/client/inline.ts +4 -4
  10. package/src/client/inserter.ts +11 -11
  11. package/src/client/invite.ts +4 -4
  12. package/src/client/item.ts +308 -17
  13. package/src/client/live.ts +92 -0
  14. package/src/client/media.ts +12 -12
  15. package/src/client/pages.ts +14 -14
  16. package/src/client/picker.ts +30 -30
  17. package/src/client/preview.css +58 -58
  18. package/src/client/rich.ts +14 -14
  19. package/src/client/shell.css +281 -265
  20. package/src/client/state.ts +2 -2
  21. package/src/client/tomarkdown.ts +56 -0
  22. package/src/client/tree.ts +11 -11
  23. package/src/client/ui.ts +13 -13
  24. package/src/client/users.ts +6 -6
  25. package/src/core/auth.ts +1 -1
  26. package/src/core/markdown.ts +127 -0
  27. package/src/core/pages.ts +6 -2
  28. package/src/core/storage-github.ts +60 -6
  29. package/src/core/storage-local.ts +1 -0
  30. package/src/core/storage.ts +19 -0
  31. package/src/routes/Nav.astro +5 -3
  32. package/src/routes/api/asset.ts +2 -2
  33. package/src/routes/api/collection.ts +30 -8
  34. package/src/routes/api/live.ts +27 -0
  35. package/src/routes/edit-collection.astro +14 -14
  36. package/src/routes/edit-global.astro +8 -8
  37. package/src/routes/edit-index.astro +18 -18
  38. package/src/routes/edit-item.astro +30 -17
  39. package/src/routes/edit-media.astro +9 -9
  40. package/src/routes/edit-page.astro +32 -30
  41. package/src/routes/edit-users.astro +9 -9
  42. package/src/routes/enroll.astro +6 -6
  43. package/src/routes/login.astro +6 -6
  44. package/src/routes/preview-item.astro +33 -0
  45. package/src/routes/preview.astro +1 -1
  46. package/src/routes/uploaded.ts +26 -0
  47. package/src/runtime.ts +16 -2
  48. package/src/server/context.ts +3 -3
  49. package/src/server/middleware.ts +20 -13
  50. package/src/server/webauthn.ts +2 -2
  51. package/src/virtual.d.ts +1 -0
package/README.md CHANGED
@@ -4,8 +4,8 @@ A visual editor for Astro sites where pages are a stack of sections. Git-only: s
4
4
  the public site stays static, and nothing lives outside the repo.
5
5
 
6
6
  - The public site stays **fully static**. `astro build` is unchanged.
7
- - The editor (`/edit/*`, `/api/editor/*`) is on-demand rendered and only exists in `astro dev`
8
- or in a build made with `EDITOR=1` (which adds `@astrojs/node`).
7
+ - The editor (`/edit/*`, `/api/editor/*`) is on-demand rendered and only exists when asked for:
8
+ `EDITOR=dev astro dev`, or a build made with `EDITOR=1` (which adds `@astrojs/node` unless the site has an adapter).
9
9
  - Pages are JSON documents in the repo (`src/content/pages/<slug>.json`). Saving writes a file
10
10
  (dev) or makes **one commit** through the GitHub API (production). Nothing is stored anywhere else.
11
11
  - Login is **passkeys** (WebAuthn). Users' public keys live in a committed `editor-users.json`;
@@ -58,7 +58,8 @@ export default defineConfig({
58
58
  ```
59
59
 
60
60
  ```bash
61
- npm run dev # editor at http://localhost:4321/edit, saves to the working tree
61
+ EDITOR=dev astro dev # editor at http://localhost:4321/edit, saves to the working tree
62
+ astro dev # the site alone: no editor, nothing can write content
62
63
  EDITOR=1 astro build # dist/server (node) + dist/client — the editor for a host
63
64
  astro build # plain static site, no editor code
64
65
  ```
@@ -213,6 +214,54 @@ export const globals = {
213
214
  };
214
215
  ```
215
216
 
217
+ #### Editing a collection item on its own page
218
+
219
+ Give a collection a layout in `previews` (an option on the integration) and its items open on that
220
+ page in the editor: click the title, a paragraph, a heading, a list or a quote and type; click an
221
+ image to pick another; tables, code and nested lists open the Markdown with that block selected. The
222
+ **+** beside a block, or `/` in an empty one, adds a paragraph, heading, list, quote, image or table
223
+ there. **Page** and **Markdown** switch views, and Preview ↗ shows the unsaved item in a tab. An
224
+ edited block is turned back into Markdown and replaces only its own lines, so the rest of the file
225
+ stays byte-for-byte as it was.
226
+
227
+ The ⋮ menu has **Change URL** (moves the file; with the collection's `url` and a redirects file, the
228
+ old address redirects in the same commit), **Revisions** (the file's git history; Restore loads one
229
+ as unsaved changes, covering the body and the fields the editor shows) and **Delete**.
230
+
231
+ ```js
232
+ pagestack({ /* … */ previews: { blog: './src/editor/PostPreview.astro' } })
233
+ ```
234
+
235
+ The layout gets `{ item: { id, collection, data, body, html, headings }, editing }`. `html` is the
236
+ sanitised body (render it with `set:html`), blocks already marked; `data` is the frontmatter as
237
+ written, so apply the defaults and date parsing your content schema would. Mark the item's own
238
+ fields with `itemField(editing, 'title')` from the runtime, or write the same two attributes
239
+ (`data-ps-field`, `data-ps-field-type`) yourself. Sharing one component between the real page
240
+ and the preview keeps them identical:
241
+
242
+ ```astro
243
+ ---
244
+ // src/editor/PostPreview.astro
245
+ import PostPage from '../components/PostPage.astro';
246
+ const { item, editing } = Astro.props;
247
+ ---
248
+ <PostPage data={{ ...item.data, date: new Date(item.data.date) }} headings={item.headings} editing={editing}>
249
+ <Fragment set:html={item.html} />
250
+ </PostPage>
251
+ ```
252
+
253
+ The preview renders on the editor's server (a Worker on Cloudflare), so whatever the layout imports
254
+ must run there: no `node:fs` reads of the project, no native modules (sharp, resvg), and no import of
255
+ `content.config.ts` (its loaders only run in a build). `getCollection` works. The page's own scripts
256
+ are left out of the editor's frame.
257
+
258
+ In the block editor's preview the site's own scripts do run (tabs, accordions), but scripts from
259
+ other origins are refused, so analytics, captchas and chat widgets stay out of the editor.
260
+ `previewScripts: 'all'` lifts that for a site whose preview needs an outside script.
261
+
262
+ An image field stored as a bare URL can name its alt-text field, `{ type: 'image', asUrl: true,
263
+ altField: 'imageAlt' }`, and the picker fills it in.
264
+
216
265
  Blocks can set `category` and `keywords` for the inserter. A `list` field is a repeatable group of
217
266
  `fields`, with `itemLabel` naming the field that titles each row.
218
267
 
@@ -235,7 +284,22 @@ than setting a hard limit. Passkeys are what actually stops guessing.
235
284
  | `storage` | Reads | Saves | Uploads |
236
285
  |---|---|---|---|
237
286
  | `local` (dev default) | working tree | writes the JSON file (you commit) | written to `public/images/uploads/` |
238
- | `github` (build default) | Contents API on `github.branch` | one commit via the Git Data API: blobs → tree → commit → ref; with `pullRequest: true` a new `site-editor/<timestamp>-<sha>` branch + PR instead | wait on a `pagestack-uploads` branch, shown to signed-in editors, until the next save brings them along |
287
+ | `github` (build default) | Contents API on `github.branch` | one commit via the Git Data API: blobs → tree → commit → ref; with `pullRequest: true` a new `site-editor/<timestamp>-<sha>` branch + PR instead | wait on a `pagestack-uploads` branch until the next save brings them along; the editor serves them, and anything committed since it was built, to signed-in editors |
288
+
289
+ ### Staging and Go live
290
+
291
+ With `github.live`, saves stay on `github.branch` (staging) and the public site builds from `live`.
292
+ Every screen gets a **Go live** button counting the saved changes the live site doesn't have yet;
293
+ it lists them, links to `github.stagingUrl` if you give one, and puts them all on `live` in one step.
294
+ That is a fast-forward when nobody committed to `live` directly. When someone did, it makes a merge
295
+ commit and moves staging to it; when their change conflicts, it refuses and says so, and a person
296
+ merges in GitHub. A burst of saves becomes one production build.
297
+
298
+ ```js
299
+ github: { repo: 'acme/site', branch: 'develop', live: 'main', stagingUrl: 'https://develop.acme.pages.dev/' }
300
+ ```
301
+
302
+ Point the host's production deploy at `live` and its preview deploys at the staging branch.
239
303
 
240
304
  The GitHub token (`GITHUB_TOKEN` or `EDITOR_GITHUB_TOKEN`) is read from the environment on the
241
305
  server only. A fine-grained token with *Contents: write* (and *Pull requests: write* for PR mode)
@@ -249,7 +313,7 @@ like any other push.
249
313
  - `editor-users.json` (committed, path configurable with `usersFile`) holds users and the
250
314
  **public keys** of their passkeys. Nothing in it is secret.
251
315
  - `EDITOR_SECRET` (≥ 16 chars, environment only) signs three kinds of short-lived tokens:
252
- WebAuthn challenges (5 min), the session cookie (`ase_session`, HttpOnly, SameSite=Lax, 12 h) and
316
+ WebAuthn challenges (5 min), the session cookie (`ps_session`, HttpOnly, SameSite=Lax, 12 h) and
253
317
  invite links (3 days). Tokens are `base64url(json).base64url(hmac-sha256)` with the expiry inside,
254
318
  so there is no server state.
255
319
  - **Invites** are single-use: the invite id is recorded on the credential it created. Make the first
@@ -295,14 +359,16 @@ editor response is `noindex` and `no-store`.
295
359
  |---|---|---|
296
360
  | `renderer` | required, unless `pages: false` | Astro component rendering `{ page, editing }` |
297
361
  | `pages` | `true` | `false` for a site with no block pages: only collections, globals and media |
362
+ | `previews` | `{}` | per collection id, an Astro layout for editing items on their page (see above) |
298
363
  | `sections` | required | module exporting `{ schemas, presets }` |
299
364
  | `pagesDir` | `src/content/pages` | |
300
365
  | `imagesDir` / `uploadsDir` / `publicDir` | `public/images` / `public/images/uploads` / `public` | |
301
366
  | `usersFile` | `editor-users.json` | |
302
367
  | `auth` | `passkey` | `passkey` \| `none-behind-proxy` \| `none` |
303
368
  | `storage` | `local` in dev, `github` in build | |
304
- | `github` | — | `{ repo, branch, pullRequest }` |
305
- | `enabled` | dev, or `EDITOR=1` | |
369
+ | `github` | — | `{ repo, branch, live?, stagingUrl?, pullRequest? }`: see Staging and Go live |
370
+ | `previewScripts` | `'site'` | block-editor preview runs the site's own scripts only; `'all'` allows other origins too |
371
+ | `enabled` | `EDITOR=dev` (dev) or `EDITOR=1` | Off otherwise, so plain `astro dev` never writes content |
306
372
  | `siteName`, `secretEnv` | `Site editor`, `EDITOR_SECRET` | |
307
373
  | `reservedSlugs` | `[]` | URLs Add page must refuse, on top of the editor's own and `src/pages` |
308
374
  | `redirectsFile` | `public/_redirects` | Change URL appends here, only if the file exists |
package/index.mjs CHANGED
@@ -4,8 +4,8 @@
4
4
  // integrations: [sectionEditor({ renderer: './src/components/SectionPage.astro', sections: './src/sections/index.ts' })]
5
5
  //
6
6
  // The public site stays fully static. The editor (/edit/*, /api/editor/*) is on-demand rendered
7
- // and only exists when the integration is enabled: always in `astro dev`, and in `astro build`
8
- // when EDITOR=1 (which produces a Node server build with @astrojs/node).
7
+ // and only exists when the integration is enabled: `EDITOR=dev astro dev` (or EDITOR=1) locally, and
8
+ // `EDITOR=1 astro build` for a server build. Plain `astro dev` / `astro build` leave it out.
9
9
  import node from '@astrojs/node';
10
10
  import { fileURLToPath } from 'node:url';
11
11
  import fs from 'node:fs';
@@ -13,6 +13,7 @@ import path from 'node:path';
13
13
 
14
14
  const VIRTUAL = 'virtual:pagestack/site';
15
15
  const VIRTUAL_RENDERER = 'virtual:pagestack/renderer';
16
+ const VIRTUAL_PREVIEWS = 'virtual:pagestack/previews';
16
17
  const here = path.dirname(fileURLToPath(import.meta.url));
17
18
  const route = (file) => new URL(`./src/routes/${file}`, import.meta.url);
18
19
 
@@ -20,6 +21,9 @@ const route = (file) => new URL(`./src/routes/${file}`, import.meta.url);
20
21
  * @typedef {object} SectionEditorOptions
21
22
  * @property {string} [renderer] Astro component rendering a page: props { page, editing }. Required unless `pages: false`.
22
23
  * @property {boolean} [pages] false for a site with no block pages: only collections, globals and media.
24
+ * @property {Record<string, string>} [previews] Per collection id, an Astro component that lays out one item
25
+ * the way the site does: props { item: { id, collection, data, body, html, headings }, editing }.
26
+ * With one, the item opens on its page and its text is edited in place.
23
27
  * @property {string} sections Module exporting { schemas, presets } (see runtime.ts types).
24
28
  * @property {string} [pagesDir='src/content/pages'] Directory of <slug>.json pages.
25
29
  * @property {string} [imagesDir='public/images'] Browsable image library root.
@@ -28,8 +32,12 @@ const route = (file) => new URL(`./src/routes/${file}`, import.meta.url);
28
32
  * @property {string} [usersFile='editor-users.json'] Passkey users (public keys only).
29
33
  * @property {'none'|'passkey'|'none-behind-proxy'} [auth='passkey']
30
34
  * @property {'local'|'github'} [storage] Defaults: local in dev, github in a build.
31
- * @property {{repo: string, branch?: string, pullRequest?: boolean}} [github]
32
- * @property {boolean} [enabled] Default: dev, or EDITOR=1.
35
+ * @property {{repo: string, branch?: string, pullRequest?: boolean, live?: string, stagingUrl?: string}} [github]
36
+ * `branch` is where saves go. With `live` (the branch the public site builds from), saves stay on
37
+ * `branch` as staging and a Go live button puts them on `live` in one step; `stagingUrl` links to
38
+ * a preview of the staging branch. `pullRequest` opens a PR per save instead.
39
+ * @property {'site'|'all'} [previewScripts='site'] Scripts in the block editor's preview: 'site' runs the site's own and blocks other origins (analytics, captchas, widgets); 'all' allows everything.
40
+ * @property {boolean} [enabled] Default: EDITOR=dev or EDITOR=1 (exact values: $EDITOR is also the shell's text editor). Off otherwise, in dev too.
33
41
  * @property {string} [siteName] Shown in the editor chrome.
34
42
  * @property {string} [interactiveSelector='summary'] Elements in the preview that keep their own click
35
43
  * behaviour (accordion summaries, tab titles, load-map buttons…). Everything else is
@@ -49,6 +57,14 @@ const route = (file) => new URL(`./src/routes/${file}`, import.meta.url);
49
57
  */
50
58
 
51
59
  /** Top-level URLs taken by the host's own route files (dynamic ones can't be known here). */
60
+ /** URL prefix of the uploads folder ('/images/uploads'), or null when uploads aren't public files or would be a site-wide catch-all. */
61
+ export function uploadsUrlPrefix(uploadsDir, publicDir) {
62
+ const up = uploadsDir.replace(/\\/g, '/').replace(/\/+$/, ''), pub = publicDir.replace(/\\/g, '/').replace(/\/+$/, '');
63
+ if (!up.startsWith(pub + '/')) return null;
64
+ const rest = up.slice(pub.length + 1);
65
+ return rest && !rest.split('/').some((s) => s === '..' || s === '.' || /[[\]]/.test(s)) ? '/' + rest : null;
66
+ }
67
+
52
68
  function staticRoutes(srcDir) {
53
69
  try {
54
70
  return fs.readdirSync(path.join(srcDir, 'pages'), { withFileTypes: true })
@@ -73,8 +89,9 @@ export default function sectionEditor(userOptions) {
73
89
  ...forwarded,
74
90
  'astro:config:setup': async (params) => {
75
91
  const { config, command, injectRoute, updateConfig, addMiddleware, logger } = params;
76
- const enabled = userOptions.enabled ?? (command === 'dev' || process.env.EDITOR === '1');
77
- if (!enabled) { logger.info('disabled (static build). Set EDITOR=1 to build the editor.'); return; }
92
+ const flag = process.env.EDITOR;
93
+ const enabled = userOptions.enabled ?? (flag === '1' || (command === 'dev' && flag === 'dev'));
94
+ if (!enabled) { logger.info(command === 'dev' ? 'off. Run with EDITOR=dev to edit at /edit.' : 'off (static build). Set EDITOR=1 to build the editor.'); return; }
78
95
  const isBuild = command === 'build';
79
96
  const options = {
80
97
  pagesDir: 'src/content/pages',
@@ -98,20 +115,31 @@ export default function sectionEditor(userOptions) {
98
115
  if (options.storage === 'github' && !options.github?.repo) {
99
116
  throw new Error('pagestack: storage "github" needs github.repo ("owner/name")');
100
117
  }
118
+ if (options.github?.live && options.github.live === (options.github.branch ?? 'main')) {
119
+ throw new Error('pagestack: github.live must differ from github.branch (saves go to branch, Go live moves them to live)');
120
+ }
121
+ if (options.github?.live && options.github.pullRequest) {
122
+ throw new Error('pagestack: use github.live or github.pullRequest, not both');
123
+ }
101
124
  const root = fileURLToPath(config.root);
102
125
  const abs = (p) => path.isAbsolute(p) ? p : path.resolve(root, p);
103
126
  const reservedSlugs = [...new Set([...(options.reservedSlugs ?? []), ...staticRoutes(fileURLToPath(config.srcDir))])];
104
- const serial = { ...options, reservedSlugs, root, renderer: options.renderer ? abs(options.renderer) : null, sections: abs(options.sections), command };
127
+ const serial = { ...options, reservedSlugs, root, renderer: options.renderer ? abs(options.renderer) : null, previews: Object.fromEntries(Object.entries(options.previews ?? {}).map(([k, v]) => [k, abs(v)])), sections: abs(options.sections), command };
105
128
 
106
129
  updateConfig({
107
130
  vite: {
108
131
  plugins: [{
109
132
  name: 'pagestack:virtual',
110
- resolveId(id) { if (id === VIRTUAL || id === VIRTUAL_RENDERER) return '\0' + id; },
133
+ resolveId(id) { if (id === VIRTUAL || id === VIRTUAL_RENDERER || id === VIRTUAL_PREVIEWS) return '\0' + id; },
111
134
  load(id) {
112
135
  // The renderer (and the site layout/CSS behind it) is only imported by the preview
113
136
  // route, so the editor shell doesn't drag the whole site's CSS into its page.
114
137
  if (id === '\0' + VIRTUAL_RENDERER) return serial.renderer ? `export { default as Renderer } from ${JSON.stringify(serial.renderer)};` : 'export const Renderer = null;';
138
+ // Item layouts, like the renderer, load only on the route that shows them.
139
+ if (id === '\0' + VIRTUAL_PREVIEWS) {
140
+ const entries = Object.entries(serial.previews);
141
+ return [...entries.map(([, file], i) => `import P${i} from ${JSON.stringify(file)};`), `export const previews = { ${entries.map(([k], i) => `${JSON.stringify(k)}: P${i}`).join(', ')} };`].join('\n');
142
+ }
115
143
  if (id !== '\0' + VIRTUAL) return;
116
144
  return [
117
145
  `export * as site from ${JSON.stringify(serial.sections)};`,
@@ -139,6 +167,7 @@ export default function sectionEditor(userOptions) {
139
167
  injectRoute({ pattern: '/edit/login', entrypoint: route('login.astro'), prerender: false });
140
168
  injectRoute({ pattern: '/edit/enroll', entrypoint: route('enroll.astro'), prerender: false });
141
169
  injectRoute({ pattern: '/edit/preview/[...slug]', entrypoint: route('preview.astro'), prerender: false });
170
+ injectRoute({ pattern: '/edit/preview-item/[id]/[...slug]', entrypoint: route('preview-item.astro'), prerender: false });
142
171
  injectRoute({ pattern: '/edit/global/[id]', entrypoint: route('edit-global.astro'), prerender: false });
143
172
  injectRoute({ pattern: '/edit/collection/[id]', entrypoint: route('edit-collection.astro'), prerender: false });
144
173
  injectRoute({ pattern: '/edit/collection/[id]/[...slug]', entrypoint: route('edit-item.astro'), prerender: false });
@@ -152,8 +181,12 @@ export default function sectionEditor(userOptions) {
152
181
  injectRoute({ pattern: '/api/editor/images', entrypoint: route('api/images.ts'), prerender: false });
153
182
  injectRoute({ pattern: '/api/editor/collection/[id]/[...slug]', entrypoint: route('api/collection.ts'), prerender: false });
154
183
  injectRoute({ pattern: '/api/editor/users', entrypoint: route('api/users.ts'), prerender: false });
184
+ injectRoute({ pattern: '/api/editor/live', entrypoint: route('api/live.ts'), prerender: false });
155
185
  injectRoute({ pattern: '/api/editor/asset/[...path]', entrypoint: route('api/asset.ts'), prerender: false });
156
186
  injectRoute({ pattern: '/api/editor/auth/[action]', entrypoint: route('api/auth.ts'), prerender: false });
187
+ // Uploads saved after this editor was built aren't static files in it; serve them from the repo.
188
+ const uploadsUrl = options.storage === 'github' && uploadsUrlPrefix(options.uploadsDir, options.publicDir);
189
+ if (uploadsUrl) injectRoute({ pattern: `${uploadsUrl}/[...path]`, entrypoint: route('uploaded.ts'), prerender: false });
157
190
  logger.info(`enabled — storage: ${options.storage}, auth: ${options.auth}. Open /edit`);
158
191
  },
159
192
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirateandfox/pagestack",
3
- "version": "0.1.0-beta.6",
3
+ "version": "0.1.0-beta.8",
4
4
  "description": "PageStack: visual section editor for Astro sites. Git-only, static public site, passkey login, saves are commits.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,9 +1,9 @@
1
1
  // Browser side of passkey login / enrolment (login.astro, enroll.astro).
2
2
  import { browserSupportsWebAuthn, startAuthentication, startRegistration } from '@simplewebauthn/browser';
3
3
 
4
- const root = document.querySelector<HTMLElement>('[data-ase-auth]')!;
5
- const go = document.getElementById('ase-auth-go') as HTMLButtonElement | null;
6
- const errEl = document.getElementById('ase-auth-error')!;
4
+ const root = document.querySelector<HTMLElement>('[data-ps-auth]')!;
5
+ const go = document.getElementById('ps-auth-go') as HTMLButtonElement | null;
6
+ const errEl = document.getElementById('ps-auth-error')!;
7
7
  const fail = (msg: string) => { errEl.textContent = msg; errEl.hidden = false; if (go) go.disabled = false; };
8
8
  const post = async (action: string, body: unknown) => {
9
9
  const res = await fetch(`/api/editor/auth/${action}`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
@@ -16,7 +16,7 @@ if (!browserSupportsWebAuthn()) fail('This browser does not support passkeys.');
16
16
  else if (go) go.addEventListener('click', async () => {
17
17
  go.disabled = true; errEl.hidden = true;
18
18
  try {
19
- if (root.dataset.aseAuth === 'login') {
19
+ if (root.dataset.psAuth === 'login') {
20
20
  const { options, token } = await post('login-options', {});
21
21
  const response = await startAuthentication({ optionsJSON: options });
22
22
  const { next } = await post('login-verify', { token, response, next: root.dataset.next });
@@ -24,7 +24,7 @@ else if (go) go.addEventListener('click', async () => {
24
24
  } else {
25
25
  const { options, token } = await post('register-options', { invite: root.dataset.invite });
26
26
  const response = await startRegistration({ optionsJSON: options });
27
- const label = (document.getElementById('ase-auth-label') as HTMLInputElement | null)?.value;
27
+ const label = (document.getElementById('ps-auth-label') as HTMLInputElement | null)?.value;
28
28
  await post('register-verify', { token, response, label });
29
29
  location.assign('/edit');
30
30
  }
@@ -2,10 +2,10 @@
2
2
  import { slugify, uniqueSlug } from '../core/pages';
3
3
  import { confirmDialog, promptDialog, toast } from './ui';
4
4
 
5
- const boot = (window as any).__ASE_COLLECTION__ as { id: string; singular: string; slugs: string[]; reserved: string[] };
5
+ const boot = (window as any).__PS_COLLECTION__ as { id: string; singular: string; slugs: string[]; reserved: string[] };
6
6
  const api = `/api/editor/collection/${boot.id}`;
7
7
 
8
- document.getElementById('ase-add-item')?.addEventListener('click', async () => {
8
+ document.getElementById('ps-add-item')?.addEventListener('click', async () => {
9
9
  const title = await promptDialog({ title: `Add ${boot.singular}`, label: 'Title', submit: `Add ${boot.singular}` });
10
10
  if (!title) return;
11
11
  const slug = uniqueSlug(slugify(title) || boot.singular, [...boot.slugs, ...boot.reserved]);
@@ -15,7 +15,7 @@ document.getElementById('ase-add-item')?.addEventListener('click', async () => {
15
15
  location.href = `/edit/collection/${boot.id}/${data.slug}`;
16
16
  });
17
17
 
18
- document.getElementById('ase-pagelist')!.addEventListener('click', async (e) => {
18
+ document.getElementById('ps-pagelist')!.addEventListener('click', async (e) => {
19
19
  const b = (e.target as HTMLElement).closest<HTMLElement>('[data-delete]');
20
20
  if (!b) return;
21
21
  const row = b.closest('li')!;
@@ -28,10 +28,10 @@ document.getElementById('ase-pagelist')!.addEventListener('click', async (e) =>
28
28
  toast(`Deleted ${name}.`, 'ok');
29
29
  });
30
30
 
31
- const search = document.getElementById('ase-page-search') as HTMLInputElement;
31
+ const search = document.getElementById('ps-page-search') as HTMLInputElement;
32
32
  search.addEventListener('input', () => {
33
33
  const q = search.value.trim().toLowerCase();
34
34
  let shown = 0;
35
- document.querySelectorAll<HTMLElement>('#ase-pagelist > li').forEach((li) => { const on = li.dataset.search!.includes(q); li.hidden = !on; if (on) shown++; });
36
- document.getElementById('ase-no-match')!.hidden = shown > 0;
35
+ document.querySelectorAll<HTMLElement>('#ps-pagelist > li').forEach((li) => { const on = li.dataset.search!.includes(q); li.hidden = !on; if (on) shown++; });
36
+ document.getElementById('ps-no-match')!.hidden = shown > 0;
37
37
  });