bearminion 1.17.0 → 1.19.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,6 @@
1
- import { _ as CollectionOptions, n as ImageConvertOptions, t as EditorContext, v as collection, y as ContentStore } from "./editor-context-CuD7HgT7.js";
2
- import { i as StoreKeyError, n as githubStore, r as StoreError, t as GithubStoreOptions } from "./github-store-C4oCDBnl.js";
3
- import { g as ContentModel, n as PageRules, t as Page } from "./page-DNbZW-J7.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
4
  //#region src/api.d.ts
5
5
  interface HandleMeta {
6
6
  /**
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
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-CuD7HgT7.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-DNbZW-J7.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
5
  //#region src/errors.d.ts
6
6
  /** One schema problem, addressed by a dot path such as `sections.0.props.heading`. */
package/dist/index.js CHANGED
@@ -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
  }
@@ -104,10 +104,10 @@ declare const textMarkSchema: z.ZodObject<{
104
104
  start: z.ZodNumber;
105
105
  end: z.ZodNumber;
106
106
  weight: z.ZodOptional<z.ZodEnum<{
107
+ bold: "bold";
107
108
  regular: "regular";
108
109
  medium: "medium";
109
110
  semibold: "semibold";
110
- bold: "bold";
111
111
  }>>;
112
112
  italic: z.ZodOptional<z.ZodBoolean>;
113
113
  font: z.ZodOptional<z.ZodEnum<{
@@ -148,10 +148,10 @@ declare function withEmphasis<T extends z.ZodRawShape>(shape: T): z.ZodPipe<z.Zo
148
148
  start: z.ZodNumber;
149
149
  end: z.ZodNumber;
150
150
  weight: z.ZodOptional<z.ZodEnum<{
151
+ bold: "bold";
151
152
  regular: "regular";
152
153
  medium: "medium";
153
154
  semibold: "semibold";
154
- bold: "bold";
155
155
  }>>;
156
156
  italic: z.ZodOptional<z.ZodBoolean>;
157
157
  font: z.ZodOptional<z.ZodEnum<{
@@ -166,10 +166,10 @@ declare function withEmphasis<T extends z.ZodRawShape>(shape: T): z.ZodPipe<z.Zo
166
166
  start: z.ZodNumber;
167
167
  end: z.ZodNumber;
168
168
  weight: z.ZodOptional<z.ZodEnum<{
169
+ bold: "bold";
169
170
  regular: "regular";
170
171
  medium: "medium";
171
172
  semibold: "semibold";
172
- bold: "bold";
173
173
  }>>;
174
174
  italic: z.ZodOptional<z.ZodBoolean>;
175
175
  font: z.ZodOptional<z.ZodEnum<{
@@ -186,10 +186,10 @@ declare function withEmphasis<T extends z.ZodRawShape>(shape: T): z.ZodPipe<z.Zo
186
186
  start: z.ZodNumber;
187
187
  end: z.ZodNumber;
188
188
  weight: z.ZodOptional<z.ZodEnum<{
189
+ bold: "bold";
189
190
  regular: "regular";
190
191
  medium: "medium";
191
192
  semibold: "semibold";
192
- bold: "bold";
193
193
  }>>;
194
194
  italic: z.ZodOptional<z.ZodBoolean>;
195
195
  font: z.ZodOptional<z.ZodEnum<{
@@ -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<{
@@ -446,10 +447,10 @@ declare function createSiteSchema(header: HeaderParts, footer: FooterParts): z.Z
446
447
  start: z.ZodNumber;
447
448
  end: z.ZodNumber;
448
449
  weight: z.ZodOptional<z.ZodEnum<{
450
+ bold: "bold";
449
451
  regular: "regular";
450
452
  medium: "medium";
451
453
  semibold: "semibold";
452
- bold: "bold";
453
454
  }>>;
454
455
  italic: z.ZodOptional<z.ZodBoolean>;
455
456
  font: z.ZodOptional<z.ZodEnum<{
@@ -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>>>;
@@ -681,7 +683,7 @@ declare function createSiteSchema(header: HeaderParts, footer: FooterParts): z.Z
681
683
  nameMarks: {
682
684
  start: number;
683
685
  end: number;
684
- weight?: "regular" | "medium" | "semibold" | "bold" | undefined;
686
+ weight?: "bold" | "regular" | "medium" | "semibold" | undefined;
685
687
  italic?: boolean | undefined;
686
688
  font?: "sans" | "serif" | "mono" | undefined;
687
689
  }[] | undefined;
@@ -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,12 +937,13 @@ 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?: {
940
944
  start: number;
941
945
  end: number;
942
- weight?: "regular" | "medium" | "semibold" | "bold" | undefined;
946
+ weight?: "bold" | "regular" | "medium" | "semibold" | undefined;
943
947
  italic?: boolean | undefined;
944
948
  font?: "sans" | "serif" | "mono" | undefined;
945
949
  }[] | undefined;
@@ -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. */
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.17.0",
3
+ "version": "1.19.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",
@@ -0,0 +1,73 @@
1
+ ---
2
+ import { hasJsonLdId, mergeJsonLd, siteJsonLdIds, type Page } from 'bearminion'
3
+ import type { Site } from '../organisms/site-definition'
4
+ import { isRemote, resolveLocalAsset } from '../../lib/assets'
5
+ import { editing } from '../../lib/editing'
6
+
7
+ interface Props {
8
+ site: Site
9
+ page: Page
10
+ pathname: string
11
+ }
12
+
13
+ const { site, page, pathname } = Astro.props
14
+
15
+ function resolveAgainstSite(value: string): string {
16
+ if (/^https?:\/\//i.test(value)) return value
17
+ return new URL(value, site.url).href
18
+ }
19
+
20
+ function absoluteImage(src: string): string | undefined {
21
+ if (isRemote(src)) return src
22
+ const asset = resolveLocalAsset(src)
23
+ // An image just uploaded in the hosted editor is not in this build yet. A preview has no use for a share image.
24
+ if (!asset && editing) return undefined
25
+ if (!asset) throw new Error(`No file in src/assets for image path "${src}". Restore the file, or choose another image in the editor and save.`)
26
+ return new URL(asset.src, site.url).href
27
+ }
28
+
29
+ const title = site.seo.titleTemplate ? site.seo.titleTemplate.replaceAll('%s', page.seo.title) : page.seo.title
30
+ const description = page.seo.description || site.seo.description || ''
31
+ const path = pathname.startsWith('/') ? pathname : `/${pathname}`
32
+ const canonical = page.seo.canonical ? resolveAgainstSite(page.seo.canonical) : new URL(path, site.url).href
33
+ const robots = [page.seo.noindex ? 'noindex' : 'index', page.seo.nofollow ? 'nofollow' : 'follow'].join(', ')
34
+ const ogImageSrc = page.seo.ogImage ?? site.seo.ogImage
35
+ const ogImage = ogImageSrc ? absoluteImage(ogImageSrc) : undefined
36
+
37
+ // Blocks from site.seo.jsonLd go on every page. When the site describes itself, the generated WebPage points at those blocks.
38
+ const siteBlocks = site.seo.jsonLd ?? []
39
+ const ids = siteJsonLdIds(site.url)
40
+ const webPage = {
41
+ '@context': 'https://schema.org',
42
+ '@type': 'WebPage',
43
+ name: title,
44
+ description,
45
+ url: canonical,
46
+ ...(ogImage ? { image: ogImage } : {}),
47
+ isPartOf: hasJsonLdId(siteBlocks, ids.website) ? { '@id': ids.website } : { '@type': 'WebSite', name: site.name, url: site.url },
48
+ ...(hasJsonLdId(siteBlocks, ids.organization) ? { publisher: { '@id': ids.organization } } : {}),
49
+ }
50
+ // A page's own JSON-LD replaces only the generated WebPage. Blocks with the same @id are emitted once, the page's first.
51
+ const blocks = mergeJsonLd(siteBlocks, page.seo.jsonLd ?? [webPage])
52
+ ---
53
+
54
+ <title>{title}</title>
55
+ <meta name="description" content={description} />
56
+ <link rel="canonical" href={canonical} />
57
+ <meta name="robots" content={robots} />
58
+ <meta property="og:site_name" content={site.name} />
59
+ <meta property="og:title" content={title} />
60
+ <meta property="og:description" content={description} />
61
+ <meta property="og:type" content="website" />
62
+ <meta property="og:url" content={canonical} />
63
+ {ogImage && <meta property="og:image" content={ogImage} />}
64
+ <meta name="twitter:card" content={ogImage ? 'summary_large_image' : 'summary'} />
65
+ <meta name="twitter:title" content={title} />
66
+ <meta name="twitter:description" content={description} />
67
+ {ogImage && <meta name="twitter:image" content={ogImage} />}
68
+ {/* `<` is escaped so a value cannot close the script tag. */}
69
+ {
70
+ blocks.map((block) => (
71
+ <script type="application/ld+json" set:html={JSON.stringify(block).replace(/</g, '\\u003c')} />
72
+ ))
73
+ }
@@ -0,0 +1,13 @@
1
+ /// <reference types="astro/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ /** Set by the hosted editor's build (`bearminionHostedEditor`). Not set in a public site's build. */
5
+ readonly BEARMINION_HOSTED?: boolean
6
+ }
7
+
8
+ declare namespace App {
9
+ interface Locals {
10
+ /** Set by the hosted editor (`bearminionHostedEditor`) for a signed-in person: the repository's current content. */
11
+ bearminion?: import('bearminion/hosted').HostedLocals
12
+ }
13
+ }
@@ -0,0 +1,18 @@
1
+ ---
2
+ import type { Site } from '../components/organisms/site-definition'
3
+ import type { Page } from '../components/sections/definitions'
4
+ import SectionList from '../components/sections/SectionList.astro'
5
+ import Base from '../layouts/Base.astro'
6
+ import { getPage, getSite } from '../lib/content'
7
+
8
+ // Astro emits this route as /404.html, which static hosts serve for unknown URLs.
9
+ // The content is content/pages/404.json, so the editor changes it like any other page.
10
+ const live = Astro.locals.bearminion
11
+ const site = live ? ((await live.content.getSite()) as Site) : await getSite()
12
+ const page = live ? ((await live.content.getPage('404')) as Page | undefined) : await getPage('404')
13
+ if (!page) throw new Error('content/pages/404.json is missing')
14
+ ---
15
+
16
+ <Base site={site} page={page}>
17
+ <SectionList sections={page.sections} motion={site.theme.motion} />
18
+ </Base>
@@ -0,0 +1,40 @@
1
+ ---
2
+ import type { Site } from '../components/organisms/site-definition'
3
+ import type { Page } from '../components/sections/definitions'
4
+ import SectionList from '../components/sections/SectionList.astro'
5
+ import Base from '../layouts/Base.astro'
6
+ import { getPages, getSite } from '../lib/content'
7
+
8
+ export async function getStaticPaths() {
9
+ const site = await getSite()
10
+ // 404.json is rendered by src/pages/404.astro, so Astro emits /404.html instead of /404/index.html.
11
+ const pages = await getPages(['404'])
12
+
13
+ return pages.map((page) => ({
14
+ params: {
15
+ // The home page is stored as slug "index" and published at `/`.
16
+ slug: page.slug === 'index' ? undefined : page.slug,
17
+ },
18
+ props: { site, page },
19
+ }))
20
+ }
21
+
22
+ interface Props {
23
+ site: Site
24
+ page: Page
25
+ }
26
+
27
+ // The hosted editor draws the repository's current content (`Astro.locals.bearminion`); a static build uses the props.
28
+ const live = Astro.locals.bearminion
29
+ let { site, page } = Astro.props as Partial<Props>
30
+ if (live) {
31
+ site = (await live.content.getSite()) as Site
32
+ page = (await live.content.getPage(Astro.params.slug ?? 'index')) as Page | undefined
33
+ if (!page) return Astro.rewrite('/404')
34
+ }
35
+ if (!site || !page) throw new Error(`No content for ${Astro.url.pathname}.`)
36
+ ---
37
+
38
+ <Base site={site} page={page}>
39
+ <SectionList sections={page.sections} motion={site.theme.motion} />
40
+ </Base>