@lets-ship/site 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/README.md +59 -2
- package/bin/ship-site.js +5 -0
- package/dist/badge/badge.d.ts +14 -0
- package/dist/badge/badge.d.ts.map +1 -0
- package/dist/badge/badge.js +16 -0
- package/dist/badge/badge.js.map +1 -0
- package/dist/blog/arrow.d.ts +6 -0
- package/dist/blog/arrow.d.ts.map +1 -0
- package/dist/blog/arrow.js +6 -0
- package/dist/blog/arrow.js.map +1 -0
- package/dist/blog/article-view.d.ts +20 -0
- package/dist/blog/article-view.d.ts.map +1 -0
- package/dist/blog/article-view.js +71 -0
- package/dist/blog/article-view.js.map +1 -0
- package/dist/blog/article.d.ts +72 -0
- package/dist/blog/article.d.ts.map +1 -0
- package/dist/blog/article.js +90 -0
- package/dist/blog/article.js.map +1 -0
- package/dist/blog/featured.d.ts +18 -0
- package/dist/blog/featured.d.ts.map +1 -0
- package/dist/blog/featured.js +19 -0
- package/dist/blog/featured.js.map +1 -0
- package/dist/blog/frontmatter.d.ts +155 -0
- package/dist/blog/frontmatter.d.ts.map +1 -0
- package/dist/blog/frontmatter.js +96 -0
- package/dist/blog/frontmatter.js.map +1 -0
- package/dist/blog/index-view.d.ts +21 -0
- package/dist/blog/index-view.d.ts.map +1 -0
- package/dist/blog/index-view.js +70 -0
- package/dist/blog/index-view.js.map +1 -0
- package/dist/blog/inline-markdown.d.ts +15 -0
- package/dist/blog/inline-markdown.d.ts.map +1 -0
- package/dist/blog/inline-markdown.js +44 -0
- package/dist/blog/inline-markdown.js.map +1 -0
- package/dist/blog/post-card.d.ts +37 -0
- package/dist/blog/post-card.d.ts.map +1 -0
- package/dist/blog/post-card.js +68 -0
- package/dist/blog/post-card.js.map +1 -0
- package/dist/blog/site.d.ts +57 -0
- package/dist/blog/site.d.ts.map +1 -0
- package/dist/blog/site.js +76 -0
- package/dist/blog/site.js.map +1 -0
- package/dist/blog/toc.d.ts +29 -0
- package/dist/blog/toc.d.ts.map +1 -0
- package/dist/blog/toc.js +42 -0
- package/dist/blog/toc.js.map +1 -0
- package/dist/config/context.d.ts +16 -0
- package/dist/config/context.d.ts.map +1 -0
- package/dist/config/context.js +11 -0
- package/dist/config/context.js.map +1 -0
- package/dist/config/identity.d.ts +41 -0
- package/dist/config/identity.d.ts.map +1 -0
- package/dist/config/identity.js +28 -0
- package/dist/config/identity.js.map +1 -0
- package/dist/config/json-schema.d.ts +11 -0
- package/dist/config/json-schema.d.ts.map +1 -0
- package/dist/config/json-schema.js +14 -0
- package/dist/config/json-schema.js.map +1 -0
- package/dist/config/site-config.d.ts +145 -0
- package/dist/config/site-config.d.ts.map +1 -0
- package/dist/config/site-config.js +130 -0
- package/dist/config/site-config.js.map +1 -0
- package/dist/docs/page-view.d.ts +21 -0
- package/dist/docs/page-view.d.ts.map +1 -0
- package/dist/docs/page-view.js +27 -0
- package/dist/docs/page-view.js.map +1 -0
- package/dist/feeds/feeds.d.ts +33 -0
- package/dist/feeds/feeds.d.ts.map +1 -0
- package/dist/feeds/feeds.js +122 -0
- package/dist/feeds/feeds.js.map +1 -0
- package/dist/format/dates.d.ts +5 -0
- package/dist/format/dates.d.ts.map +1 -0
- package/dist/format/dates.js +17 -0
- package/dist/format/dates.js.map +1 -0
- package/dist/format/node-text.d.ts +7 -0
- package/dist/format/node-text.d.ts.map +1 -0
- package/dist/format/node-text.js +15 -0
- package/dist/format/node-text.js.map +1 -0
- package/dist/format/toc-depth.d.ts +11 -0
- package/dist/format/toc-depth.d.ts.map +1 -0
- package/dist/format/toc-depth.js +14 -0
- package/dist/format/toc-depth.js.map +1 -0
- package/dist/i18n/fumadocs-keys.d.ts +13 -0
- package/dist/i18n/fumadocs-keys.d.ts.map +1 -0
- package/dist/i18n/fumadocs-keys.js +136 -0
- package/dist/i18n/fumadocs-keys.js.map +1 -0
- package/dist/i18n/strings.d.ts +19 -0
- package/dist/i18n/strings.d.ts.map +1 -0
- package/dist/i18n/strings.js +59 -0
- package/dist/i18n/strings.js.map +1 -0
- package/dist/i18n/tables/de.d.ts +3 -0
- package/dist/i18n/tables/de.d.ts.map +1 -0
- package/dist/i18n/tables/de.js +82 -0
- package/dist/i18n/tables/de.js.map +1 -0
- package/dist/i18n/tables/en.d.ts +3 -0
- package/dist/i18n/tables/en.d.ts.map +1 -0
- package/dist/i18n/tables/en.js +25 -0
- package/dist/i18n/tables/en.js.map +1 -0
- package/dist/i18n/tables/es.d.ts +3 -0
- package/dist/i18n/tables/es.d.ts.map +1 -0
- package/dist/i18n/tables/es.js +82 -0
- package/dist/i18n/tables/es.js.map +1 -0
- package/dist/i18n/tables/fr.d.ts +3 -0
- package/dist/i18n/tables/fr.d.ts.map +1 -0
- package/dist/i18n/tables/fr.js +82 -0
- package/dist/i18n/tables/fr.js.map +1 -0
- package/dist/i18n/tables/nl.d.ts +3 -0
- package/dist/i18n/tables/nl.d.ts.map +1 -0
- package/dist/i18n/tables/nl.js +82 -0
- package/dist/i18n/tables/nl.js.map +1 -0
- package/dist/i18n/tables/pt.d.ts +3 -0
- package/dist/i18n/tables/pt.d.ts.map +1 -0
- package/dist/i18n/tables/pt.js +82 -0
- package/dist/i18n/tables/pt.js.map +1 -0
- package/dist/i18n/tables/tr.d.ts +3 -0
- package/dist/i18n/tables/tr.d.ts.map +1 -0
- package/dist/i18n/tables/tr.js +82 -0
- package/dist/i18n/tables/tr.js.map +1 -0
- package/dist/i18n/types.d.ts +39 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +2 -0
- package/dist/i18n/types.js.map +1 -0
- package/dist/layout/analytics.d.ts +9 -0
- package/dist/layout/analytics.d.ts.map +1 -0
- package/dist/layout/analytics.js +18 -0
- package/dist/layout/analytics.js.map +1 -0
- package/dist/layout/brand-files.d.ts +15 -0
- package/dist/layout/brand-files.d.ts.map +1 -0
- package/dist/layout/brand-files.js +15 -0
- package/dist/layout/brand-files.js.map +1 -0
- package/dist/layout/footer.d.ts +10 -0
- package/dist/layout/footer.d.ts.map +1 -0
- package/dist/layout/footer.js +21 -0
- package/dist/layout/footer.js.map +1 -0
- package/dist/layout/not-found.d.ts +7 -0
- package/dist/layout/not-found.d.ts.map +1 -0
- package/dist/layout/not-found.js +8 -0
- package/dist/layout/not-found.js.map +1 -0
- package/dist/layout/provider.d.ts +17 -0
- package/dist/layout/provider.d.ts.map +1 -0
- package/dist/layout/provider.js +14 -0
- package/dist/layout/provider.js.map +1 -0
- package/dist/layout/root.d.ts +17 -0
- package/dist/layout/root.d.ts.map +1 -0
- package/dist/layout/root.js +47 -0
- package/dist/layout/root.js.map +1 -0
- package/dist/lint/source.d.ts +19 -0
- package/dist/lint/source.d.ts.map +1 -0
- package/dist/lint/source.js +43 -0
- package/dist/lint/source.js.map +1 -0
- package/dist/llms/llms.d.ts +22 -0
- package/dist/llms/llms.d.ts.map +1 -0
- package/dist/llms/llms.js +24 -0
- package/dist/llms/llms.js.map +1 -0
- package/dist/markdown/article.d.ts +44 -0
- package/dist/markdown/article.d.ts.map +1 -0
- package/dist/markdown/article.js +108 -0
- package/dist/markdown/article.js.map +1 -0
- package/dist/markdown/inline.d.ts +40 -0
- package/dist/markdown/inline.d.ts.map +1 -0
- package/dist/markdown/inline.js +74 -0
- package/dist/markdown/inline.js.map +1 -0
- package/dist/markdown/page.d.ts +13 -0
- package/dist/markdown/page.d.ts.map +1 -0
- package/dist/markdown/page.js +21 -0
- package/dist/markdown/page.js.map +1 -0
- package/dist/marker.d.ts +37 -0
- package/dist/marker.d.ts.map +1 -0
- package/dist/marker.js +36 -0
- package/dist/marker.js.map +1 -0
- package/dist/mdx/allow-list.d.ts +23 -0
- package/dist/mdx/allow-list.d.ts.map +1 -0
- package/dist/mdx/allow-list.js +79 -0
- package/dist/mdx/allow-list.js.map +1 -0
- package/dist/mdx/components.d.ts +8 -0
- package/dist/mdx/components.d.ts.map +1 -0
- package/dist/mdx/components.js +68 -0
- package/dist/mdx/components.js.map +1 -0
- package/dist/mdx/remark-alerts.d.ts +4 -0
- package/dist/mdx/remark-alerts.d.ts.map +1 -0
- package/dist/mdx/remark-alerts.js +39 -0
- package/dist/mdx/remark-alerts.js.map +1 -0
- package/dist/next.d.ts +24 -0
- package/dist/next.d.ts.map +1 -0
- package/dist/next.js +55 -0
- package/dist/next.js.map +1 -0
- package/dist/node/bin.d.ts +3 -0
- package/dist/node/bin.d.ts.map +1 -0
- package/dist/node/bin.js +13 -0
- package/dist/node/bin.js.map +1 -0
- package/dist/node/brand.d.ts +13 -0
- package/dist/node/brand.d.ts.map +1 -0
- package/dist/node/brand.js +48 -0
- package/dist/node/brand.js.map +1 -0
- package/dist/node/build.d.ts +20 -0
- package/dist/node/build.d.ts.map +1 -0
- package/dist/node/build.js +133 -0
- package/dist/node/build.js.map +1 -0
- package/dist/node/cli.d.ts +11 -0
- package/dist/node/cli.d.ts.map +1 -0
- package/dist/node/cli.js +80 -0
- package/dist/node/cli.js.map +1 -0
- package/dist/node/config-file.d.ts +5 -0
- package/dist/node/config-file.d.ts.map +1 -0
- package/dist/node/config-file.js +31 -0
- package/dist/node/config-file.js.map +1 -0
- package/dist/node/content.d.ts +6 -0
- package/dist/node/content.d.ts.map +1 -0
- package/dist/node/content.js +36 -0
- package/dist/node/content.js.map +1 -0
- package/dist/node/errors.d.ts +26 -0
- package/dist/node/errors.d.ts.map +1 -0
- package/dist/node/errors.js +34 -0
- package/dist/node/errors.js.map +1 -0
- package/dist/node/files.d.ts +12 -0
- package/dist/node/files.d.ts.map +1 -0
- package/dist/node/files.js +43 -0
- package/dist/node/files.js.map +1 -0
- package/dist/node/marker.d.ts +24 -0
- package/dist/node/marker.d.ts.map +1 -0
- package/dist/node/marker.js +22 -0
- package/dist/node/marker.js.map +1 -0
- package/dist/node/og.d.ts +17 -0
- package/dist/node/og.d.ts.map +1 -0
- package/dist/node/og.js +43 -0
- package/dist/node/og.js.map +1 -0
- package/dist/node/project-root.d.ts +12 -0
- package/dist/node/project-root.d.ts.map +1 -0
- package/dist/node/project-root.js +27 -0
- package/dist/node/project-root.js.map +1 -0
- package/dist/node/serve.d.ts +32 -0
- package/dist/node/serve.d.ts.map +1 -0
- package/dist/node/serve.js +133 -0
- package/dist/node/serve.js.map +1 -0
- package/dist/node/theme.d.ts +15 -0
- package/dist/node/theme.d.ts.map +1 -0
- package/dist/node/theme.js +46 -0
- package/dist/node/theme.js.map +1 -0
- package/dist/search/dialog.d.ts +14 -0
- package/dist/search/dialog.d.ts.map +1 -0
- package/dist/search/dialog.js +17 -0
- package/dist/search/dialog.js.map +1 -0
- package/dist/search/language.d.ts +8 -0
- package/dist/search/language.d.ts.map +1 -0
- package/dist/search/language.js +30 -0
- package/dist/search/language.js.map +1 -0
- package/dist/search/route.d.ts +9 -0
- package/dist/search/route.d.ts.map +1 -0
- package/dist/search/route.js +11 -0
- package/dist/search/route.js.map +1 -0
- package/dist/seo/article.d.ts +84 -0
- package/dist/seo/article.d.ts.map +1 -0
- package/dist/seo/article.js +117 -0
- package/dist/seo/article.js.map +1 -0
- package/dist/seo/collection.d.ts +19 -0
- package/dist/seo/collection.d.ts.map +1 -0
- package/dist/seo/collection.js +30 -0
- package/dist/seo/collection.js.map +1 -0
- package/dist/seo/dataset.d.ts +31 -0
- package/dist/seo/dataset.d.ts.map +1 -0
- package/dist/seo/dataset.js +33 -0
- package/dist/seo/dataset.js.map +1 -0
- package/dist/seo/json-ld.d.ts +6 -0
- package/dist/seo/json-ld.d.ts.map +1 -0
- package/dist/seo/json-ld.js +8 -0
- package/dist/seo/json-ld.js.map +1 -0
- package/dist/seo/script-json.d.ts +8 -0
- package/dist/seo/script-json.d.ts.map +1 -0
- package/dist/seo/script-json.js +12 -0
- package/dist/seo/script-json.js.map +1 -0
- package/dist/seo/title.d.ts +11 -0
- package/dist/seo/title.d.ts.map +1 -0
- package/dist/seo/title.js +11 -0
- package/dist/seo/title.js.map +1 -0
- package/dist/seo/x-handle.d.ts +9 -0
- package/dist/seo/x-handle.d.ts.map +1 -0
- package/dist/seo/x-handle.js +21 -0
- package/dist/seo/x-handle.js.map +1 -0
- package/dist/site/app.d.ts +56 -0
- package/dist/site/app.d.ts.map +1 -0
- package/dist/site/app.js +79 -0
- package/dist/site/app.js.map +1 -0
- package/dist/site/features.d.ts +26 -0
- package/dist/site/features.d.ts.map +1 -0
- package/dist/site/features.js +46 -0
- package/dist/site/features.js.map +1 -0
- package/dist/site/metadata.d.ts +6 -0
- package/dist/site/metadata.d.ts.map +1 -0
- package/dist/site/metadata.js +78 -0
- package/dist/site/metadata.js.map +1 -0
- package/dist/site/outputs.d.ts +24 -0
- package/dist/site/outputs.d.ts.map +1 -0
- package/dist/site/outputs.js +113 -0
- package/dist/site/outputs.js.map +1 -0
- package/dist/site/posts.d.ts +6 -0
- package/dist/site/posts.d.ts.map +1 -0
- package/dist/site/posts.js +9 -0
- package/dist/site/posts.js.map +1 -0
- package/dist/site/routes.d.ts +43 -0
- package/dist/site/routes.d.ts.map +1 -0
- package/dist/site/routes.js +94 -0
- package/dist/site/routes.js.map +1 -0
- package/dist/site/site-page.d.ts +11 -0
- package/dist/site/site-page.d.ts.map +1 -0
- package/dist/site/site-page.js +70 -0
- package/dist/site/site-page.js.map +1 -0
- package/dist/site/sources.d.ts +58 -0
- package/dist/site/sources.d.ts.map +1 -0
- package/dist/site/sources.js +2 -0
- package/dist/site/sources.js.map +1 -0
- package/dist/site/url-style.d.ts +21 -0
- package/dist/site/url-style.d.ts.map +1 -0
- package/dist/site/url-style.js +18 -0
- package/dist/site/url-style.js.map +1 -0
- package/dist/website/blocks/commerce.d.ts +41 -0
- package/dist/website/blocks/commerce.d.ts.map +1 -0
- package/dist/website/blocks/commerce.js +26 -0
- package/dist/website/blocks/commerce.js.map +1 -0
- package/dist/website/blocks/content.d.ts +41 -0
- package/dist/website/blocks/content.d.ts.map +1 -0
- package/dist/website/blocks/content.js +25 -0
- package/dist/website/blocks/content.js.map +1 -0
- package/dist/website/blocks/marketing.d.ts +32 -0
- package/dist/website/blocks/marketing.d.ts.map +1 -0
- package/dist/website/blocks/marketing.js +23 -0
- package/dist/website/blocks/marketing.js.map +1 -0
- package/dist/website/blocks/parts.d.ts +26 -0
- package/dist/website/blocks/parts.d.ts.map +1 -0
- package/dist/website/blocks/parts.js +13 -0
- package/dist/website/blocks/parts.js.map +1 -0
- package/dist/website/page-view.d.ts +12 -0
- package/dist/website/page-view.d.ts.map +1 -0
- package/dist/website/page-view.js +10 -0
- package/dist/website/page-view.js.map +1 -0
- package/dist/zod.d.ts +8 -0
- package/dist/zod.d.ts.map +1 -0
- package/dist/zod.js +8 -0
- package/dist/zod.js.map +1 -0
- package/package.json +187 -3
- package/styles.css +326 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured data for blog posts and comparison pages, in the same shape the
|
|
3
|
+
* use-case pages emit: one JSON array of schema.org nodes.
|
|
4
|
+
*
|
|
5
|
+
* Every optional node is built from a frontmatter field the page also renders
|
|
6
|
+
* (the Questions section, the guide's H2 steps, the ranked table), so the
|
|
7
|
+
* markup and the page are one source and cannot disagree. Schema.org and the
|
|
8
|
+
* search engines that read it require exactly that.
|
|
9
|
+
*/
|
|
10
|
+
export type ArticleType = "BlogPosting" | "TechArticle";
|
|
11
|
+
export interface ArticleFaq {
|
|
12
|
+
readonly q: string;
|
|
13
|
+
readonly a: string;
|
|
14
|
+
}
|
|
15
|
+
export interface HowToStepRef {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly text: string;
|
|
18
|
+
/** Absolute URL of the section that carries the step. */
|
|
19
|
+
readonly url: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ListEntry {
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly url?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ArticleJsonLdInput {
|
|
26
|
+
readonly origin: string;
|
|
27
|
+
/** The organisation that publishes the site: the site identity's name. */
|
|
28
|
+
readonly publisher: string;
|
|
29
|
+
/** BCP-47 language of the page: the site identity's locale. */
|
|
30
|
+
readonly locale: string;
|
|
31
|
+
/** The name of the first breadcrumb, in the site's language. */
|
|
32
|
+
readonly homeLabel: string;
|
|
33
|
+
readonly pageUrl: string;
|
|
34
|
+
readonly type: ArticleType;
|
|
35
|
+
readonly title: string;
|
|
36
|
+
readonly description?: string;
|
|
37
|
+
readonly author: string;
|
|
38
|
+
/** Absolute URL of the page that introduces the author. */
|
|
39
|
+
readonly authorUrl: string;
|
|
40
|
+
readonly datePublished: Date;
|
|
41
|
+
readonly dateModified?: Date;
|
|
42
|
+
/** Site-relative cover image path. */
|
|
43
|
+
readonly image?: string;
|
|
44
|
+
/** The section the page belongs to, for the breadcrumb. */
|
|
45
|
+
readonly section: {
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly path: string;
|
|
48
|
+
};
|
|
49
|
+
/** A blog post's category: a breadcrumb level between the section and the page, and its articleSection. */
|
|
50
|
+
readonly category?: {
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly path: string;
|
|
53
|
+
};
|
|
54
|
+
readonly faqs?: ReadonlyArray<ArticleFaq>;
|
|
55
|
+
readonly howTo?: {
|
|
56
|
+
readonly name: string;
|
|
57
|
+
readonly steps: ReadonlyArray<HowToStepRef>;
|
|
58
|
+
};
|
|
59
|
+
readonly itemList?: {
|
|
60
|
+
readonly name: string;
|
|
61
|
+
readonly items: ReadonlyArray<ListEntry>;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** A FAQPage node; also used by /faq, whose questions render from the same array. */
|
|
65
|
+
export declare function faqNode(faqs: ReadonlyArray<ArticleFaq>): Record<string, unknown>;
|
|
66
|
+
export declare function articleJsonLd(input: ArticleJsonLdInput): string;
|
|
67
|
+
export interface HeadingAnchor {
|
|
68
|
+
readonly text: string;
|
|
69
|
+
/** The fragment, with its leading `#`. */
|
|
70
|
+
readonly url: string;
|
|
71
|
+
}
|
|
72
|
+
export declare class HowToHeadingError extends Error {
|
|
73
|
+
constructor(heading: string, page: string);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Resolve each step to the H2 that carries it. A step with no visible heading
|
|
77
|
+
* is a build error, not a silently dropped step: HowTo markup that points at
|
|
78
|
+
* nothing is the mismatch structured-data guidelines penalise.
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveHowToSteps(steps: ReadonlyArray<{
|
|
81
|
+
readonly heading: string;
|
|
82
|
+
readonly text: string;
|
|
83
|
+
}>, headings: ReadonlyArray<HeadingAnchor>, pageUrl: string): HowToStepRef[];
|
|
84
|
+
//# sourceMappingURL=article.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"article.d.ts","sourceRoot":"","sources":["../../src/seo/article.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,aAAa,CAAC;AAExD,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yDAAyD;IACzD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gEAAgE;IAChE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE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BAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,CAS/D;AAED,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,iBAAkB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAIzC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,aAAa,CAAC;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EACzE,QAAQ,EAAE,aAAa,CAAC,aAAa,CAAC,EACtC,OAAO,EAAE,MAAM,GACb,YAAY,EAAE,CAMhB"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured data for blog posts and comparison pages, in the same shape the
|
|
3
|
+
* use-case pages emit: one JSON array of schema.org nodes.
|
|
4
|
+
*
|
|
5
|
+
* Every optional node is built from a frontmatter field the page also renders
|
|
6
|
+
* (the Questions section, the guide's H2 steps, the ranked table), so the
|
|
7
|
+
* markup and the page are one source and cannot disagree. Schema.org and the
|
|
8
|
+
* search engines that read it require exactly that.
|
|
9
|
+
*/
|
|
10
|
+
function articleNode(input) {
|
|
11
|
+
const organization = { "@type": "Organization", name: input.publisher, url: input.origin };
|
|
12
|
+
return {
|
|
13
|
+
"@context": "https://schema.org",
|
|
14
|
+
"@type": input.type,
|
|
15
|
+
"@id": input.pageUrl,
|
|
16
|
+
headline: input.title,
|
|
17
|
+
description: input.description,
|
|
18
|
+
author: { "@type": "Person", name: input.author, url: input.authorUrl },
|
|
19
|
+
datePublished: input.datePublished.toISOString(),
|
|
20
|
+
dateModified: (input.dateModified ?? input.datePublished).toISOString(),
|
|
21
|
+
image: input.image ? `${input.origin}${input.image}` : undefined,
|
|
22
|
+
url: input.pageUrl,
|
|
23
|
+
mainEntityOfPage: input.pageUrl,
|
|
24
|
+
articleSection: input.category?.name,
|
|
25
|
+
inLanguage: input.locale,
|
|
26
|
+
publisher: organization,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function breadcrumbNode(input) {
|
|
30
|
+
// Every BreadcrumbList names its home page at "/", not the bare origin (SHIP-480).
|
|
31
|
+
const home = { name: input.homeLabel, path: "/" };
|
|
32
|
+
// A section at the site root is the home page itself, so it is not a level of its own.
|
|
33
|
+
const section = input.section.path === "/" ? [] : [input.section];
|
|
34
|
+
const trail = [home, ...section, ...(input.category ? [input.category] : [])].map((crumb) => ({
|
|
35
|
+
name: crumb.name,
|
|
36
|
+
item: `${input.origin}${crumb.path}`,
|
|
37
|
+
}));
|
|
38
|
+
return {
|
|
39
|
+
"@context": "https://schema.org",
|
|
40
|
+
"@type": "BreadcrumbList",
|
|
41
|
+
itemListElement: [...trail, { name: input.title, item: input.pageUrl }].map((crumb, index) => ({
|
|
42
|
+
"@type": "ListItem",
|
|
43
|
+
position: index + 1,
|
|
44
|
+
...crumb,
|
|
45
|
+
})),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** A FAQPage node; also used by /faq, whose questions render from the same array. */
|
|
49
|
+
export function faqNode(faqs) {
|
|
50
|
+
return {
|
|
51
|
+
"@context": "https://schema.org",
|
|
52
|
+
"@type": "FAQPage",
|
|
53
|
+
mainEntity: faqs.map((faq) => ({
|
|
54
|
+
"@type": "Question",
|
|
55
|
+
name: faq.q,
|
|
56
|
+
acceptedAnswer: { "@type": "Answer", text: faq.a },
|
|
57
|
+
})),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function howToNode(howTo) {
|
|
61
|
+
return {
|
|
62
|
+
"@context": "https://schema.org",
|
|
63
|
+
"@type": "HowTo",
|
|
64
|
+
name: howTo.name,
|
|
65
|
+
step: howTo.steps.map((step, index) => ({
|
|
66
|
+
"@type": "HowToStep",
|
|
67
|
+
position: index + 1,
|
|
68
|
+
name: step.name,
|
|
69
|
+
text: step.text,
|
|
70
|
+
url: step.url,
|
|
71
|
+
})),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function itemListNode(list) {
|
|
75
|
+
return {
|
|
76
|
+
"@context": "https://schema.org",
|
|
77
|
+
"@type": "ItemList",
|
|
78
|
+
name: list.name,
|
|
79
|
+
numberOfItems: list.items.length,
|
|
80
|
+
itemListElement: list.items.map((item, index) => ({
|
|
81
|
+
"@type": "ListItem",
|
|
82
|
+
position: index + 1,
|
|
83
|
+
name: item.name,
|
|
84
|
+
url: item.url,
|
|
85
|
+
})),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export function articleJsonLd(input) {
|
|
89
|
+
const nodes = [
|
|
90
|
+
articleNode(input),
|
|
91
|
+
breadcrumbNode(input),
|
|
92
|
+
...(input.faqs ? [faqNode(input.faqs)] : []),
|
|
93
|
+
...(input.howTo ? [howToNode(input.howTo)] : []),
|
|
94
|
+
...(input.itemList ? [itemListNode(input.itemList)] : []),
|
|
95
|
+
];
|
|
96
|
+
return JSON.stringify(nodes);
|
|
97
|
+
}
|
|
98
|
+
export class HowToHeadingError extends Error {
|
|
99
|
+
constructor(heading, page) {
|
|
100
|
+
super(`howTo step "${heading}" on ${page} has no matching H2. Step headings must equal a visible heading.`);
|
|
101
|
+
this.name = "HowToHeadingError";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Resolve each step to the H2 that carries it. A step with no visible heading
|
|
106
|
+
* is a build error, not a silently dropped step: HowTo markup that points at
|
|
107
|
+
* nothing is the mismatch structured-data guidelines penalise.
|
|
108
|
+
*/
|
|
109
|
+
export function resolveHowToSteps(steps, headings, pageUrl) {
|
|
110
|
+
return steps.map((step) => {
|
|
111
|
+
const match = headings.find((h) => h.text.trim() === step.heading.trim());
|
|
112
|
+
if (!match)
|
|
113
|
+
throw new HowToHeadingError(step.heading, pageUrl);
|
|
114
|
+
return { name: step.heading, text: step.text, url: `${pageUrl}${match.url}` };
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=article.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"article.js","sourceRoot":"","sources":["../../src/seo/article.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmDH,SAAS,WAAW,CAAC,KAAyB;IAC7C,MAAM,YAAY,GAAG,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;IAC3F,OAAO;QACN,UAAU,EAAE,oBAAoB;QAChC,OAAO,EAAE,KAAK,CAAC,IAAI;QACnB,KAAK,EAAE,KAAK,CAAC,OAAO;QACpB,QAAQ,EAAE,KAAK,CAAC,KAAK;QACrB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE;QACvE,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,EAAE;QAChD,YAAY,EAAE,CAAC,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE;QACvE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS;QAChE,GAAG,EAAE,KAAK,CAAC,OAAO;QAClB,gBAAgB,EAAE,KAAK,CAAC,OAAO;QAC/B,cAAc,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI;QACpC,UAAU,EAAE,KAAK,CAAC,MAAM;QACxB,SAAS,EAAE,YAAY;KACvB,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,KAAyB;IAChD,mFAAmF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**
|
|
2
|
+
* CollectionPage + ItemList + BreadcrumbList for listing pages (the blog index, each blog
|
|
3
|
+
* category, the comparison index), so an answer engine reads a listing as an ordered set of
|
|
4
|
+
* named pages at a known place in the site, instead of inferring either from card markup.
|
|
5
|
+
*/
|
|
6
|
+
export interface NamedLink {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly url: string;
|
|
9
|
+
}
|
|
10
|
+
export interface CollectionInput {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly description: string;
|
|
13
|
+
readonly url: string;
|
|
14
|
+
readonly items: ReadonlyArray<NamedLink>;
|
|
15
|
+
/** From the home page down to this listing, this listing last. */
|
|
16
|
+
readonly breadcrumbs: ReadonlyArray<NamedLink>;
|
|
17
|
+
}
|
|
18
|
+
export declare function collectionJsonLd(input: CollectionInput): string;
|
|
19
|
+
//# sourceMappingURL=collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../src/seo/collection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACzC,kEAAkE;IAClE,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CAC/C;AAMD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAoB/D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CollectionPage + ItemList + BreadcrumbList for listing pages (the blog index, each blog
|
|
3
|
+
* category, the comparison index), so an answer engine reads a listing as an ordered set of
|
|
4
|
+
* named pages at a known place in the site, instead of inferring either from card markup.
|
|
5
|
+
*/
|
|
6
|
+
function listItems(links, key) {
|
|
7
|
+
return links.map((link, index) => ({ "@type": "ListItem", position: index + 1, name: link.name, [key]: link.url }));
|
|
8
|
+
}
|
|
9
|
+
export function collectionJsonLd(input) {
|
|
10
|
+
return JSON.stringify([
|
|
11
|
+
{
|
|
12
|
+
"@context": "https://schema.org",
|
|
13
|
+
"@type": "CollectionPage",
|
|
14
|
+
name: input.name,
|
|
15
|
+
description: input.description,
|
|
16
|
+
url: input.url,
|
|
17
|
+
mainEntity: {
|
|
18
|
+
"@type": "ItemList",
|
|
19
|
+
numberOfItems: input.items.length,
|
|
20
|
+
itemListElement: listItems(input.items, "url"),
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"@context": "https://schema.org",
|
|
25
|
+
"@type": "BreadcrumbList",
|
|
26
|
+
itemListElement: listItems(input.breadcrumbs, "item"),
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../src/seo/collection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgBH,SAAS,SAAS,CAAC,KAA+B,EAAE,GAAmB;IACtE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACrH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAsB;IACtD,OAAO,IAAI,CAAC,SAAS,CAAC;QACrB;YACC,UAAU,EAAE,oBAAoB;YAChC,OAAO,EAAE,gBAAgB;YACzB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,GAAG,EAAE,KAAK,CAAC,GAAG;YACd,UAAU,EAAE;gBACX,OAAO,EAAE,UAAU;gBACnB,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM;gBACjC,eAAe,EAAE,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC;aAC9C;SACD;QACD;YACC,UAAU,EAAE,oBAAoB;YAChC,OAAO,EAAE,gBAAgB;YACzB,eAAe,EAAE,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC;SACrD;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** The frontmatter block a post carries when it publishes its underlying data. */
|
|
2
|
+
export interface PostDataset {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly description: string;
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly encodingFormat: string;
|
|
7
|
+
readonly variables: ReadonlyArray<string>;
|
|
8
|
+
readonly license?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface DatasetContext {
|
|
11
|
+
readonly origin: string;
|
|
12
|
+
/** The organisation that publishes the site: the site identity's name. */
|
|
13
|
+
readonly publisher: string;
|
|
14
|
+
/** The post the data belongs to, so the two are linked in both directions. */
|
|
15
|
+
readonly pageUrl: string;
|
|
16
|
+
readonly author: string;
|
|
17
|
+
readonly datePublished: Date;
|
|
18
|
+
/** The type the article node was emitted as, so `isPartOf` names the same entity. */
|
|
19
|
+
readonly articleType?: "BlogPosting" | "TechArticle";
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* schema.org Dataset for a post that publishes its data.
|
|
23
|
+
*
|
|
24
|
+
* This is the purpose-built mechanism for research data and the only route into
|
|
25
|
+
* Google Dataset Search. `distribution.contentUrl` has to be a real, fetchable
|
|
26
|
+
* URL - which is why the CSV is served by a route rather than manufactured in
|
|
27
|
+
* the browser - and `isPartOf` ties the file back to the article that explains
|
|
28
|
+
* it, so neither is orphaned.
|
|
29
|
+
*/
|
|
30
|
+
export declare function datasetJsonLd(dataset: PostDataset, ctx: DatasetContext): string;
|
|
31
|
+
//# sourceMappingURL=dataset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataset.d.ts","sourceRoot":"","sources":["../../src/seo/dataset.ts"],"names":[],"mappings":"AAEA,kFAAkF;AAClF,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC;IAC7B,qFAAqF;IACrF,QAAQ,CAAC,WAAW,CAAC,EAAE,aAAa,GAAG,aAAa,CAAC;CACrD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,cAAc,GAAG,MAAM,CAqB/E"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { stripInlineMarkdown } from "../markdown/inline.js";
|
|
2
|
+
/**
|
|
3
|
+
* schema.org Dataset for a post that publishes its data.
|
|
4
|
+
*
|
|
5
|
+
* This is the purpose-built mechanism for research data and the only route into
|
|
6
|
+
* Google Dataset Search. `distribution.contentUrl` has to be a real, fetchable
|
|
7
|
+
* URL - which is why the CSV is served by a route rather than manufactured in
|
|
8
|
+
* the browser - and `isPartOf` ties the file back to the article that explains
|
|
9
|
+
* it, so neither is orphaned.
|
|
10
|
+
*/
|
|
11
|
+
export function datasetJsonLd(dataset, ctx) {
|
|
12
|
+
return JSON.stringify({
|
|
13
|
+
"@context": "https://schema.org",
|
|
14
|
+
"@type": "Dataset",
|
|
15
|
+
name: stripInlineMarkdown(dataset.name),
|
|
16
|
+
description: stripInlineMarkdown(dataset.description),
|
|
17
|
+
url: ctx.pageUrl,
|
|
18
|
+
license: dataset.license,
|
|
19
|
+
creator: { "@type": "Person", name: ctx.author },
|
|
20
|
+
publisher: { "@type": "Organization", name: ctx.publisher, url: ctx.origin },
|
|
21
|
+
datePublished: ctx.datePublished.toISOString(),
|
|
22
|
+
isPartOf: { "@type": ctx.articleType ?? "BlogPosting", "@id": ctx.pageUrl },
|
|
23
|
+
variableMeasured: dataset.variables.map((v) => ({ "@type": "PropertyValue", name: v })),
|
|
24
|
+
distribution: [
|
|
25
|
+
{
|
|
26
|
+
"@type": "DataDownload",
|
|
27
|
+
encodingFormat: dataset.encodingFormat,
|
|
28
|
+
contentUrl: `${ctx.origin}${dataset.path}`,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=dataset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataset.js","sourceRoot":"","sources":["../../src/seo/dataset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAwB5D;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,OAAoB,EAAE,GAAmB;IACtE,OAAO,IA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,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,YAAY,CAGxE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { scriptJson } from "./script-json.js";
|
|
3
|
+
/** Structured data as a script element, escaped so no value in it can end the element. */
|
|
4
|
+
export function JsonLd({ json }) {
|
|
5
|
+
// biome-ignore lint/security/noDangerouslySetInnerHtml: JSON-LD, escaped for a script element by scriptJson
|
|
6
|
+
return _jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: scriptJson(json) } });
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=json-ld.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-ld.js","sourceRoot":"","sources":["../../src/seo/json-ld.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,0FAA0F;AAC1F,MAAM,UAAU,MAAM,CAAC,EAAE,IAAI,EAA6B;IACzD,4GAA4G;IAC5G,OAAO,iBAAQ,IAAI,EAAC,qBAAqB,EAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,GAAI,CAAC;AACrG,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON made safe to place inside a `<script>` element. Content on a site is written by its owner
|
|
3
|
+
* and by agents, so a title can hold `</script>` or `<!--`, which would end the element. Every
|
|
4
|
+
* less-than sign and both line separators become JSON unicode escapes, which every JSON parser
|
|
5
|
+
* reads back as the same characters.
|
|
6
|
+
*/
|
|
7
|
+
export declare function scriptJson(json: string): string;
|
|
8
|
+
//# sourceMappingURL=script-json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-json.d.ts","sourceRoot":"","sources":["../../src/seo/script-json.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** U+2028 and U+2029, which JavaScript reads as line ends inside a script. */
|
|
2
|
+
const LINE_SEPARATORS = /[\u2028\u2029]/g;
|
|
3
|
+
/**
|
|
4
|
+
* JSON made safe to place inside a `<script>` element. Content on a site is written by its owner
|
|
5
|
+
* and by agents, so a title can hold `</script>` or `<!--`, which would end the element. Every
|
|
6
|
+
* less-than sign and both line separators become JSON unicode escapes, which every JSON parser
|
|
7
|
+
* reads back as the same characters.
|
|
8
|
+
*/
|
|
9
|
+
export function scriptJson(json) {
|
|
10
|
+
return json.replace(/</g, "\\u003c").replace(LINE_SEPARATORS, (char) => `\\u${char.charCodeAt(0).toString(16)}`);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=script-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-json.js","sourceRoot":"","sources":["../../src/seo/script-json.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACtC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAClH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Roughly what a search result shows of a title before it cuts the end off. */
|
|
2
|
+
export declare const MAX_SEARCH_TITLE_LENGTH = 60;
|
|
3
|
+
/**
|
|
4
|
+
* A title for the layout's title template ("%s ~ Acme"). When the suffix would push it past what
|
|
5
|
+
* a search result shows, the title goes out on its own, so the cut never lands on the page's own
|
|
6
|
+
* words.
|
|
7
|
+
*/
|
|
8
|
+
export declare function searchTitle(title: string, template: string): string | {
|
|
9
|
+
absolute: string;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=title.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"title.d.ts","sourceRoot":"","sources":["../../src/seo/title.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAE1F"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Roughly what a search result shows of a title before it cuts the end off. */
|
|
2
|
+
export const MAX_SEARCH_TITLE_LENGTH = 60;
|
|
3
|
+
/**
|
|
4
|
+
* A title for the layout's title template ("%s ~ Acme"). When the suffix would push it past what
|
|
5
|
+
* a search result shows, the title goes out on its own, so the cut never lands on the page's own
|
|
6
|
+
* words.
|
|
7
|
+
*/
|
|
8
|
+
export function searchTitle(title, template) {
|
|
9
|
+
return template.replace("%s", () => title).length <= MAX_SEARCH_TITLE_LENGTH ? title : { absolute: title };
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=title.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"title.js","sourceRoot":"","sources":["../../src/seo/title.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,QAAgB;IAC1D,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,MAAM,IAAI,uBAAuB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAC5G,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** An X handle as `twitter:site` and `twitter:creator` print it: `@` and up to 15 letters, digits or `_`. */
|
|
2
|
+
export declare const X_HANDLE_PATTERN: RegExp;
|
|
3
|
+
/** A brand's `x` link that names no X account. */
|
|
4
|
+
export declare class XLinkError extends Error {
|
|
5
|
+
constructor(link: string);
|
|
6
|
+
}
|
|
7
|
+
/** The `@name` handle of a brand's `x` link: a profile URL or the handle itself. */
|
|
8
|
+
export declare function xHandleFromLink(link: string): string;
|
|
9
|
+
//# sourceMappingURL=x-handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x-handle.d.ts","sourceRoot":"","sources":["../../src/seo/x-handle.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAC7G,eAAO,MAAM,gBAAgB,QAA0B,CAAC;AAOxD,kDAAkD;AAClD,qBAAa,UAAW,SAAQ,KAAK;gBACxB,IAAI,EAAE,MAAM;CAMxB;AAED,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIpD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** An X handle as `twitter:site` and `twitter:creator` print it: `@` and up to 15 letters, digits or `_`. */
|
|
2
|
+
export const X_HANDLE_PATTERN = /^@[A-Za-z0-9_]{1,15}$/;
|
|
3
|
+
const NAME = "([A-Za-z0-9_]{1,15})";
|
|
4
|
+
// A profile URL on x.com or twitter.com, or the bare handle a DNA may hold instead.
|
|
5
|
+
const PROFILE_URL = new RegExp(`^https?://(?:www\\.)?(?:x|twitter)\\.com/${NAME}/?$`);
|
|
6
|
+
const BARE_HANDLE = new RegExp(`^@?${NAME}$`);
|
|
7
|
+
/** A brand's `x` link that names no X account. */
|
|
8
|
+
export class XLinkError extends Error {
|
|
9
|
+
constructor(link) {
|
|
10
|
+
super(`site identity: the brand's x link "${link}" is not an X profile. Set brand.links.x in the brand DNA to a URL like https://x.com/name, or to the handle.`);
|
|
11
|
+
this.name = "XLinkError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** The `@name` handle of a brand's `x` link: a profile URL or the handle itself. */
|
|
15
|
+
export function xHandleFromLink(link) {
|
|
16
|
+
const name = PROFILE_URL.exec(link)?.[1] ?? BARE_HANDLE.exec(link)?.[1];
|
|
17
|
+
if (!name)
|
|
18
|
+
throw new XLinkError(link);
|
|
19
|
+
return `@${name}`;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=x-handle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x-handle.js","sourceRoot":"","sources":["../../src/seo/x-handle.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAC7G,MAAM,CAAC,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAExD,MAAM,IAAI,GAAG,sBAAsB,CAAC;AACpC,oFAAoF;AACpF,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,4CAA4C,IAAI,KAAK,CAAC,CAAC;AACtF,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;AAE9C,kDAAkD;AAClD,MAAM,OAAO,UAAW,SAAQ,KAAK;IACpC,YAAY,IAAY;QACvB,KAAK,CACJ,sCAAsC,IAAI,+GAA+G,CACzJ,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC1B,CAAC;CACD;AAED,oFAAoF;AACpF,MAAM,UAAU,eAAe,CAAC,IAAY;IAC3C,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxE,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,IAAI,IAAI,EAAE,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { MDXComponents } from "mdx/types";
|
|
2
|
+
import { type BlogSite } from "../blog/site.js";
|
|
3
|
+
import { type SiteContext } from "../config/context.js";
|
|
4
|
+
import type { SiteIdentity } from "../config/identity.js";
|
|
5
|
+
import type { SiteConfig } from "../config/site-config.js";
|
|
6
|
+
import { type RouteRow, type SiteRoute } from "./routes.js";
|
|
7
|
+
import type { SiteSources } from "./sources.js";
|
|
8
|
+
import { type UrlPaths, type UrlStyle } from "./url-style.js";
|
|
9
|
+
/**
|
|
10
|
+
* A whole site, resolved once: its context, its blog (when the config turns one on), its URL style,
|
|
11
|
+
* its MDX components and every route. A template builds one in `lib/site.ts`, and its catch-all
|
|
12
|
+
* page, metadata and file routes all read from it.
|
|
13
|
+
*/
|
|
14
|
+
export interface SiteApp {
|
|
15
|
+
readonly context: SiteContext;
|
|
16
|
+
readonly blog: BlogSite | null;
|
|
17
|
+
readonly urls: UrlPaths;
|
|
18
|
+
readonly sources: SiteSources;
|
|
19
|
+
readonly components: MDXComponents;
|
|
20
|
+
readonly rows: readonly RouteRow[];
|
|
21
|
+
}
|
|
22
|
+
export interface SiteAppInput {
|
|
23
|
+
readonly config: SiteConfig;
|
|
24
|
+
readonly identity: SiteIdentity;
|
|
25
|
+
readonly sources: SiteSources;
|
|
26
|
+
/** The site's own MDX components, which site.config.ts names in `mdxComponents`. */
|
|
27
|
+
readonly components: MDXComponents;
|
|
28
|
+
readonly style: UrlStyle;
|
|
29
|
+
}
|
|
30
|
+
/** A site component that site.config.ts does not name, or the other way round. */
|
|
31
|
+
export declare class SiteComponentsError extends Error {
|
|
32
|
+
constructor(missing: readonly string[], unnamed: readonly string[]);
|
|
33
|
+
}
|
|
34
|
+
/** A site whose sections leave `/` empty: the header, the social card and every visitor's first request go there. */
|
|
35
|
+
export declare class SiteRootError extends Error {
|
|
36
|
+
constructor();
|
|
37
|
+
}
|
|
38
|
+
export declare function createSiteApp(input: SiteAppInput): SiteApp;
|
|
39
|
+
/**
|
|
40
|
+
* A route with no path to build. A static export refuses such a route with an error that names
|
|
41
|
+
* neither the content nor the fix, so the engine stops first with one that does.
|
|
42
|
+
*/
|
|
43
|
+
export declare class EmptyRouteError extends Error {
|
|
44
|
+
constructor(route: string, remedy: string);
|
|
45
|
+
}
|
|
46
|
+
/** `generateStaticParams` of the catch-all page `app/[[...slug]]/page.tsx`. */
|
|
47
|
+
export declare function staticParams(app: SiteApp): Array<{
|
|
48
|
+
slug: string[];
|
|
49
|
+
}>;
|
|
50
|
+
/** The route at a catch-all page's params (Next decodes them); the site root comes as `undefined`. */
|
|
51
|
+
export declare function routeAt(app: SiteApp, slug: readonly string[] | undefined): SiteRoute | undefined;
|
|
52
|
+
/** A row's path in the site's URL style. */
|
|
53
|
+
export declare function rowPath(app: SiteApp, row: RouteRow): string;
|
|
54
|
+
/** The blog of a route that needs one: the table only has blog routes when the config has a blog. */
|
|
55
|
+
export declare function requireBlog(app: SiteApp): BlogSite;
|
|
56
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/site/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAoB,KAAK,QAAQ,EAAY,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAa,KAAK,QAAQ,EAAyB,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EA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SAAS,CAEhG;AAED,4CAA4C;AAC5C,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,GAAG,MAAM,CAE3D;AAED,qGAAqG;AACrG,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,QAAQ,CAGlD"}
|
package/dist/site/app.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { BlogSectionError, blogSite } from "../blog/site.js";
|
|
2
|
+
import { siteContext } from "../config/context.js";
|
|
3
|
+
import { siteMdxComponents } from "../mdx/components.js";
|
|
4
|
+
import { findRoute, routePath, routeTable } from "./routes.js";
|
|
5
|
+
import { urlPaths } from "./url-style.js";
|
|
6
|
+
/** A site component that site.config.ts does not name, or the other way round. */
|
|
7
|
+
export class SiteComponentsError extends Error {
|
|
8
|
+
constructor(missing, unnamed) {
|
|
9
|
+
const parts = [
|
|
10
|
+
...(missing.length > 0
|
|
11
|
+
? [`site.config.ts names ${missing.join(", ")} in mdxComponents, but the template passes no such component`]
|
|
12
|
+
: []),
|
|
13
|
+
...(unnamed.length > 0
|
|
14
|
+
? [`the template passes ${unnamed.join(", ")}, which site.config.ts does not name in mdxComponents`]
|
|
15
|
+
: []),
|
|
16
|
+
];
|
|
17
|
+
super(`site: ${parts.join("; ")}`);
|
|
18
|
+
this.name = "SiteComponentsError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** The config's list is what the content check allows, so it must name exactly what the template renders. */
|
|
22
|
+
function checkComponents(config, components) {
|
|
23
|
+
const given = Object.keys(components);
|
|
24
|
+
const missing = config.mdxComponents.filter((name) => !given.includes(name));
|
|
25
|
+
const unnamed = given.filter((name) => !config.mdxComponents.includes(name));
|
|
26
|
+
if (missing.length > 0 || unnamed.length > 0)
|
|
27
|
+
throw new SiteComponentsError(missing, unnamed);
|
|
28
|
+
}
|
|
29
|
+
/** A site whose sections leave `/` empty: the header, the social card and every visitor's first request go there. */
|
|
30
|
+
export class SiteRootError extends Error {
|
|
31
|
+
constructor() {
|
|
32
|
+
super("site: no page is at /. Set one section's path to / in site.config.ts, or add an index page to the website at /");
|
|
33
|
+
this.name = "SiteRootError";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function createSiteApp(input) {
|
|
37
|
+
checkComponents(input.config, input.components);
|
|
38
|
+
const rows = routeTable(input.config, input.sources);
|
|
39
|
+
if (!rows.some((row) => row.segments.length === 0))
|
|
40
|
+
throw new SiteRootError();
|
|
41
|
+
return {
|
|
42
|
+
context: siteContext(input.config, input.identity),
|
|
43
|
+
blog: input.config.sections.blog ? blogSite(input.config, input.identity, input.style) : null,
|
|
44
|
+
urls: urlPaths(input.style),
|
|
45
|
+
sources: input.sources,
|
|
46
|
+
components: siteMdxComponents(input.components),
|
|
47
|
+
rows,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A route with no path to build. A static export refuses such a route with an error that names
|
|
52
|
+
* neither the content nor the fix, so the engine stops first with one that does.
|
|
53
|
+
*/
|
|
54
|
+
export class EmptyRouteError extends Error {
|
|
55
|
+
constructor(route, remedy) {
|
|
56
|
+
super(`site: ${route} has no page to build; ${remedy}`);
|
|
57
|
+
this.name = "EmptyRouteError";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** `generateStaticParams` of the catch-all page `app/[[...slug]]/page.tsx`. */
|
|
61
|
+
// Never empty: createSiteApp refuses a site without a page at /.
|
|
62
|
+
export function staticParams(app) {
|
|
63
|
+
return app.rows.map((row) => ({ slug: [...row.segments] }));
|
|
64
|
+
}
|
|
65
|
+
/** The route at a catch-all page's params (Next decodes them); the site root comes as `undefined`. */
|
|
66
|
+
export function routeAt(app, slug) {
|
|
67
|
+
return findRoute(app.rows, slug ?? []);
|
|
68
|
+
}
|
|
69
|
+
/** A row's path in the site's URL style. */
|
|
70
|
+
export function rowPath(app, row) {
|
|
71
|
+
return app.urls.page(routePath(row));
|
|
72
|
+
}
|
|
73
|
+
/** The blog of a route that needs one: the table only has blog routes when the config has a blog. */
|
|
74
|
+
export function requireBlog(app) {
|
|
75
|
+
if (!app.blog)
|
|
76
|
+
throw new BlogSectionError();
|
|
77
|
+
return app.blog;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/site/app.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAiB,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAoB,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAiB,SAAS,EAAE,UAAU,EAAkB,MAAM,aAAa,CAAC;AAE9F,OAAO,EAAgC,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAyBxE,kFAAkF;AAClF,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC7C,YAAY,OAA0B,EAAE,OAA0B;QACjE,MAAM,KAAK,GAAG;YACb,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;gBACrB,CAAC,CAAC,CAAC,wBAAwB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,8DAA8D,CAAC;gBAC5G,CAAC,CAAC,EAAE,CAAC;YACN,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;gBACrB,CAAC,CAAC,CAAC,uBAAuB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,uDAAuD,CAAC;gBACpG,CAAC,CAAC,EAAE,CAAC;SACN,CAAC;QACF,KAAK,CAAC,SAAS,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACnC,CAAC;CACD;AAED,6GAA6G;AAC7G,SAAS,eAAe,CAAC,MAAkB,EAAE,UAAyB;IACrE,MA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