bearminion 1.21.0 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # bearminion
2
2
 
3
+ ## 1.22.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6656dcd: The editor is now a shell around the page: a navigation on the left (Pages, every content type, Media, Navigation, Footer, Site, Design, SEO) that collapses to an icon rail with Ctrl/Cmd+\, a top bar with the breadcrumb, undo and redo, version history, the unsaved changes, Preview and Save, and a resizable inspector on the right with the Page and Section tabs. The page itself is still where you edit.
8
+
9
+ - Content listings: every page and every entry of a content type in a table with search, Published, Draft and Unsaved tabs, sorting, bulk delete, duplicate, view and ten rows a page. `GET /pages` and the entries of a type also return `draft`, `noindex` and `updatedAt`.
10
+ - Media: the image library with where each image is used, upload and delete. `GET /images?usage=1` returns the uses.
11
+ - Navigation, Footer, Site, Design and SEO are full screens with a card per group. Search defaults moved from Site to SEO.
12
+ - SEO: the site's structured data is edited inline, one card per JSON-LD block, instead of in a dialog. New Indexing switches turn search engines (`site.seo.robots`) and `sitemap.xml` (`site.seo.sitemap`) off for the whole site. A site created earlier needs three small edits to its own `Seo.astro`, `robots.txt.ts` and `astro.config.ts` for them to take effect: see the editor docs.
13
+ - Pages have a status: a draft (`"status": "draft"`) is left out of the build, the listings and the sitemap, and still shows in `astro dev`. Files without a status stay published, and no file of your site needs to change for this.
14
+ - Tablet and mobile frames show the unsaved draft at 820px and 390px.
15
+ - The dock and the Save menu are gone: undo, redo, history, discard and commit live in the top bar.
16
+
17
+ ### Patch Changes
18
+
19
+ - 8fa088c: Shorter npm description for `bearminion`, and `create-bearminion` no longer carries the `withastro` keyword, so the Astro integrations library lists BearMinion once.
20
+
3
21
  ## 1.21.0
4
22
 
5
23
  ### Minor Changes
package/README.md CHANGED
@@ -28,7 +28,7 @@ npm run dev
28
28
  It asks for the site's name and web address. Open the address `npm run dev` prints, press **Ctrl+E** (**Cmd+E** on a Mac), click any text to change it, and press **Ctrl/Cmd+S** to save. Push the folder to GitHub and import it in Vercel, Netlify or Cloudflare Pages to put it online.
29
29
 
30
30
  <p align="center">
31
- <img src="https://raw.githubusercontent.com/langehelp-software/bearminion/main/.github/assets/editor.png" alt="The BearMinion editor: a section toolbar on the hero, a heading being edited, and the Pages tab in the sidebar" width="100%" />
31
+ <img src="https://raw.githubusercontent.com/langehelp-software/bearminion/main/.github/assets/editor.png" alt="The BearMinion editor: the navigation, the page with a section toolbar on the hero, and the inspector" width="100%" />
32
32
  </p>
33
33
 
34
34
  ## What you can change
@@ -44,7 +44,7 @@ Content is plain JSON in your project, validated on every save and kept in your
44
44
  **Editing online is opt-in.** `npx bearminion add hosted` sets up a second deployment where people sign in with GitHub and edit in the browser. Whoever may push to the repository may edit, and every save is a commit under their name. See [Edit online](https://docs.bearminion.com/hosted-editor/).
45
45
 
46
46
  <p align="center">
47
- <img src="https://raw.githubusercontent.com/langehelp-software/bearminion/main/.github/assets/design.png" alt="The Design tab: color mode, brand, neutral and link colors, and a preview of every section tone in light and dark mode" width="100%" />
47
+ <img src="https://raw.githubusercontent.com/langehelp-software/bearminion/main/.github/assets/design.png" alt="The Design screen: color mode, brand, neutral and link colors, and a preview of every section tone in light and dark mode" width="100%" />
48
48
  </p>
49
49
 
50
50
  ## Learn more
package/dist/astro.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { C as ContentStore, T as UploadStore, n as ImageConvertOptions, t as EditorContext, w as StoreOperation, x as CollectionOptions } from "./editor-context-BwQzdSow.js";
2
- import { i as StoreKeyError, n as githubStore, r as StoreError, t as GithubStoreOptions } from "./github-store-BVQY4d-Q.js";
3
- import { C as ContentType, D as ListingDocument, Nt as SiteDefinition, Pt as SiteOf, T as Entry, U as SectionOf, d as SectionRegistry, n as PageRules, t as Page, u as ContentModel, v as ContentMigrator } from "./page-aWKWqoh4.js";
1
+ import { E as UploadStore, S as CollectionOptions, T as StoreOperation, n as ImageConvertOptions, t as EditorContext, w as ContentStore } from "./editor-context-D1yfPp21.js";
2
+ import { i as StoreKeyError, n as githubStore, r as StoreError, t as GithubStoreOptions } from "./github-store-CuhvbFCh.js";
3
+ import { D as Entry, Ft as SiteDefinition, G as SectionOf, It as SiteOf, T as ContentType, b as ContentMigrator, f as ContentModel, k as ListingDocument, n as PageRules, p as SectionRegistry, t as Page } from "./page-CpVElMPH.js";
4
4
  import { AstroIntegration } from "astro";
5
5
  //#region src/store.d.ts
6
6
  interface FileStoreOptions {
package/dist/astro.js CHANGED
@@ -1,13 +1,13 @@
1
- import { A as ContentValidationError, C as loadThemePreview, c as siteRoutes, g as resolveCollections, k as ContentReadError, s as normalizePath, x as PreviewUnavailableError } from "./routing-BWuJlNud.js";
2
- import { t as defaultTheme } from "./theme-DVMi1524.js";
3
- import { i as createTolerantPageSchema, o as resolvePageRules, r as createPageSchema } from "./page-CcC5RRMj.js";
4
- import { D as StoreKeyError, E as StoreError, i as LISTING_MIGRATION_TYPE, l as createEntrySchema, r as LISTING_FILE, u as createListingSchema, w as parseKey, y as resolveTypes } from "./content-types-POybRzMX.js";
1
+ import { A as ContentValidationError, C as loadThemePreview, c as siteRoutes, g as resolveCollections, k as ContentReadError, s as normalizePath, x as PreviewUnavailableError } from "./routing-jKeq4LwO.js";
2
+ import { t as defaultTheme } from "./theme-DTVVNMlr.js";
3
+ import { i as createTolerantPageSchema, r as createPageSchema, s as resolvePageRules } from "./page-C7zE_HD1.js";
4
+ import { D as StoreKeyError, E as StoreError, i as LISTING_MIGRATION_TYPE, l as createEntrySchema, r as LISTING_FILE, u as createListingSchema, w as parseKey, y as resolveTypes } from "./content-types-46XqPaW4.js";
5
5
  import { a as DEFAULT_UPLOADS_DIR, i as DEFAULT_CONTENT_DIR, n as createMigrator, o as DEFAULT_VIDEOS_DIR, t as SCHEMA_VERSION_KEY } from "./migrate-Cm30puW8.js";
6
6
  import { i as resolveMaxImageBytes, n as formatBytes, r as resolveConvert } from "./upload-rules-Cao9uY5K.js";
7
- import { n as isLocalRequest, t as JSON_BODY_LIMIT } from "./request-guards-6WtQV3-a.js";
7
+ import { n as isLocalRequest, t as JSON_BODY_LIMIT } from "./request-guards-DtNVdqQ7.js";
8
8
  import { i as resolveInside, n as isInside, r as resolveDir, t as asDirectory } from "./security-CBiOYdVE.js";
9
9
  import { a as resolveFormsConfig, n as formFile, r as formsAreLive, t as createFormsMiddleware } from "./forms-dev-CzUHR7oS.js";
10
- import { a as isHistoryId, c as imageBodyLimit, d as stableStringify, i as historyId, l as IMAGE_EXTENSION, n as missingImageSvg, o as COMMIT_MESSAGE_LIMIT, p as videoBodyLimit, r as handleEditorRequest, s as GitError, t as githubStore, u as uploadStem } from "./github-store-4-Y4ERBF.js";
10
+ import { a as isHistoryId, c as imageBodyLimit, d as stableStringify, i as historyId, l as IMAGE_EXTENSION, n as missingImageSvg, o as COMMIT_MESSAGE_LIMIT, p as videoBodyLimit, r as handleEditorRequest, s as GitError, t as githubStore, u as uploadStem } from "./github-store-B2folBeq.js";
11
11
  import { S as isAssetPath } from "./draft-store-DBEfw_Gq.js";
12
12
  import { n as contentReloadPlugin, r as dropEarlyReloadAfterSave } from "./reload-BzVw721A.js";
13
13
  import { i as syncSections, r as staleSectionsMessage } from "./sections-manifest-CO9QfJPG.js";
@@ -246,6 +246,14 @@ function createFileStore({ root, contentDir, uploadsDir, videosDir }) {
246
246
  const filePath = resolve(key);
247
247
  return access(filePath).then(() => true, () => false);
248
248
  },
249
+ async modified(key) {
250
+ try {
251
+ return (await stat(resolve(key))).mtimeMs;
252
+ } catch (error) {
253
+ if (isErrno$1(error) && (error.code === "ENOENT" || error.code === "ENOTDIR")) return void 0;
254
+ throw error;
255
+ }
256
+ },
249
257
  async list(dir) {
250
258
  const directory = resolve(dir);
251
259
  let entries;
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { k as imageSchema } from "./page-CcC5RRMj.js";
3
- import { _ as multi, b as single, d as defineTypes } from "./content-types-POybRzMX.js";
2
+ import { A as imageSchema } from "./page-C7zE_HD1.js";
3
+ import { _ as multi, b as single, d as defineTypes } from "./content-types-46XqPaW4.js";
4
4
  import { i as readDotEnv } from "./forms-dev-CzUHR7oS.js";
5
5
  import { i as syncSections, r as staleSectionsMessage, t as SectionsError } from "./sections-manifest-CO9QfJPG.js";
6
6
  import { i as writeLock, n as readLock, r as recordFiles, t as hashContent } from "./hash-BeBymBO1.js";
@@ -1,4 +1,4 @@
1
- import { N as textSchema, c as slugSchema, d as createSectionSchema, f as createTolerantSectionSchema, i as createTolerantPageSchema, n as addSectionIdentityIssues, r as createPageSchema, s as seoSchema } from "./page-CcC5RRMj.js";
1
+ import { P as textSchema, c as seoSchema, f as createSectionSchema, i as createTolerantPageSchema, l as slugSchema, n as addSectionIdentityIssues, o as pageStatusSchema, p as createTolerantSectionSchema, r as createPageSchema } from "./page-C7zE_HD1.js";
2
2
  import { z } from "zod";
3
3
  //#region src/store-error.ts
4
4
  /** A key that is empty, has an empty or dot segment, or leaves its base directory. */
@@ -436,6 +436,7 @@ function createEntrySchema(registry, type, options = {}) {
436
436
  const schema = z.object({
437
437
  slug: slugSchema,
438
438
  title: textSchema,
439
+ status: pageStatusSchema.optional(),
439
440
  seo: seoSchema,
440
441
  sections: sectionList(registry, type, tolerant),
441
442
  ...type.fields ? { fields: type.fields } : {}
package/dist/content.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { E as LISTINGS_COLLECTION, a as createPageSchema, j as SINGLES_COLLECTION, u as ContentModel } from "./page-aWKWqoh4.js";
1
+ import { N as SINGLES_COLLECTION, O as LISTINGS_COLLECTION, f as ContentModel, o as createPageSchema } from "./page-CpVElMPH.js";
2
2
  import { z } from "zod";
3
3
  import { glob } from "astro/loaders";
4
4
  //#region src/content.d.ts
package/dist/content.js CHANGED
@@ -1,5 +1,5 @@
1
- import { i as createTolerantPageSchema, r as createPageSchema } from "./page-CcC5RRMj.js";
2
- import { c as SINGLES_DIR, i as LISTING_MIGRATION_TYPE, l as createEntrySchema, n as LISTINGS_COLLECTION, r as LISTING_FILE, s as SINGLES_COLLECTION, u as createListingSchema, y as resolveTypes } from "./content-types-POybRzMX.js";
1
+ import { i as createTolerantPageSchema, r as createPageSchema } from "./page-C7zE_HD1.js";
2
+ import { c as SINGLES_DIR, i as LISTING_MIGRATION_TYPE, l as createEntrySchema, n as LISTINGS_COLLECTION, r as LISTING_FILE, s as SINGLES_COLLECTION, u as createListingSchema, y as resolveTypes } from "./content-types-46XqPaW4.js";
3
3
  import { n as createMigrator } from "./migrate-Cm30puW8.js";
4
4
  import { t as CONTENT_COLLECTIONS_MARKER } from "./reload-BzVw721A.js";
5
5
  import { z } from "zod";
@@ -1,4 +1,4 @@
1
- import { A as ResolvedTypes, Nt as SiteDefinition, d as SectionRegistry, n as PageRules, p as ThemeDefinition, v as ContentMigrator } from "./page-aWKWqoh4.js";
1
+ import { Ft as SiteDefinition, M as ResolvedTypes, b as ContentMigrator, h as ThemeDefinition, n as PageRules, p as SectionRegistry } from "./page-CpVElMPH.js";
2
2
  import { ZodType, z } from "zod";
3
3
  //#region src/upload-names.d.ts
4
4
  type ImageKind = 'png' | 'jpeg' | 'webp' | 'gif' | 'avif';
@@ -46,6 +46,11 @@ interface ContentStore {
46
46
  /** The text at `key`, or `undefined` when there is none. */
47
47
  read(key: string): Promise<string | undefined>;
48
48
  exists(key: string): Promise<boolean>;
49
+ /**
50
+ * When the file at `key` last changed, in milliseconds since the epoch, or `undefined` when there is no such file or
51
+ * the store cannot tell. Optional: the editor's listings show no time without it.
52
+ */
53
+ modified?(key: string): Promise<number | undefined>;
49
54
  /** Names of the files directly inside the directory `dir`, sorted, or `undefined` when it does not exist. */
50
55
  list(dir: string): Promise<string[] | undefined>;
51
56
  /**
@@ -191,7 +196,16 @@ interface ApiIssue {
191
196
  file?: 'page' | 'site';
192
197
  }
193
198
  /** `GET /pages`. */
194
- interface PageListItem {
199
+ /** What the editor's listings show beside a document's title. All optional: older servers leave them out. */
200
+ interface ListMeta {
201
+ /** True when the document is a draft: left out of the build, the listings and the sitemap. */
202
+ draft?: boolean;
203
+ /** True when the document is marked `noindex`. */
204
+ noindex?: boolean;
205
+ /** When the file last changed (ISO 8601), when the content store can tell. */
206
+ updatedAt?: string;
207
+ }
208
+ interface PageListItem extends ListMeta {
195
209
  slug: string;
196
210
  title: string;
197
211
  /** File name inside the pages directory. */
@@ -250,7 +264,7 @@ interface CreateEntryRequest {
250
264
  fields?: Record<string, unknown>;
251
265
  }
252
266
  /** `GET /types/:id/entries`. */
253
- interface EntryListItem {
267
+ interface EntryListItem extends ListMeta {
254
268
  slug: string;
255
269
  title: string;
256
270
  file: string;
@@ -266,6 +280,8 @@ interface UploadedImage {
266
280
  /** Project-relative path, the value image fields store. */
267
281
  path: string;
268
282
  bytes?: number;
283
+ /** With `GET /images?usage=1`: where the saved content uses the image ("Home page › Hero"). */
284
+ usages?: string[];
269
285
  }
270
286
  /** `GET /videos` entries and the body of a successful `POST /videos`. */
271
287
  interface UploadedVideo {
@@ -304,6 +320,8 @@ interface CreatePageRequest {
304
320
  slug: string;
305
321
  title: string;
306
322
  template?: string;
323
+ /** `draft` starts the document as a draft. Absent: published. */
324
+ status?: 'published' | 'draft';
307
325
  }
308
326
  /** `POST /git/commit`. */
309
327
  interface CommitRequest {
@@ -392,4 +410,4 @@ interface EditorContext {
392
410
  formFile?: (name: string) => string | null;
393
411
  }
394
412
  //#endregion
395
- export { ContentStore as C, collection as S, UploadStore as T, UploadedImage as _, CommitRequest as a, GitInfo as b, CreateEntryRequest as c, EntryListItem as d, HistoryEntry as f, SitePreview as g, SaveResponse as h, ApiProblem as i, CreatePageRequest as l, SaveRequest as m, ImageConvertOptions as n, CommitResult as o, PageListItem as p, ApiIssue as r, ContentTypeInfo as s, EditorContext as t, DocumentAt as u, UploadedVideo as v, StoreOperation as w, CollectionOptions as x, ChangedFile as y };
413
+ export { collection as C, UploadStore as E, CollectionOptions as S, StoreOperation as T, SitePreview as _, CommitRequest as a, ChangedFile as b, CreateEntryRequest as c, EntryListItem as d, HistoryEntry as f, SaveResponse as g, SaveRequest as h, ApiProblem as i, CreatePageRequest as l, PageListItem as m, ImageConvertOptions as n, CommitResult as o, ListMeta as p, ApiIssue as r, ContentTypeInfo as s, EditorContext as t, DocumentAt as u, UploadedImage as v, ContentStore as w, GitInfo as x, UploadedVideo as y };
@@ -1,9 +1,9 @@
1
- import { A as ContentValidationError, E as imageFields, _ as updateEntry, b as validateSite, d as deleteEntry, f as fieldDefinitions, h as renameEntry, k as ContentReadError, m as readEntry, o as matchPath, p as listEntries, u as createEntry, v as fieldIssues, x as PreviewUnavailableError, y as validateEditorPage } from "./routing-BWuJlNud.js";
2
- import { a as isSystemPage, l as withoutOrphanSections, p as isOrphanSection } from "./page-CcC5RRMj.js";
3
- import { D as StoreKeyError, E as StoreError, S as SITE_KEY, a as PAGES_TYPE, f as entryKey, g as listingPath, i as LISTING_MIGRATION_TYPE, l as createEntrySchema, m as listingKey, p as entryPath, u as createListingSchema, v as reservedSlugs, w as parseKey, x as sortEntries, y as resolveTypes } from "./content-types-POybRzMX.js";
1
+ import { A as ContentValidationError, E as imageFields, _ as updateEntry, b as validateSite, d as deleteEntry, f as fieldDefinitions, h as renameEntry, k as ContentReadError, m as readEntry, o as matchPath, p as listEntries, r as isDraft, u as createEntry, v as fieldIssues, x as PreviewUnavailableError, y as validateEditorPage } from "./routing-jKeq4LwO.js";
2
+ import { a as isSystemPage, m as isOrphanSection, u as withoutOrphanSections } from "./page-C7zE_HD1.js";
3
+ import { D as StoreKeyError, E as StoreError, S as SITE_KEY, a as PAGES_TYPE, f as entryKey, g as listingPath, i as LISTING_MIGRATION_TYPE, l as createEntrySchema, m as listingKey, p as entryPath, u as createListingSchema, v as reservedSlugs, w as parseKey, x as sortEntries, y as resolveTypes } from "./content-types-46XqPaW4.js";
4
4
  import { r as API_PREFIX, t as SCHEMA_VERSION_KEY } from "./migrate-Cm30puW8.js";
5
5
  import { n as formatBytes, t as DEFAULT_IMAGE_BYTE_LIMIT } from "./upload-rules-Cao9uY5K.js";
6
- import { i as readSlug, n as isLocalRequest, r as isSameOriginRequest } from "./request-guards-6WtQV3-a.js";
6
+ import { i as readSlug, n as isLocalRequest, r as isSameOriginRequest } from "./request-guards-DtNVdqQ7.js";
7
7
  import { C as missingAssetIssues, S as isAssetPath, b as describeSiteRef, c as projectId, v as assetRefs, y as describePageRef } from "./draft-store-DBEfw_Gq.js";
8
8
  import { z } from "zod";
9
9
  //#region src/video-sniff.ts
@@ -285,7 +285,7 @@ async function route(request, context, meta) {
285
285
  return methodNotAllowed(["POST"]);
286
286
  }
287
287
  if (parts.length === 1 && parts[0] === "images") {
288
- if (method === "GET") return getImages(scoped(context, "uploads"));
288
+ if (method === "GET") return getImages(scoped(context, "uploads"), new URL(request.url).searchParams.get("usage") === "1");
289
289
  if (method === "POST") return postImage(request, scoped(context, "uploads"));
290
290
  return methodNotAllowed(["GET", "POST"]);
291
291
  }
@@ -723,16 +723,26 @@ async function getHistory(context, scope, slug, id) {
723
723
  return json(200, snapshot);
724
724
  }
725
725
  const sectionAnchors = (sections) => sections.flatMap((section) => typeof section === "object" && section !== null && "anchor" in section && typeof section.anchor === "string" && section.anchor !== "" ? [section.anchor] : []);
726
+ /** Draft, noindex and the time of the last change: what the listings show beside each document. */
727
+ async function listMeta(context, stored) {
728
+ const time = await context.store.modified?.(stored.key).catch(() => void 0);
729
+ return {
730
+ ...isDraft(stored.page) ? { draft: true } : {},
731
+ ...stored.page.seo.noindex === true ? { noindex: true } : {},
732
+ ...time === void 0 ? {} : { updatedAt: new Date(time).toISOString() }
733
+ };
734
+ }
726
735
  async function getPages(context) {
727
736
  const loaded = await loadStoredPages(context);
728
737
  if (loaded.response) return loaded.response;
729
- return json(200, { pages: loaded.pages.map((entry) => ({
738
+ return json(200, { pages: await Promise.all(loaded.pages.map(async (entry) => ({
730
739
  slug: entry.page.slug,
731
740
  title: entry.page.title,
732
741
  file: entry.fileName,
733
742
  system: isSystemPage(entry.page.slug),
734
- anchors: sectionAnchors(entry.page.sections)
735
- })) });
743
+ anchors: sectionAnchors(entry.page.sections),
744
+ ...await listMeta(context, entry)
745
+ }))) });
736
746
  }
737
747
  /** The language strings are ordered in: the site's own (`site.json` `lang`), so a listing reads right to its visitors. */
738
748
  async function siteLang(context) {
@@ -749,6 +759,7 @@ async function getEntries(context, type) {
749
759
  if (loaded.response) return loaded.response;
750
760
  const own = loaded.pages.filter((entry) => documentType(context, type, entry.page.slug) === type);
751
761
  const files = new Map(own.map((entry) => [entry.page.slug, entry.fileName]));
762
+ const metas = new Map(await Promise.all(own.map(async (entry) => [entry.page.slug, await listMeta(context, entry)])));
752
763
  const sorted = sortEntries(type, own.map((entry) => entry.page), await siteLang(context));
753
764
  const by = type.sort && type.sort.by !== "title" ? type.sort.by : null;
754
765
  return json(200, { entries: sorted.map((entry) => ({
@@ -757,7 +768,8 @@ async function getEntries(context, type) {
757
768
  file: files.get(entry.slug),
758
769
  path: entryPath(type, entry.slug),
759
770
  ...by === null ? {} : { sortValue: entry.fields?.[by] },
760
- anchors: sectionAnchors(entry.sections)
771
+ anchors: sectionAnchors(entry.sections),
772
+ ...metas.get(entry.slug)
761
773
  })) });
762
774
  }
763
775
  async function getPage(context, slug, type) {
@@ -1159,13 +1171,23 @@ async function postSitePreview(request, context, meta) {
1159
1171
  return problem(500, "preview_failed", message);
1160
1172
  }
1161
1173
  }
1162
- async function getImages(context) {
1174
+ /** The uploaded images and the upload rules. With `?usage=1`, each image also says where the saved content uses it. */
1175
+ async function getImages(context, withUsage = false) {
1163
1176
  const limits = {
1164
1177
  maxBytes: context.maxImageBytes,
1165
1178
  convert: context.imageConvert
1166
1179
  };
1180
+ const images = await context.store.uploads.list();
1181
+ if (!withUsage) return json(200, {
1182
+ images,
1183
+ limits
1184
+ });
1185
+ const usages = await allImageUsages(context);
1167
1186
  return json(200, {
1168
- images: await context.store.uploads.list(),
1187
+ images: images.map((image) => ({
1188
+ ...image,
1189
+ usages: usages.get(image.path) ?? []
1190
+ })),
1169
1191
  limits
1170
1192
  });
1171
1193
  }
@@ -1207,14 +1229,19 @@ async function storedDocuments(context) {
1207
1229
  * drafts before it asks to delete, and saving a draft that still points at a deleted image fails validation.
1208
1230
  */
1209
1231
  async function imageUsages(context, src) {
1232
+ return (await allImageUsages(context)).get(src) ?? [];
1233
+ }
1234
+ /** Every image the saved content uses, with where: one pass over the files instead of one per image. */
1235
+ async function allImageUsages(context) {
1210
1236
  const labels = Object.fromEntries(Object.values(context.sections).map((definition) => [definition.type, definition.label]));
1211
- const usages = [];
1237
+ const usages = /* @__PURE__ */ new Map();
1238
+ const add = (src, where) => usages.set(src, [...usages.get(src) ?? [], where]);
1212
1239
  const site = await readStoredJson(context, SITE_KEY, "site");
1213
- for (const ref of assetRefs(site)) if (ref.src === src) usages.push(describeSiteRef(ref));
1240
+ for (const ref of assetRefs(site)) add(ref.src, describeSiteRef(ref));
1214
1241
  for (const { name, document: page } of await storedDocuments(context)) {
1215
1242
  const title = "title" in page && typeof page.title === "string" ? page.title : name;
1216
1243
  const sections = "sections" in page && Array.isArray(page.sections) ? page.sections : [];
1217
- for (const ref of assetRefs(page)) if (ref.src === src) usages.push(describePageRef(ref, {
1244
+ for (const ref of assetRefs(page)) add(ref.src, describePageRef(ref, {
1218
1245
  title,
1219
1246
  sections
1220
1247
  }, labels));
@@ -1350,7 +1377,9 @@ const createPageSchema = z.object({
1350
1377
  title: z.string(),
1351
1378
  template: z.string().min(1).optional(),
1352
1379
  /** The entry's own fields, for a type that declares them. */
1353
- fields: z.record(z.string(), z.unknown()).optional()
1380
+ fields: z.record(z.string(), z.unknown()).optional(),
1381
+ /** `draft` starts the entry as a draft. Absent: published, as before. */
1382
+ status: z.enum(["published", "draft"]).optional()
1354
1383
  }).strict().superRefine((value, ctx) => {
1355
1384
  if (readSlug(value.slug) === null) ctx.addIssue({
1356
1385
  code: "custom",
@@ -1396,6 +1425,7 @@ function draftPage(input, pages, registry, type) {
1396
1425
  noindex: false,
1397
1426
  nofollow: false
1398
1427
  };
1428
+ const status = input.status === "draft" ? { status: "draft" } : {};
1399
1429
  const fields = type.fields || input.fields ? { fields: {
1400
1430
  ...type.fields ? starterFields(type.fields) : {},
1401
1431
  ...input.fields
@@ -1403,6 +1433,7 @@ function draftPage(input, pages, registry, type) {
1403
1433
  const allowed = (name) => type.sections === null || type.sections.includes(name);
1404
1434
  const drafted = (definition) => ({
1405
1435
  ...pageFromSection(slug, input.title, seo, definition),
1436
+ ...status,
1406
1437
  ...fields
1407
1438
  });
1408
1439
  if (input.template === void 0) {
@@ -1420,6 +1451,7 @@ function draftPage(input, pages, registry, type) {
1420
1451
  return { page: {
1421
1452
  slug,
1422
1453
  title: input.title,
1454
+ ...status,
1423
1455
  seo,
1424
1456
  sections: structuredClone(source.page.sections),
1425
1457
  ...input.fields === void 0 && source.page.fields ? { fields: structuredClone(source.page.fields) } : fields
@@ -1,4 +1,4 @@
1
- import { C as ContentStore } from "./editor-context-BwQzdSow.js";
1
+ import { w as ContentStore } from "./editor-context-D1yfPp21.js";
2
2
  //#region src/store-error.d.ts
3
3
  /** A key that is empty, has an empty or dot segment, or leaves its base directory. */
4
4
  declare class StoreKeyError extends Error {
@@ -1,4 +1,4 @@
1
- import { t as createHostedMiddleware } from "./hosted-middleware-D6cd62SL.js";
1
+ import { t as createHostedMiddleware } from "./hosted-middleware-DHLIedeV.js";
2
2
  import { editor, preview, signIn } from "virtual:bearminion/editor";
3
3
  //#region src/hosted-astro.ts
4
4
  let ready;
@@ -1,4 +1,4 @@
1
- import { r as isSameOriginRequest } from "./request-guards-6WtQV3-a.js";
1
+ import { r as isSameOriginRequest } from "./request-guards-DtNVdqQ7.js";
2
2
  //#region src/hosted-auth.ts
3
3
  const AUTH_PREFIX = "/__bearminion/auth";
4
4
  const encoder = new TextEncoder();