bearminion 1.18.0 → 1.20.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/dist/hosted.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { _ as CollectionOptions, n as ImageConvertOptions, t as EditorContext, v as collection, y as ContentStore } from "./editor-context-ESJwMFpS.js";
2
- import { i as StoreKeyError, n as githubStore, r as StoreError, t as GithubStoreOptions } from "./github-store-CDQNvoKQ.js";
3
- import { g as ContentModel, n as PageRules, t as Page } from "./page-D1pdneYm.js";
1
+ import { _ as CollectionOptions, n as ImageConvertOptions, t as EditorContext, v as collection, y as ContentStore } from "./editor-context-DzRwKENi.js";
2
+ import { i as StoreKeyError, n as githubStore, r as StoreError, t as GithubStoreOptions } from "./github-store-DsLCe5MR.js";
3
+ import { g as ContentModel, n as PageRules, t as Page } from "./page-BGSTL63-.js";
4
+ import { r as ThemePreviewSource } from "./preview-DFLna-Be.js";
4
5
  //#region src/api.d.ts
5
6
  interface HandleMeta {
6
7
  /**
@@ -147,12 +148,21 @@ interface HostedEditorConfig extends ContentModel {
147
148
  /** The clock, in milliseconds. For tests. */
148
149
  now?: () => number;
149
150
  }
151
+ interface HostedHandleOptions {
152
+ /**
153
+ * The theme's preview renderer (the default export of `src/lib/render-preview.ts`), or a function that loads it.
154
+ * With it the editor redraws a draft as it changes: a section just added, a layout switched, the header and footer.
155
+ * Without it the preview endpoints answer 501 and such changes show after Save and a reload.
156
+ * `bearminionHostedEditor` passes it by itself.
157
+ */
158
+ preview?: ThemePreviewSource;
159
+ }
150
160
  interface HostedEditor {
151
161
  /**
152
162
  * Answers `/__bearminion/auth/*` (sign-in) and `/__bearminion/api/*` (the editor API, signed-in people only).
153
163
  * Returns `null` for any other path, so the site's own routes carry on.
154
164
  */
155
- handle(request: Request): Promise<Response | null>;
165
+ handle(request: Request, options?: HostedHandleOptions): Promise<Response | null>;
156
166
  /**
157
167
  * Passes a page the site rendered through, adding the editor overlay when the request comes from a signed-in
158
168
  * person. Anyone else gets the page untouched. A page with the overlay is marked `private, no-store`, so no cache
@@ -186,6 +196,8 @@ interface HostedMiddlewareOptions {
186
196
  * live content and the overlay.
187
197
  */
188
198
  signIn?: 'required' | 'optional';
199
+ /** The theme's preview renderer, for the editor's live preview. See `HostedHandleOptions.preview`. */
200
+ preview?: ThemePreviewSource;
189
201
  }
190
202
  interface HostedMiddlewareContext {
191
203
  request: Request;
package/dist/hosted.js CHANGED
@@ -1,11 +1,11 @@
1
- import { D as ContentReadError, O as ContentValidationError, c as resolveCollections, g as pageKey, h as SITE_KEY, t as collection, v as StoreError, y as StoreKeyError } from "./collections-BbL4_4jt.js";
1
+ import { C as previewRenderers, O as ContentReadError, c as resolveCollections, g as pageKey, h as SITE_KEY, k as ContentValidationError, t as collection, v as StoreError, y as StoreKeyError } from "./collections-Bm3RWg2K.js";
2
2
  import { t as defaultTheme } from "./theme-BvqJ8UnS.js";
3
3
  import { a as resolvePageRules, c as withoutOrphanSections, n as createPageSchema, r as createTolerantPageSchema, s as slugSchema } from "./page-wlcQJAA-.js";
4
4
  import { n as createMigrator } from "./migrate-b408EaLp.js";
5
5
  import { i as resolveMaxImageBytes, r as resolveConvert } from "./upload-rules-Cao9uY5K.js";
6
- import { f as DEFAULT_VIDEO_BYTE_LIMIT, n as missingImageSvg, r as handleEditorRequest, t as githubStore } from "./github-store-D3LEUhcM.js";
6
+ import { f as DEFAULT_VIDEO_BYTE_LIMIT, n as missingImageSvg, r as handleEditorRequest, t as githubStore } from "./github-store-Dt_YuOPD.js";
7
7
  import { S as isAssetPath } from "./draft-store-DBEfw_Gq.js";
8
- import { n as AUTH_PREFIX, r as createHostedAuth, t as createHostedMiddleware } from "./hosted-middleware-CedN9WNM.js";
8
+ import { n as AUTH_PREFIX, r as createHostedAuth, t as createHostedMiddleware } from "./hosted-middleware-CsROahka.js";
9
9
  //#region src/hosted-context.ts
10
10
  /** The context for `handleEditorRequest`. */
11
11
  function createHostedContext(options) {
@@ -199,7 +199,16 @@ function createHostedEditor(config) {
199
199
  content: createStoreContent(config, store)
200
200
  };
201
201
  }
202
- async function handle(request) {
202
+ const renderers = /* @__PURE__ */ new WeakMap();
203
+ function renderersFor(source) {
204
+ let found = renderers.get(source);
205
+ if (!found) {
206
+ found = previewRenderers(source);
207
+ renderers.set(source, found);
208
+ }
209
+ return found;
210
+ }
211
+ async function handle(request, options = {}) {
203
212
  const signIn = await auth.handle(request);
204
213
  if (signIn) return signIn;
205
214
  const pathname = new URL(request.url).pathname.replace(/\/+$/, "");
@@ -240,7 +249,7 @@ function createHostedEditor(config) {
240
249
  ...config.migrations ? { migrations: config.migrations } : {},
241
250
  ...config.schemaVersion === void 0 ? {} : { schemaVersion: config.schemaVersion },
242
251
  store: storeFor(found.session.token)
243
- }));
252
+ }), options.preview ? renderersFor(options.preview) : {});
244
253
  if (response && found.cookie) response.headers.append("set-cookie", found.cookie);
245
254
  return response;
246
255
  }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { _ as CollectionOptions, a as CommitRequest, c as HistoryEntry, d as SaveResponse, f as SitePreview, g as GitInfo, h as ChangedFile, i as ApiProblem, l as PageListItem, m as UploadedVideo, o as CommitResult, p as UploadedImage, r as ApiIssue, s as CreatePageRequest, u as SaveRequest, v as collection } from "./editor-context-ESJwMFpS.js";
1
+ import { _ as CollectionOptions, a as CommitRequest, c as HistoryEntry, d as SaveResponse, f as SitePreview, g as GitInfo, h as ChangedFile, i as ApiProblem, l as PageListItem, m as UploadedVideo, o as CommitResult, p as UploadedImage, r as ApiIssue, s as CreatePageRequest, u as SaveRequest, v as collection } from "./editor-context-DzRwKENi.js";
2
2
  import { _ as renderMarkedHtml, a as WeightMark, f as markClass, g as reconcileMarks, i as TextRun, l as fontMarks, m as marksFromEmphasis, o as applyTextMark, r as TextMark, t as FontMark, v as splitMarkedText, y as weightMarks } from "./marks-BzLa48Y9.js";
3
- import { $ as mergeJsonLd, $t as tones, A as SectionDefinition, At as MAX_NAV_DEPTH, B as FieldIcons, Bt as toneSchema, C as ContentMigration, Ct as siteConsentSchema, D as SCHEMA_VERSION_KEY, Dt as ButtonStyle, E as DocumentKind, Et as themeSchema, F as defineWireframe, Ft as imageSchema, G as SiteJsonLdIds, Gt as EnumOption, H as ShowWhen, Ht as withEmphasis, I as wireKinds, It as linkSchema, J as generateSiteJsonLd, Jt as StringOption, K as SiteJsonLdSource, Kt as NumberOption, L as wireframeIssues, Lt as richTextSchema, M as WireKind, Mt as Text, N as WireRect, Nt as Tone, O as createMigrator, Ot as Image, P as Wireframe, Pt as htmlIdSchema, Q as jsonLdWarnings, Qt as toneOption, R as OptionalContent, Rt as textMarkSchema, S as defineTheme, St as siteAnalyticsSchema, T as ContentVersioning, Tt as themeColorsSchema, U as JsonLdBlock, Ut as BooleanOption, V as ShowCondition, Vt as trackingIdSchema, W as JsonLdResult, Wt as CountRule, X as isPlaceholderSiteUrl, Xt as motionOption, Y as hasJsonLdId, Yt as buttonStyles, Z as jsonLdSchema, Zt as themeModes, _ as SectionRegistry, _t as SiteSeo, a as createPageSchema, at as DEFAULT_MAX_HEADER_ACTIONS, b as ThemeFont, bt as brandLogoSchema, c as withoutOrphanSections, ct as FooterConfig, d as SectionOf, dt as Site, en as variantOption, et as parseJsonLdInput, f as anchorSchema, ft as SiteAnalytics, g as ContentModel, gt as SiteOf, h as API_PREFIX, ht as SiteDefinition, i as Seo, it as DEFAULT_MAX_FOOTER_COLUMNS, j as defineSection, jt as RichText, k as SectionConfig, kt as Link, l as BaseSection, lt as Header, m as sectionIdSchema, mt as SiteConsent, nt as upsertJsonLd, o as isSystemPage, ot as Footer, p as createSectionSchema, pt as SiteConfig, q as formatJsonLd, qt as Option, r as SYSTEM_PAGES, rt as BRAND_LOGO_HEIGHT, s as seoSchema, st as FooterColumn, t as Page, tt as siteJsonLdIds, u as PropsOf, ut as HeaderConfig, v as ThemeConfig, vt as SiteWith, w as ContentMigrator, wt as siteSeoSchema, x as defaultTheme, xt as defineSite, y as ThemeDefinition, yt as Theme, z as FieldChoices, zt as textSchema } from "./page-D1pdneYm.js";
3
+ import { $ as mergeJsonLd, $t as tones, A as SectionDefinition, At as MAX_NAV_DEPTH, B as FieldIcons, Bt as toneSchema, C as ContentMigration, Ct as siteConsentSchema, D as SCHEMA_VERSION_KEY, Dt as ButtonStyle, E as DocumentKind, Et as themeSchema, F as defineWireframe, Ft as imageSchema, G as SiteJsonLdIds, Gt as EnumOption, H as ShowWhen, Ht as withEmphasis, I as wireKinds, It as linkSchema, J as generateSiteJsonLd, Jt as StringOption, K as SiteJsonLdSource, Kt as NumberOption, L as wireframeIssues, Lt as richTextSchema, M as WireKind, Mt as Text, N as WireRect, Nt as Tone, O as createMigrator, Ot as Image, P as Wireframe, Pt as htmlIdSchema, Q as jsonLdWarnings, Qt as toneOption, R as OptionalContent, Rt as textMarkSchema, S as defineTheme, St as siteAnalyticsSchema, T as ContentVersioning, Tt as themeColorsSchema, U as JsonLdBlock, Ut as BooleanOption, V as ShowCondition, Vt as trackingIdSchema, W as JsonLdResult, Wt as CountRule, X as isPlaceholderSiteUrl, Xt as motionOption, Y as hasJsonLdId, Yt as buttonStyles, Z as jsonLdSchema, Zt as themeModes, _ as SectionRegistry, _t as SiteSeo, a as createPageSchema, at as DEFAULT_MAX_HEADER_ACTIONS, b as ThemeFont, bt as brandLogoSchema, c as withoutOrphanSections, ct as FooterConfig, d as SectionOf, dt as Site, en as variantOption, et as parseJsonLdInput, f as anchorSchema, ft as SiteAnalytics, g as ContentModel, gt as SiteOf, h as API_PREFIX, ht as SiteDefinition, i as Seo, it as DEFAULT_MAX_FOOTER_COLUMNS, j as defineSection, jt as RichText, k as SectionConfig, kt as Link, l as BaseSection, lt as Header, m as sectionIdSchema, mt as SiteConsent, nt as upsertJsonLd, o as isSystemPage, ot as Footer, p as createSectionSchema, pt as SiteConfig, q as formatJsonLd, qt as Option, r as SYSTEM_PAGES, rt as BRAND_LOGO_HEIGHT, s as seoSchema, st as FooterColumn, t as Page, tt as siteJsonLdIds, u as PropsOf, ut as HeaderConfig, v as ThemeConfig, vt as SiteWith, w as ContentMigrator, wt as siteSeoSchema, x as defaultTheme, xt as defineSite, y as ThemeDefinition, yt as Theme, z as FieldChoices, zt as textSchema } from "./page-BGSTL63-.js";
4
4
  import { a as TURNSTILE_FIELD, i as HONEYPOT_FIELD, n as FormResult, r as FormSubmission, t as FormFieldErrors } from "./form-contract-BURSJP3Y.js";
5
+ import { i as defineThemePreview, n as ThemePreview, t as SitePreviewHtml } from "./preview-DFLna-Be.js";
5
6
  //#region src/errors.d.ts
6
7
  /** One schema problem, addressed by a dot path such as `sections.0.props.heading`. */
7
8
  interface ContentIssue {
@@ -33,44 +34,6 @@ export declare const DEFAULT_IMAGE_POSITION: ImagePosition;
33
34
  export declare function isImageFit(value: unknown): value is ImageFit;
34
35
  export declare function isImagePosition(value: unknown): value is ImagePosition;
35
36
  //#endregion
36
- //#region src/preview.d.ts
37
- /** The header and footer of a draft site, as HTML. */
38
- interface SitePreviewHtml {
39
- header: string;
40
- footer: string;
41
- }
42
- /**
43
- * How a theme renders drafts for the editor's live preview. The editor calls it from the dev server;
44
- * it never reads or writes content files.
45
- */
46
- interface ThemePreview<TModel extends ContentModel = ContentModel> {
47
- /** The draft page's sections as HTML, which replaces `main#content`. Orphaned sections are already left out. */
48
- page(input: {
49
- sections: SectionOf<TModel['sections']>[];
50
- motion: boolean;
51
- }): Promise<string>;
52
- /**
53
- * The draft site's header and footer as HTML, so brand, layout and links update without a reload.
54
- * Optional: without it, header and footer changes appear after you save and reload.
55
- */
56
- site?(input: {
57
- site: SiteOf<TModel['site']>;
58
- pathname: string;
59
- }): Promise<SitePreviewHtml>;
60
- }
61
- /**
62
- * Declare a theme's preview renderer. Default-export it from the module named by `previewModule`
63
- * (default `/src/lib/render-preview.ts`). The model type ties the inputs to your section registry and site:
64
- *
65
- * ```ts
66
- * export default defineThemePreview<typeof contentModel>({
67
- * async page({ sections, motion }) { ... },
68
- * async site({ site, pathname }) { ... },
69
- * })
70
- * ```
71
- */
72
- export declare function defineThemePreview<TModel extends ContentModel = ContentModel>(preview: ThemePreview<TModel>): ThemePreview<TModel>;
73
- //#endregion
74
37
  //#region src/media-source.d.ts
75
38
  /**
76
39
  * What a Media section's video link points at. YouTube and Vimeo links become privacy-friendly embeds
@@ -204,4 +167,4 @@ interface ContrastCheck {
204
167
  /** Text pairs a visitor reads: text on its background, label on the accent fill, link on its background. */
205
168
  export declare function contrastChecks(colors: ThemeColors | undefined): ContrastCheck[];
206
169
  //#endregion
207
- export { API_PREFIX, type ApiIssue, type ApiProblem, BRAND_LOGO_HEIGHT, type BaseSection, type BooleanOption, type ButtonStyle, type ChangedFile, type CollectionOptions, type CommitRequest, type CommitResult, type ConsentCopy, type ConsentReopen, type ConsentText, type ConsentTextKey, type ContentIssue, type ContentMigration, type ContentMigrator, type ContentModel, type ContentVersioning, type ContrastCheck, type CountRule, type CreatePageRequest, DEFAULT_MAX_FOOTER_COLUMNS, DEFAULT_MAX_HEADER_ACTIONS, type DocumentKind, type EnumOption, type FieldChoices, type FieldIcons, type FontMark, type Footer, type FooterColumn, type FooterConfig, type FormFieldErrors, type FormResult, type FormSubmission, type GitInfo, HONEYPOT_FIELD, type Header, type HeaderConfig, type HistoryEntry, type Image, type ImageFit, type ImagePosition, type JsonLdBlock, type JsonLdResult, type Link, MAX_NAV_DEPTH, type MediaSource, type NumberOption, type Option, type OptionalContent, type Page, type PageListItem, type PropsOf, type RichText, SCHEMA_VERSION_KEY, SYSTEM_PAGES, type SaveRequest, type SaveResponse, type SectionConfig, type SectionDefinition, type SectionOf, type SectionRegistry, type Seo, type ShowCondition, type ShowWhen, type Site, type SiteAnalytics, type SiteConfig, type SiteConsent, type SiteDefinition, type SiteJsonLdIds, type SiteJsonLdSource, type SiteOf, type SitePreview, type SitePreviewHtml, type SiteSeo, type SiteWith, type StringOption, TURNSTILE_FIELD, type Text, type TextMark, type TextRun, type Theme, type ThemeColors, type ThemeConfig, type ThemeDefinition, type ThemeFont, type ThemePreview, type Tone, type UploadedImage, type UploadedVideo, type WeightMark, type WireKind, type WireRect, type Wireframe, anchorSchema, applyTextMark, brandLogoSchema, buttonStyles, collection, createMigrator, createPageSchema, createSectionSchema, defaultTheme, defineSection, defineSite, defineTheme, defineWireframe, fontMarks, formatJsonLd, generateSiteJsonLd, hasJsonLdId, htmlIdSchema, imageSchema, isPlaceholderSiteUrl, isSystemPage, jsonLdSchema, jsonLdWarnings, linkSchema, markClass, marksFromEmphasis, mergeJsonLd, motionOption, parseJsonLdInput, reconcileMarks, renderMarkedHtml, richTextSchema, sectionIdSchema, seoSchema, siteAnalyticsSchema, siteConsentSchema, siteJsonLdIds, siteSeoSchema, splitMarkedText, textMarkSchema, textSchema, themeColorsSchema, themeModes, themeSchema, toneOption, toneSchema, tones, trackingIdSchema, upsertJsonLd, variantOption, weightMarks, wireKinds, wireframeIssues, withEmphasis, withoutOrphanSections };
170
+ export { API_PREFIX, type ApiIssue, type ApiProblem, BRAND_LOGO_HEIGHT, type BaseSection, type BooleanOption, type ButtonStyle, type ChangedFile, type CollectionOptions, type CommitRequest, type CommitResult, type ConsentCopy, type ConsentReopen, type ConsentText, type ConsentTextKey, type ContentIssue, type ContentMigration, type ContentMigrator, type ContentModel, type ContentVersioning, type ContrastCheck, type CountRule, type CreatePageRequest, DEFAULT_MAX_FOOTER_COLUMNS, DEFAULT_MAX_HEADER_ACTIONS, type DocumentKind, type EnumOption, type FieldChoices, type FieldIcons, type FontMark, type Footer, type FooterColumn, type FooterConfig, type FormFieldErrors, type FormResult, type FormSubmission, type GitInfo, HONEYPOT_FIELD, type Header, type HeaderConfig, type HistoryEntry, type Image, type ImageFit, type ImagePosition, type JsonLdBlock, type JsonLdResult, type Link, MAX_NAV_DEPTH, type MediaSource, type NumberOption, type Option, type OptionalContent, type Page, type PageListItem, type PropsOf, type RichText, SCHEMA_VERSION_KEY, SYSTEM_PAGES, type SaveRequest, type SaveResponse, type SectionConfig, type SectionDefinition, type SectionOf, type SectionRegistry, type Seo, type ShowCondition, type ShowWhen, type Site, type SiteAnalytics, type SiteConfig, type SiteConsent, type SiteDefinition, type SiteJsonLdIds, type SiteJsonLdSource, type SiteOf, type SitePreview, type SitePreviewHtml, type SiteSeo, type SiteWith, type StringOption, TURNSTILE_FIELD, type Text, type TextMark, type TextRun, type Theme, type ThemeColors, type ThemeConfig, type ThemeDefinition, type ThemeFont, type ThemePreview, type Tone, type UploadedImage, type UploadedVideo, type WeightMark, type WireKind, type WireRect, type Wireframe, anchorSchema, applyTextMark, brandLogoSchema, buttonStyles, collection, createMigrator, createPageSchema, createSectionSchema, defaultTheme, defineSection, defineSite, defineTheme, defineThemePreview, defineWireframe, fontMarks, formatJsonLd, generateSiteJsonLd, hasJsonLdId, htmlIdSchema, imageSchema, isPlaceholderSiteUrl, isSystemPage, jsonLdSchema, jsonLdWarnings, linkSchema, markClass, marksFromEmphasis, mergeJsonLd, motionOption, parseJsonLdInput, reconcileMarks, renderMarkedHtml, richTextSchema, sectionIdSchema, seoSchema, siteAnalyticsSchema, siteConsentSchema, siteJsonLdIds, siteSeoSchema, splitMarkedText, textMarkSchema, textSchema, themeColorsSchema, themeModes, themeSchema, toneOption, toneSchema, tones, trackingIdSchema, upsertJsonLd, variantOption, weightMarks, wireKinds, wireframeIssues, withEmphasis, withoutOrphanSections };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as enumFields, D as ContentReadError, E as ContentError, O as ContentValidationError, T as schemaProps, k as formatContentIssues, t as collection, x as defineThemePreview } from "./collections-BbL4_4jt.js";
1
+ import { A as formatContentIssues, D as ContentError, E as schemaProps, O as ContentReadError, k as ContentValidationError, t as collection, w as enumFields, x as defineThemePreview } from "./collections-Bm3RWg2K.js";
2
2
  import { n as defineTheme, t as defaultTheme } from "./theme-BvqJ8UnS.js";
3
3
  import { A as textMarkSchema, B as isImagePosition, C as upsertJsonLd, D as imageSchema, E as htmlIdSchema, F as DEFAULT_IMAGE_FIT, G as toneOption, H as buttonStyles, I as DEFAULT_IMAGE_POSITION, K as tones, L as IMAGE_FITS, M as toneSchema, N as trackingIdSchema, O as linkSchema, P as withEmphasis, R as IMAGE_POSITIONS, S as siteJsonLdIds, T as addMarkIssues, U as motionOption, W as themeModes, _ as isPlaceholderSiteUrl, b as mergeJsonLd, c as withoutOrphanSections, f as sectionIdSchema, g as hasJsonLdId, h as generateSiteJsonLd, i as isSystemPage, j as textSchema, k as richTextSchema, l as anchorSchema, m as formatJsonLd, n as createPageSchema, o as seoSchema, p as walkLinkIds, q as variantOption, t as SYSTEM_PAGES, u as createSectionSchema, v as jsonLdSchema, w as MAX_NAV_DEPTH, x as parseJsonLdInput, y as jsonLdWarnings, z as isImageFit } from "./page-wlcQJAA-.js";
4
4
  import { d as reconcileMarks, f as renderMarkedHtml, i as fontMarks, l as marksFromEmphasis, m as weightMarks, p as splitMarkedText, s as markClass, t as applyTextMark } from "./marks-DPBilumg.js";
@@ -219,7 +219,7 @@ function createHeaderSchema({ variants, defaultVariant, maxActions }) {
219
219
  actions: actions ?? [signIn, cta].filter((link) => link !== void 0)
220
220
  }));
221
221
  }
222
- function createFooterSchema({ variants, defaultVariant, maxColumns, badge }) {
222
+ function createFooterSchema({ variants, defaultVariant, maxColumns, badge, poweredBy }) {
223
223
  return z.object({
224
224
  variant: z.enum(variants).default(defaultVariant),
225
225
  tone: toneSchema,
@@ -227,6 +227,8 @@ function createFooterSchema({ variants, defaultVariant, maxColumns, badge }) {
227
227
  legal: z.string().optional(),
228
228
  /** Pill on the columns variant. Hidden when omitted. Only themes that enable it accept it. */
229
229
  badge: z.string().min(1).optional(),
230
+ /** The "Powered by BearMinion" link. Only `false` hides it. Only themes that enable it accept it. */
231
+ poweredBy: z.boolean().optional(),
230
232
  columns: z.array(footerColumnSchema).max(maxColumns)
231
233
  }).strict().superRefine((footer, ctx) => {
232
234
  if (!badge && footer.badge !== void 0) ctx.addIssue({
@@ -234,6 +236,11 @@ function createFooterSchema({ variants, defaultVariant, maxColumns, badge }) {
234
236
  message: "This site has no footer badge",
235
237
  path: ["badge"]
236
238
  });
239
+ if (!poweredBy && footer.poweredBy !== void 0) ctx.addIssue({
240
+ code: "custom",
241
+ message: "This site has no \"Powered by BearMinion\" link",
242
+ path: ["poweredBy"]
243
+ });
237
244
  });
238
245
  }
239
246
  /** Defaults used when a page does not set its own SEO fields. */
@@ -345,6 +352,7 @@ function defineSite(config) {
345
352
  const maxActions = header.maxActions ?? 2;
346
353
  const maxColumns = footer.maxColumns ?? 3;
347
354
  const badge = footer.badge === true;
355
+ const poweredBy = footer.poweredBy === true;
348
356
  for (const [name, part] of [["header", header], ["footer", footer]]) if (!part.variants.includes(part.defaultVariant)) throw new Error(`defineSite: ${name}.defaultVariant "${part.defaultVariant}" is not in ${name}.variants.`);
349
357
  if (!Number.isInteger(maxActions) || maxActions < 1) throw new Error("defineSite: header.maxActions must be a positive integer.");
350
358
  if (!Number.isInteger(maxColumns) || maxColumns < 1) throw new Error("defineSite: footer.maxColumns must be a positive integer.");
@@ -357,7 +365,8 @@ function defineSite(config) {
357
365
  variants: footer.variants,
358
366
  defaultVariant: footer.defaultVariant,
359
367
  maxColumns,
360
- badge
368
+ badge,
369
+ poweredBy
361
370
  }),
362
371
  options: [
363
372
  {
@@ -418,6 +427,12 @@ function defineSite(config) {
418
427
  label: "Footer badge",
419
428
  type: "string",
420
429
  default: ""
430
+ }] : [],
431
+ ...poweredBy ? [{
432
+ name: "footer.poweredBy",
433
+ label: "Powered by BearMinion",
434
+ type: "boolean",
435
+ default: true
421
436
  }] : []
422
437
  ],
423
438
  counts: {
@@ -438,7 +453,8 @@ function defineSite(config) {
438
453
  footer: {
439
454
  variants: footer.variants,
440
455
  defaultVariant: footer.defaultVariant,
441
- badge
456
+ badge,
457
+ poweredBy
442
458
  }
443
459
  };
444
460
  }
@@ -394,6 +394,7 @@ interface FooterParts {
394
394
  defaultVariant: string;
395
395
  maxColumns: number;
396
396
  badge: boolean;
397
+ poweredBy: boolean;
397
398
  }
398
399
  /** Defaults used when a page does not set its own SEO fields. */
399
400
  declare const siteSeoSchema: z.ZodObject<{
@@ -665,6 +666,7 @@ declare function createSiteSchema(header: HeaderParts, footer: FooterParts): z.Z
665
666
  text: z.ZodOptional<z.ZodString>;
666
667
  legal: z.ZodOptional<z.ZodString>;
667
668
  badge: z.ZodOptional<z.ZodString>;
669
+ poweredBy: z.ZodOptional<z.ZodBoolean>;
668
670
  columns: z.ZodArray<z.ZodObject<{
669
671
  title: z.ZodString;
670
672
  links: z.ZodArray<z.ZodType<Link, unknown, z.core.$ZodTypeInternals<Link, unknown>>>;
@@ -798,6 +800,7 @@ declare function createSiteSchema(header: HeaderParts, footer: FooterParts): z.Z
798
800
  text?: string | undefined;
799
801
  legal?: string | undefined;
800
802
  badge?: string | undefined;
803
+ poweredBy?: boolean | undefined;
801
804
  };
802
805
  lang?: string | undefined;
803
806
  brandLogo?: {
@@ -934,6 +937,7 @@ declare function createSiteSchema(header: HeaderParts, footer: FooterParts): z.Z
934
937
  text?: string | undefined;
935
938
  legal?: string | undefined;
936
939
  badge?: string | undefined;
940
+ poweredBy?: boolean | undefined;
937
941
  };
938
942
  nameEm?: string | undefined;
939
943
  nameMarks?: {
@@ -1013,6 +1017,8 @@ interface FooterConfig<TVariants extends readonly [string, ...string[]]> {
1013
1017
  maxColumns?: number;
1014
1018
  /** The footer has a pill whose text the editor sets. Default false. */
1015
1019
  badge?: boolean;
1020
+ /** The footer has a "Powered by BearMinion" link that the editor can switch off. Default false. */
1021
+ poweredBy?: boolean;
1016
1022
  }
1017
1023
  interface SiteConfig<THeaderVariants extends readonly [string, ...string[]], TFooterVariants extends readonly [string, ...string[]]> {
1018
1024
  header: HeaderConfig<THeaderVariants>;
@@ -1046,6 +1052,7 @@ interface SiteDefinition<THeader extends string = string, TFooter extends string
1046
1052
  readonly variants: readonly TFooter[];
1047
1053
  readonly defaultVariant: TFooter;
1048
1054
  readonly badge: boolean;
1055
+ readonly poweredBy: boolean;
1049
1056
  };
1050
1057
  }
1051
1058
  /** The site type a definition validates to. */
@@ -0,0 +1,42 @@
1
+ import { d as SectionOf, g as ContentModel, gt as SiteOf } from "./page-BGSTL63-.js";
2
+ //#region src/preview.d.ts
3
+ /** The header and footer of a draft site, as HTML. */
4
+ interface SitePreviewHtml {
5
+ header: string;
6
+ footer: string;
7
+ }
8
+ /**
9
+ * How a theme renders drafts for the editor's live preview. The editor calls it from the dev server;
10
+ * it never reads or writes content files.
11
+ */
12
+ interface ThemePreview<TModel extends ContentModel = ContentModel> {
13
+ /** The draft page's sections as HTML, which replaces `main#content`. Orphaned sections are already left out. */
14
+ page(input: {
15
+ sections: SectionOf<TModel['sections']>[];
16
+ motion: boolean;
17
+ }): Promise<string>;
18
+ /**
19
+ * The draft site's header and footer as HTML, so brand, layout and links update without a reload.
20
+ * Optional: without it, header and footer changes appear after you save and reload.
21
+ */
22
+ site?(input: {
23
+ site: SiteOf<TModel['site']>;
24
+ pathname: string;
25
+ }): Promise<SitePreviewHtml>;
26
+ }
27
+ /**
28
+ * Declare a theme's preview renderer. Default-export it from the module named by `previewModule`
29
+ * (default `/src/lib/render-preview.ts`). The model type ties the inputs to your section registry and site:
30
+ *
31
+ * ```ts
32
+ * export default defineThemePreview<typeof contentModel>({
33
+ * async page({ sections, motion }) { ... },
34
+ * async site({ site, pathname }) { ... },
35
+ * })
36
+ * ```
37
+ */
38
+ declare function defineThemePreview<TModel extends ContentModel = ContentModel>(preview: ThemePreview<TModel>): ThemePreview<TModel>;
39
+ /** A theme's preview, or a function that loads it on first use (so a server only pays for it when someone edits). */
40
+ type ThemePreviewSource = ThemePreview | (() => ThemePreview | Promise<ThemePreview>);
41
+ //#endregion
42
+ export { defineThemePreview as i, ThemePreview as n, ThemePreviewSource as r, SitePreviewHtml as t };
package/dist/ui/mount.js CHANGED
@@ -14750,7 +14750,7 @@ const getHistoryVersion = (scope, slug, id) => request(`${historyPath(scope, slu
14750
14750
  const PAGE_DEBOUNCE_MS = 160;
14751
14751
  const SITE_DEBOUNCE_MS = 200;
14752
14752
  /** Site edits that change the header or footer markup. Text typed on the page itself is skipped at render time. */
14753
- const SITE_PREVIEW_PATH = /^(name|nameMarks|brandLogo|header\.(variant|tone|sticky|actions|links)|footer\.(variant|tone|columns|text|legal|badge))(\.|$)/;
14753
+ const SITE_PREVIEW_PATH = /^(name|nameMarks|brandLogo|header\.(variant|tone|sticky|actions|links)|footer\.(variant|tone|columns|text|legal|badge|poweredBy))(\.|$)/;
14754
14754
  function affectsSitePreview(path) {
14755
14755
  return SITE_PREVIEW_PATH.test(path);
14756
14756
  }
@@ -22319,7 +22319,8 @@ function JsonLdGroup({ site, onEdit }) {
22319
22319
  //#region src/ui/forms/footer-form.tsx
22320
22320
  /** Footer tab: layout, text, and the columns with their links. */
22321
22321
  function FooterForm({ site, options, maxColumns, pages, currentSlug, currentAnchors, onField, onOptional }) {
22322
- const layout = options.filter((option) => option.name.startsWith("footer.") && option.name !== "footer.badge");
22322
+ const layout = options.filter((option) => option.name.startsWith("footer.") && option.name !== "footer.badge" && option.name !== "footer.poweredBy");
22323
+ const poweredBy = options.find((option) => option.name === "footer.poweredBy");
22323
22324
  return /* @__PURE__ */ jsxs("div", {
22324
22325
  class: "bm-stack",
22325
22326
  children: [
@@ -22359,7 +22360,8 @@ function FooterForm({ site, options, maxColumns, pages, currentSlug, currentAnch
22359
22360
  value: text(getAt(site, "footer.badge")),
22360
22361
  onChange: (value) => onOptional("footer.badge", value),
22361
22362
  hint: "Pill on the footer. Empty hides it."
22362
- })
22363
+ }),
22364
+ poweredBy && siteOptionControl(site, poweredBy, onField)
22363
22365
  ]
22364
22366
  }),
22365
22367
  /* @__PURE__ */ jsx(FooterColumns, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bearminion",
3
- "version": "1.18.0",
3
+ "version": "1.20.0",
4
4
  "description": "A git-based CMS for Astro with no database and no server: JSON content in your repo, edited by clicking on the page during astro dev.",
5
5
  "license": "MIT",
6
6
  "author": "Jakub Lange",
@@ -3,7 +3,7 @@ import type { Site } from '../components/organisms/site-definition'
3
3
  import type { Page } from '../components/sections/definitions'
4
4
  import SectionList from '../components/sections/SectionList.astro'
5
5
  import Base from '../layouts/Base.astro'
6
- import { getPages, getSite } from '../lib/content'
6
+ import { getPage, getPages, getSite } from '../lib/content'
7
7
 
8
8
  export async function getStaticPaths() {
9
9
  const site = await getSite()
@@ -31,6 +31,11 @@ if (live) {
31
31
  site = (await live.content.getSite()) as Site
32
32
  page = (await live.content.getPage(Astro.params.slug ?? 'index')) as Page | undefined
33
33
  if (!page) return Astro.rewrite('/404')
34
+ } else if (!page) {
35
+ // A server build has no props: a visitor to a hosted editor with `signIn: 'optional'` gets the build's content.
36
+ site = await getSite()
37
+ page = await getPage(Astro.params.slug ?? 'index')
38
+ if (!page || page.slug === '404') return Astro.rewrite('/404')
34
39
  }
35
40
  if (!site || !page) throw new Error(`No content for ${Astro.url.pathname}.`)
36
41
  ---
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "template": "default",
4
- "version": "1.18.0",
4
+ "version": "1.20.0",
5
5
  "files": {
6
6
  "src/components/atoms/Button.astro": {
7
7
  "hash": "7be42b3dc3a3b59bec169de32a9d801904689e2705473d1945724658dc799043",
@@ -356,9 +356,10 @@
356
356
  ]
357
357
  },
358
358
  "src/pages/[...slug].astro": {
359
- "hash": "08bf1ac4b4a8a9961045f91e74a22aa2ec3b622998ebfa1f167ab39039bbf467",
359
+ "hash": "dfe279b2d84767700c0fbbbb85077c3f8f7334671adc25c633ae2fb1802ac28f",
360
360
  "history": [
361
- "c1f491e544eead7313f31a8e1c630776b5ec7ab886f61cf04fbd66eeed69fa28"
361
+ "c1f491e544eead7313f31a8e1c630776b5ec7ab886f61cf04fbd66eeed69fa28",
362
+ "08bf1ac4b4a8a9961045f91e74a22aa2ec3b622998ebfa1f167ab39039bbf467"
362
363
  ]
363
364
  }
364
365
  },