bearminion 1.20.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 +35 -0
- package/README.md +3 -3
- package/dist/astro.d.ts +16 -7
- package/dist/astro.js +212 -93
- package/dist/cli.js +903 -4
- package/dist/content-types-46XqPaW4.js +505 -0
- package/dist/content.d.ts +24 -3
- package/dist/content.js +83 -6
- package/dist/{editor-context-DzRwKENi.d.ts → editor-context-D1yfPp21.d.ts} +95 -8
- package/dist/{github-store-Dt_YuOPD.js → github-store-B2folBeq.js} +551 -206
- package/dist/{github-store-DsLCe5MR.d.ts → github-store-CuhvbFCh.d.ts} +1 -1
- package/dist/hosted-astro.js +1 -1
- package/dist/{hosted-middleware-CsROahka.js → hosted-middleware-DHLIedeV.js} +1 -1
- package/dist/hosted-overlay.js +1 -1
- package/dist/hosted.d.ts +10 -4
- package/dist/hosted.js +68 -9
- package/dist/index.d.ts +4 -4
- package/dist/index.js +11 -6
- package/dist/{migrate-b408EaLp.js → migrate-Cm30puW8.js} +2 -2
- package/dist/{page-wlcQJAA-.js → page-C7zE_HD1.js} +5 -1
- package/dist/{page-BGSTL63-.d.ts → page-CpVElMPH.d.ts} +193 -37
- package/dist/{request-guards-BcSUj8Gc.js → request-guards-DtNVdqQ7.js} +1 -1
- package/dist/{collections-Bm3RWg2K.js → routing-jKeq4LwO.js} +213 -57
- package/dist/routing-yPy8hEfZ.d.ts +137 -0
- package/dist/{theme-BvqJ8UnS.js → theme-DTVVNMlr.js} +1 -1
- package/dist/ui/mount.js +3294 -1259
- package/package.json +2 -2
- package/registry/default/files/src/components/organisms/EntryList.astro +83 -0
- package/registry/default/files/src/components/organisms/Pagination.astro +56 -0
- package/registry/default/files/src/components/sections/contact/definition.ts +6 -2
- package/registry/default/files/src/components/sections/faq/definition.ts +2 -2
- package/registry/default/files/src/components/sections/media/Media.astro +2 -2
- package/registry/default/files/src/components/sections/media/MediaPlayer.astro +2 -2
- package/registry/default/files/src/components/sections/pricing/definition.ts +16 -1
- package/registry/default/files/src/components/sections/shared.ts +3 -0
- package/registry/default/files/src/components/sections/stats/definition.ts +6 -1
- package/registry/default/files/src/components/sections/testimonials/definition.ts +13 -1
- package/registry/default/files/src/components/sections/text-image/definition.ts +1 -1
- package/registry/default/files/src/components/seo/Seo.astro +3 -1
- package/registry/default/files/src/content.config.ts +21 -0
- package/registry/default/files/src/env.d.ts +2 -0
- package/registry/default/files/src/lib/content.ts +81 -0
- package/registry/default/files/src/lib/editing.ts +6 -0
- package/registry/default/files/src/lib/sitemap.ts +48 -0
- package/registry/default/files/src/pages/[...slug].astro +30 -16
- package/registry/default/registry.json +77 -21
- package/dist/preview-DFLna-Be.d.ts +0 -42
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { r as fieldKey } from "./theme-
|
|
2
|
-
import {
|
|
1
|
+
import { r as fieldKey } from "./theme-DTVVNMlr.js";
|
|
2
|
+
import { i as createTolerantPageSchema, l as slugSchema } from "./page-C7zE_HD1.js";
|
|
3
|
+
import { T as repoKey, g as listingPath, h as listingPageCount, p as entryPath, t as HOME_SLUG, x as sortEntries, y as resolveTypes } from "./content-types-46XqPaW4.js";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
5
6
|
import { gfmFromMarkdown } from "mdast-util-gfm";
|
|
@@ -412,52 +413,6 @@ function removeField(frontmatter, key) {
|
|
|
412
413
|
return frontmatter.slice(0, start) + (lineEnd === -1 ? "" : frontmatter.slice(lineEnd + 1));
|
|
413
414
|
}
|
|
414
415
|
//#endregion
|
|
415
|
-
//#region src/store-error.ts
|
|
416
|
-
/** A key that is empty, has an empty or dot segment, or leaves its base directory. */
|
|
417
|
-
var StoreKeyError = class extends Error {
|
|
418
|
-
constructor(key) {
|
|
419
|
-
super(`"${key}" is not a valid store path.`);
|
|
420
|
-
this.name = "StoreKeyError";
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
/**
|
|
424
|
-
* A store that could not do what was asked, for a reason the person editing can act on (a refused token, a protected
|
|
425
|
-
* branch, a branch that moved). The editor API answers it with `status` and `code`, so the message reaches the page
|
|
426
|
-
* instead of becoming a bare 500.
|
|
427
|
-
*/
|
|
428
|
-
var StoreError = class extends Error {
|
|
429
|
-
status;
|
|
430
|
-
code;
|
|
431
|
-
constructor(status, code, message) {
|
|
432
|
-
super(message);
|
|
433
|
-
this.name = "StoreError";
|
|
434
|
-
this.status = status;
|
|
435
|
-
this.code = code;
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
//#endregion
|
|
439
|
-
//#region src/store-core.ts
|
|
440
|
-
/** The key of a file by its path from the project root, for content outside the content directory. */
|
|
441
|
-
function repoKey(path) {
|
|
442
|
-
return `/${path}`;
|
|
443
|
-
}
|
|
444
|
-
/** Splits a store key and refuses anything empty, with empty or dot segments, or leaving its base. */
|
|
445
|
-
function parseKey(key) {
|
|
446
|
-
const base = key.startsWith("/") ? "root" : "content";
|
|
447
|
-
const parts = (base === "root" ? key.slice(1) : key).split("/");
|
|
448
|
-
if (key === "" || parts.some((part) => part === "" || part === "." || part === "..")) throw new StoreKeyError(key);
|
|
449
|
-
return {
|
|
450
|
-
base,
|
|
451
|
-
parts
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
const SITE_KEY = "site.json";
|
|
455
|
-
const PAGES_DIR = "pages";
|
|
456
|
-
/** The key of the page with this slug. The slug must already be validated (`readSlug`). */
|
|
457
|
-
function pageKey(slug) {
|
|
458
|
-
return `${PAGES_DIR}/${slug}.json`;
|
|
459
|
-
}
|
|
460
|
-
//#endregion
|
|
461
416
|
//#region src/validate.ts
|
|
462
417
|
function fieldIssues(error) {
|
|
463
418
|
return error.issues.map((issue) => ({
|
|
@@ -468,10 +423,6 @@ function fieldIssues(error) {
|
|
|
468
423
|
function validateSite(input, site) {
|
|
469
424
|
return site.schema.safeParse(input);
|
|
470
425
|
}
|
|
471
|
-
/** Validate a page document: its own fields, and each section against the registry's schema for its type. */
|
|
472
|
-
function validatePage(input, registry) {
|
|
473
|
-
return createPageSchema(registry).safeParse(input);
|
|
474
|
-
}
|
|
475
426
|
/**
|
|
476
427
|
* Validate a page for the editor: like {@link validatePage}, but a section of a type the registry no longer
|
|
477
428
|
* defines is kept as it is. The site build still rejects such a page until the section is removed.
|
|
@@ -582,7 +533,7 @@ function jsonSafe(value) {
|
|
|
582
533
|
if (value !== null && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key, jsonSafe(inner)]));
|
|
583
534
|
return value;
|
|
584
535
|
}
|
|
585
|
-
function describe(collection, slug, source) {
|
|
536
|
+
function describe$1(collection, slug, source) {
|
|
586
537
|
const parts = splitEntry(source);
|
|
587
538
|
const format = collection.ext === ".mdx" ? "mdx" : "md";
|
|
588
539
|
const parsed = parseBody(parts.body, { mdx: format === "mdx" });
|
|
@@ -636,7 +587,7 @@ async function readEntry(store, collection, slug) {
|
|
|
636
587
|
try {
|
|
637
588
|
return {
|
|
638
589
|
ok: true,
|
|
639
|
-
value: describe(collection, slug, source)
|
|
590
|
+
value: describe$1(collection, slug, source)
|
|
640
591
|
};
|
|
641
592
|
} catch (error) {
|
|
642
593
|
return entryFailure(error);
|
|
@@ -694,7 +645,7 @@ async function updateEntry(store, collection, slug, patch) {
|
|
|
694
645
|
}]);
|
|
695
646
|
return {
|
|
696
647
|
ok: true,
|
|
697
|
-
value: describe(collection, slug, next)
|
|
648
|
+
value: describe$1(collection, slug, next)
|
|
698
649
|
};
|
|
699
650
|
} catch (error) {
|
|
700
651
|
return entryFailure(error);
|
|
@@ -722,7 +673,7 @@ async function createEntry(store, collection, input) {
|
|
|
722
673
|
}]);
|
|
723
674
|
return {
|
|
724
675
|
ok: true,
|
|
725
|
-
value: describe(collection, input.slug, source)
|
|
676
|
+
value: describe$1(collection, input.slug, source)
|
|
726
677
|
};
|
|
727
678
|
} catch (error) {
|
|
728
679
|
return entryFailure(error);
|
|
@@ -767,4 +718,209 @@ async function renameEntry(store, collection, slug, next) {
|
|
|
767
718
|
};
|
|
768
719
|
}
|
|
769
720
|
//#endregion
|
|
770
|
-
|
|
721
|
+
//#region src/routing.ts
|
|
722
|
+
const emptySeo = (title) => ({
|
|
723
|
+
title,
|
|
724
|
+
description: "",
|
|
725
|
+
noindex: false,
|
|
726
|
+
nofollow: false
|
|
727
|
+
});
|
|
728
|
+
/**
|
|
729
|
+
* A document that is not ready to be published: its status is `draft`, or its type declares a `draft` field and it is
|
|
730
|
+
* on. A build leaves it out of the routes, the listings and the sitemap.
|
|
731
|
+
*/
|
|
732
|
+
function isDraft(entry) {
|
|
733
|
+
return entry.status === "draft" || entry.fields?.draft === true;
|
|
734
|
+
}
|
|
735
|
+
/** What a declared single shows before it has been saved once: its label and nothing else. */
|
|
736
|
+
function emptySingle(type) {
|
|
737
|
+
return {
|
|
738
|
+
slug: type.slug,
|
|
739
|
+
title: type.label,
|
|
740
|
+
seo: emptySeo(type.label),
|
|
741
|
+
sections: [],
|
|
742
|
+
...type.fields ? { fields: {} } : {}
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
/** What a listing page shows above its list before it has been saved once. */
|
|
746
|
+
function emptyListing(type) {
|
|
747
|
+
return {
|
|
748
|
+
title: type.label,
|
|
749
|
+
seo: emptySeo(type.label),
|
|
750
|
+
sections: []
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
/** The entries a listing shows, in its order. */
|
|
754
|
+
function listedEntries(type, entries, options = {}) {
|
|
755
|
+
return sortEntries(type, options.drafts ? entries : entries.filter((entry) => !isDraft(entry)), options.locale);
|
|
756
|
+
}
|
|
757
|
+
/** A canonical address set on the listing belongs to its first page; page 2 is its own address. */
|
|
758
|
+
function laterPageSeo(seo, page) {
|
|
759
|
+
const { canonical: _canonical, ...rest } = seo;
|
|
760
|
+
return {
|
|
761
|
+
...rest,
|
|
762
|
+
title: `${seo.title} - Page ${page}`
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
/** One page of a type's listing. `entries` is what {@link listedEntries} returned. Undefined when there is no such page. */
|
|
766
|
+
function listingRoute(type, listing, entries, page) {
|
|
767
|
+
if (!type.listing) return void 0;
|
|
768
|
+
const pages = listingPageCount(type, entries.length);
|
|
769
|
+
if (!Number.isInteger(page) || page < 1 || page > pages) return void 0;
|
|
770
|
+
const { perPage, slug } = type.listing;
|
|
771
|
+
const document = listing ?? emptyListing(type);
|
|
772
|
+
const first = page === 1;
|
|
773
|
+
return {
|
|
774
|
+
kind: "listing",
|
|
775
|
+
type: type.id,
|
|
776
|
+
path: listingPath(type, page),
|
|
777
|
+
page: {
|
|
778
|
+
slug,
|
|
779
|
+
title: document.title,
|
|
780
|
+
seo: first ? document.seo : laterPageSeo(document.seo, page),
|
|
781
|
+
sections: first ? document.sections : []
|
|
782
|
+
},
|
|
783
|
+
entries: entries.slice((page - 1) * perPage, page * perPage).map((entry) => ({
|
|
784
|
+
slug: entry.slug,
|
|
785
|
+
title: entry.title,
|
|
786
|
+
path: entryPath(type, entry.slug),
|
|
787
|
+
description: entry.seo.description,
|
|
788
|
+
fields: entry.fields ?? {}
|
|
789
|
+
})),
|
|
790
|
+
pagination: {
|
|
791
|
+
page,
|
|
792
|
+
pages,
|
|
793
|
+
total: entries.length,
|
|
794
|
+
perPage,
|
|
795
|
+
previous: first ? null : listingPath(type, page - 1),
|
|
796
|
+
next: page === pages ? null : listingPath(type, page + 1),
|
|
797
|
+
links: Array.from({ length: pages }, (_, index) => ({
|
|
798
|
+
page: index + 1,
|
|
799
|
+
path: listingPath(type, index + 1),
|
|
800
|
+
current: index + 1 === page
|
|
801
|
+
}))
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Every address of the site with what it shows: the home page, the 404 page (at `/404`), declared singles, pages,
|
|
807
|
+
* and for each declared type its listing pages and its entries. Throws when two documents claim one address, naming
|
|
808
|
+
* both, so a hand-made file cannot silently replace another page.
|
|
809
|
+
*/
|
|
810
|
+
function siteRoutes(model, content, options = {}) {
|
|
811
|
+
const types = resolveTypes(model);
|
|
812
|
+
const routes = [];
|
|
813
|
+
const bySlug = new Map(content.pages.map((page) => [page.slug, page]));
|
|
814
|
+
const home = bySlug.get(HOME_SLUG);
|
|
815
|
+
if (home) routes.push({
|
|
816
|
+
kind: "page",
|
|
817
|
+
type: types.home.id,
|
|
818
|
+
path: types.home.path,
|
|
819
|
+
page: home
|
|
820
|
+
});
|
|
821
|
+
const notFound = bySlug.get("404");
|
|
822
|
+
if (notFound) routes.push({
|
|
823
|
+
kind: "page",
|
|
824
|
+
type: types.notFound.id,
|
|
825
|
+
path: types.notFound.path,
|
|
826
|
+
page: notFound
|
|
827
|
+
});
|
|
828
|
+
for (const type of types.singles) {
|
|
829
|
+
if (type.builtIn) continue;
|
|
830
|
+
routes.push({
|
|
831
|
+
kind: "page",
|
|
832
|
+
type: type.id,
|
|
833
|
+
path: type.path,
|
|
834
|
+
page: content.singles?.[type.id] ?? emptySingle(type)
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
for (const type of types.multi) {
|
|
838
|
+
const listed = listedEntries(type, type === types.pages ? content.pages.filter((page) => page.slug !== "index" && page.slug !== "404") : content.entries?.[type.id] ?? [], options);
|
|
839
|
+
for (let page = 1; page <= listingPageCount(type, listed.length); page++) {
|
|
840
|
+
const route = listingRoute(type, content.listings?.[type.id], listed, page);
|
|
841
|
+
if (route) routes.push(route);
|
|
842
|
+
}
|
|
843
|
+
for (const entry of listed) routes.push({
|
|
844
|
+
kind: "page",
|
|
845
|
+
type: type.id,
|
|
846
|
+
path: entryPath(type, entry.slug),
|
|
847
|
+
page: entry
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
const seen = /* @__PURE__ */ new Map();
|
|
851
|
+
for (const route of routes) {
|
|
852
|
+
const other = seen.get(route.path);
|
|
853
|
+
if (other) throw new Error(`Two documents share the address "${route.path}": ${describe(other)} and ${describe(route)}. Rename one of them, or change the type's path or listing slug.`);
|
|
854
|
+
seen.set(route.path, route);
|
|
855
|
+
}
|
|
856
|
+
return routes;
|
|
857
|
+
}
|
|
858
|
+
function describe(route) {
|
|
859
|
+
return route.kind === "listing" ? `the listing of "${route.type}"` : `"${route.page.slug}" (${route.type})`;
|
|
860
|
+
}
|
|
861
|
+
/** `/blog/` and `/blog` are one address; the root stays `/`. */
|
|
862
|
+
function normalizePath(pathname) {
|
|
863
|
+
const trimmed = pathname.length > 1 ? pathname.replace(/\/+$/, "") : pathname;
|
|
864
|
+
return trimmed === "" ? "/" : trimmed;
|
|
865
|
+
}
|
|
866
|
+
/** The route at `pathname`, or undefined. */
|
|
867
|
+
function findRoute(model, content, pathname, options = {}) {
|
|
868
|
+
const wanted = normalizePath(pathname);
|
|
869
|
+
return siteRoutes(model, content, options).find((route) => route.path === wanted);
|
|
870
|
+
}
|
|
871
|
+
const SEGMENT = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
872
|
+
/**
|
|
873
|
+
* What kind of document `pathname` would be, from the address alone: for a reader that fetches one document at a
|
|
874
|
+
* time and must know which. It does not say the document exists. Null when no type has such an address.
|
|
875
|
+
*/
|
|
876
|
+
function matchPath(types, pathname) {
|
|
877
|
+
const path = normalizePath(pathname);
|
|
878
|
+
if (path === "/") return {
|
|
879
|
+
kind: "single",
|
|
880
|
+
type: types.home
|
|
881
|
+
};
|
|
882
|
+
const parts = path.slice(1).split("/");
|
|
883
|
+
if (parts.some((part) => !SEGMENT.test(part))) return null;
|
|
884
|
+
const [first = "", second = "", third = ""] = parts;
|
|
885
|
+
const declared = types.multi.filter((type) => type !== types.pages);
|
|
886
|
+
if (parts.length === 1) {
|
|
887
|
+
const single = types.singles.find((type) => type.slug === first && type !== types.home);
|
|
888
|
+
if (single) return {
|
|
889
|
+
kind: "single",
|
|
890
|
+
type: single
|
|
891
|
+
};
|
|
892
|
+
const listing = declared.find((type) => type.listing?.slug === first);
|
|
893
|
+
if (listing) return {
|
|
894
|
+
kind: "listing",
|
|
895
|
+
type: listing,
|
|
896
|
+
page: 1
|
|
897
|
+
};
|
|
898
|
+
return {
|
|
899
|
+
kind: "entry",
|
|
900
|
+
type: types.pages,
|
|
901
|
+
slug: first
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
if (parts.length === 2) {
|
|
905
|
+
const type = declared.find((candidate) => candidate.prefix === first);
|
|
906
|
+
if (!type) return null;
|
|
907
|
+
if (type.listing?.slug === type.prefix && second === "page") return null;
|
|
908
|
+
return {
|
|
909
|
+
kind: "entry",
|
|
910
|
+
type,
|
|
911
|
+
slug: second
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
if (parts.length === 3 && second === "page" && /^[1-9][0-9]*$/.test(third)) {
|
|
915
|
+
const type = declared.find((candidate) => candidate.listing?.slug === first);
|
|
916
|
+
const page = Number(third);
|
|
917
|
+
return type && page >= 2 ? {
|
|
918
|
+
kind: "listing",
|
|
919
|
+
type,
|
|
920
|
+
page
|
|
921
|
+
} : null;
|
|
922
|
+
}
|
|
923
|
+
return null;
|
|
924
|
+
}
|
|
925
|
+
//#endregion
|
|
926
|
+
export { ContentValidationError as A, loadThemePreview as C, schemaProps as D, imageFields as E, ContentError as O, defineThemePreview as S, enumFields as T, updateEntry as _, listingRoute as a, validateSite as b, siteRoutes as c, deleteEntry as d, fieldDefinitions as f, resolveCollections as g, renameEntry as h, listedEntries as i, formatContentIssues as j, ContentReadError as k, collection as l, readEntry as m, findRoute as n, matchPath as o, listEntries as p, isDraft as r, normalizePath as s, emptySingle as t, createEntry as u, fieldIssues as v, previewRenderers as w, PreviewUnavailableError as x, validateEditorPage as y };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { D as Entry, F as SingleType, G as SectionOf, It as SiteOf, M as ResolvedTypes, R as TypesInput, f as ContentModel, j as MultiType, k as ListingDocument } from "./page-CpVElMPH.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
|
+
//#region src/routing.d.ts
|
|
43
|
+
/** A site's content, however it was read: `loadContent()`, Astro's collections, or a store. */
|
|
44
|
+
interface SiteContent {
|
|
45
|
+
/** Everything in `content/pages/`: the home page (`index`), the 404 page and the pages. */
|
|
46
|
+
pages: readonly Entry[];
|
|
47
|
+
/** The entries of each declared type, by type id. */
|
|
48
|
+
entries?: Readonly<Record<string, readonly Entry[]>>;
|
|
49
|
+
/** The listing page document of each type that has one saved, by type id. */
|
|
50
|
+
listings?: Readonly<Record<string, ListingDocument>>;
|
|
51
|
+
/** The document of each declared single that has been saved, by type id. */
|
|
52
|
+
singles?: Readonly<Record<string, Entry>>;
|
|
53
|
+
}
|
|
54
|
+
/** One entry as a listing shows it. */
|
|
55
|
+
interface ListedEntry {
|
|
56
|
+
slug: string;
|
|
57
|
+
title: string;
|
|
58
|
+
/** The entry's address, such as `/blog/first-post`. */
|
|
59
|
+
path: string;
|
|
60
|
+
/** The entry's SEO description, for a card that has no excerpt field. */
|
|
61
|
+
description: string;
|
|
62
|
+
fields: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
interface Pagination {
|
|
65
|
+
/** The page shown, from 1. */
|
|
66
|
+
page: number;
|
|
67
|
+
pages: number;
|
|
68
|
+
/** How many entries the listing has over all its pages. */
|
|
69
|
+
total: number;
|
|
70
|
+
perPage: number;
|
|
71
|
+
/** Address of the page before this one, or null on the first. */
|
|
72
|
+
previous: string | null;
|
|
73
|
+
next: string | null;
|
|
74
|
+
links: {
|
|
75
|
+
page: number;
|
|
76
|
+
path: string;
|
|
77
|
+
current: boolean;
|
|
78
|
+
}[];
|
|
79
|
+
}
|
|
80
|
+
interface PageRoute {
|
|
81
|
+
kind: 'page';
|
|
82
|
+
/** Id of the document's content type: `home`, `not-found`, `pages`, or one the site declares. */
|
|
83
|
+
type: string;
|
|
84
|
+
path: string;
|
|
85
|
+
page: Entry;
|
|
86
|
+
}
|
|
87
|
+
interface ListingRoute {
|
|
88
|
+
kind: 'listing';
|
|
89
|
+
type: string;
|
|
90
|
+
path: string;
|
|
91
|
+
/** The listing as a page: its sections are shown above the list on the first page only. */
|
|
92
|
+
page: Entry;
|
|
93
|
+
entries: ListedEntry[];
|
|
94
|
+
pagination: Pagination;
|
|
95
|
+
}
|
|
96
|
+
type Route = PageRoute | ListingRoute;
|
|
97
|
+
interface RouteOptions {
|
|
98
|
+
/** The language strings are sorted in. Pass the site's `lang`. Default `en`. */
|
|
99
|
+
locale?: string;
|
|
100
|
+
/** Include entries whose `fields.draft` is true. For `astro dev` and the editor; a build leaves them out. */
|
|
101
|
+
drafts?: boolean;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* A document that is not ready to be published: its status is `draft`, or its type declares a `draft` field and it is
|
|
105
|
+
* on. A build leaves it out of the routes, the listings and the sitemap.
|
|
106
|
+
*/
|
|
107
|
+
declare function isDraft(entry: {
|
|
108
|
+
status?: string;
|
|
109
|
+
fields?: Record<string, unknown>;
|
|
110
|
+
}): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Every address of the site with what it shows: the home page, the 404 page (at `/404`), declared singles, pages,
|
|
113
|
+
* and for each declared type its listing pages and its entries. Throws when two documents claim one address, naming
|
|
114
|
+
* both, so a hand-made file cannot silently replace another page.
|
|
115
|
+
*/
|
|
116
|
+
declare function siteRoutes(model: TypesInput, content: SiteContent, options?: RouteOptions): Route[];
|
|
117
|
+
/** The route at `pathname`, or undefined. */
|
|
118
|
+
declare function findRoute(model: TypesInput, content: SiteContent, pathname: string, options?: RouteOptions): Route | undefined;
|
|
119
|
+
type PathMatch = {
|
|
120
|
+
kind: 'single';
|
|
121
|
+
type: SingleType;
|
|
122
|
+
} | {
|
|
123
|
+
kind: 'entry';
|
|
124
|
+
type: MultiType;
|
|
125
|
+
slug: string;
|
|
126
|
+
} | {
|
|
127
|
+
kind: 'listing';
|
|
128
|
+
type: MultiType;
|
|
129
|
+
page: number;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* What kind of document `pathname` would be, from the address alone: for a reader that fetches one document at a
|
|
133
|
+
* time and must know which. It does not say the document exists. Null when no type has such an address.
|
|
134
|
+
*/
|
|
135
|
+
declare function matchPath(types: ResolvedTypes, pathname: string): PathMatch | null;
|
|
136
|
+
//#endregion
|
|
137
|
+
export { PathMatch as a, SiteContent as c, matchPath as d, siteRoutes as f, defineThemePreview as g, ThemePreviewSource as h, Pagination as i, findRoute as l, ThemePreview as m, ListingRoute as n, Route as o, SitePreviewHtml as p, PageRoute as r, RouteOptions as s, ListedEntry as t, isDraft as u };
|