nimbus-docs 0.0.3 → 0.1.1
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/cli/index.js +31 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +4 -3
- package/dist/client.js.map +1 -1
- package/dist/content.d.ts +36 -1
- package/dist/content.d.ts.map +1 -1
- package/dist/content.js +19 -2
- package/dist/content.js.map +1 -1
- package/dist/index.d.ts +289 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1103 -52
- package/dist/index.js.map +1 -1
- package/dist/schemas.d.ts +24 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +17 -2
- package/dist/schemas.js.map +1 -1
- package/dist/types.d.ts +118 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/components/NimbusHead.astro +81 -2
package/dist/schemas.d.ts
CHANGED
|
@@ -79,6 +79,7 @@ declare function defineDocSchema(config?: DocSchemaConfig): z.ZodObject<{
|
|
|
79
79
|
link: z.ZodOptional<z.ZodString>;
|
|
80
80
|
label: z.ZodOptional<z.ZodString>;
|
|
81
81
|
}, z.core.$strip>, z.ZodLiteral<false>]>>;
|
|
82
|
+
previousSlug: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
82
83
|
}, z.core.$strip> | z.ZodObject<{
|
|
83
84
|
[x: string]: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
84
85
|
}, z.core.$strip>;
|
|
@@ -152,6 +153,7 @@ declare const docsSchema: z.ZodObject<{
|
|
|
152
153
|
link: z.ZodOptional<z.ZodString>;
|
|
153
154
|
label: z.ZodOptional<z.ZodString>;
|
|
154
155
|
}, z.core.$strip>, z.ZodLiteral<false>]>>;
|
|
156
|
+
previousSlug: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
155
157
|
}, z.core.$strip> | z.ZodObject<{
|
|
156
158
|
[x: string]: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
157
159
|
}, z.core.$strip>;
|
|
@@ -159,6 +161,27 @@ declare const docsSchema: z.ZodObject<{
|
|
|
159
161
|
declare const partialsSchema: z.ZodDefault<z.ZodObject<{
|
|
160
162
|
params: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
161
163
|
}, z.core.$strip>>;
|
|
164
|
+
/** One row in a component's `props` frontmatter array. */
|
|
165
|
+
declare const componentPropSchema: z.ZodObject<{
|
|
166
|
+
name: z.ZodString;
|
|
167
|
+
type: z.ZodString;
|
|
168
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
169
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
170
|
+
description: z.ZodString;
|
|
171
|
+
}, z.core.$strip>;
|
|
172
|
+
type ComponentProp = z.infer<typeof componentPropSchema>;
|
|
173
|
+
/** Default schema for the components collection. */
|
|
174
|
+
declare const componentsSchema: z.ZodObject<{
|
|
175
|
+
title: z.ZodString;
|
|
176
|
+
tagline: z.ZodString;
|
|
177
|
+
props: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
178
|
+
name: z.ZodString;
|
|
179
|
+
type: z.ZodString;
|
|
180
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
181
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
182
|
+
description: z.ZodString;
|
|
183
|
+
}, z.core.$strip>>>;
|
|
184
|
+
}, z.core.$strip>;
|
|
162
185
|
//#endregion
|
|
163
|
-
export { DocSchemaConfig, defineDocSchema, docsSchema, partialsSchema };
|
|
186
|
+
export { ComponentProp, DocSchemaConfig, componentsSchema, defineDocSchema, docsSchema, partialsSchema };
|
|
164
187
|
//# sourceMappingURL=schemas.d.ts.map
|
package/dist/schemas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","names":[],"sources":["../src/schemas.ts"],"mappings":";;;UAgBiB,eAAA;;EAEf,MAAA,GAAS,MAAA,SAAe,CAAA,CAAE,UAAA;AAAA;;;;;;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","names":[],"sources":["../src/schemas.ts"],"mappings":";;;UAgBiB,eAAA;;EAEf,MAAA,GAAS,MAAA,SAAe,CAAA,CAAE,UAAA;AAAA;;;;;;iBA2KZ,eAAA,CAAgB,MAAA,GAAQ,eAAA,GAAoB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAS/C,UAAA,EAAU,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAGV,cAAA,EAAc,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,SAAA;;;;cAkBrB,mBAAA,EAAmB,CAAA,CAAA,SAAA;;;;;;;KAQb,aAAA,GAAgB,CAAA,CAAE,KAAA,QAAa,mBAAA;;cAG9B,gBAAA,EAAgB,CAAA,CAAA,SAAA"}
|
package/dist/schemas.js
CHANGED
|
@@ -87,7 +87,8 @@ function baseDocSchema() {
|
|
|
87
87
|
lastUpdated: z.coerce.date({ error: "\"lastUpdated\" must be a valid date (e.g. 2024-01-15)" }).optional(),
|
|
88
88
|
socialImage: z.string({ error: "\"socialImage\" must be a string (path or URL)" }).optional(),
|
|
89
89
|
prev: prevNextFrontmatterSchema,
|
|
90
|
-
next: prevNextFrontmatterSchema
|
|
90
|
+
next: prevNextFrontmatterSchema,
|
|
91
|
+
previousSlug: z.union([z.string(), z.array(z.string())], { error: "\"previousSlug\" must be a string or array of strings" }).optional()
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
@@ -104,7 +105,21 @@ function defineDocSchema(config = {}) {
|
|
|
104
105
|
const docsSchema = defineDocSchema();
|
|
105
106
|
/** Schema for partials (`<Render file="..." />` snippets). */
|
|
106
107
|
const partialsSchema = z.object({ params: z.array(z.string()).optional() }).default({});
|
|
108
|
+
/** One row in a component's `props` frontmatter array. */
|
|
109
|
+
const componentPropSchema = z.object({
|
|
110
|
+
name: z.string({ error: "prop needs a \"name\"" }),
|
|
111
|
+
type: z.string({ error: "prop needs a \"type\"" }),
|
|
112
|
+
defaultValue: z.string().optional(),
|
|
113
|
+
required: z.boolean().default(false),
|
|
114
|
+
description: z.string({ error: "prop needs a \"description\"" })
|
|
115
|
+
});
|
|
116
|
+
/** Default schema for the components collection. */
|
|
117
|
+
const componentsSchema = z.object({
|
|
118
|
+
title: z.string({ error: (iss) => iss.input === void 0 ? "Missing \"title\" in frontmatter — display name used in the sidebar and page header." : `"title" must be a string, received ${typeof iss.input}` }),
|
|
119
|
+
tagline: z.string({ error: (iss) => iss.input === void 0 ? "Missing \"tagline\" in frontmatter — one-sentence summary shown under the title." : `"tagline" must be a string, received ${typeof iss.input}` }),
|
|
120
|
+
props: z.array(componentPropSchema).default([])
|
|
121
|
+
});
|
|
107
122
|
|
|
108
123
|
//#endregion
|
|
109
|
-
export { defineDocSchema, docsSchema, partialsSchema };
|
|
124
|
+
export { componentsSchema, defineDocSchema, docsSchema, partialsSchema };
|
|
110
125
|
//# sourceMappingURL=schemas.js.map
|
package/dist/schemas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","names":[],"sources":["../src/schemas.ts"],"sourcesContent":["/**\n * Content schemas for Nimbus.\n *\n * `docsSchema` is the default frontmatter contract for the `docs` collection.\n * `partialsSchema` is the contract for `<Render file=\"...\" />` partials.\n * `defineDocSchema(config)` returns a customizable schema for advanced users\n * composing schemas outside the `docsCollection()` factory.\n *\n * Error messages target content authors, not framework developers.\n * Astro 6 ships Zod v4 via `astro/zod`. The v4 API uses a single `error`\n * field on every schema constructor — NOT v3's `required_error` /\n * `invalid_type_error` / `errorMap`.\n */\n\nimport { z } from \"astro/zod\";\n\nexport interface DocSchemaConfig {\n /** Additional frontmatter fields merged into the default schema. */\n fields?: Record<string, z.ZodTypeAny>;\n}\n\n// ---------------------------------------------------------------------------\n// Building blocks\n// ---------------------------------------------------------------------------\n\nconst sidebarBadgeSchema = z.union([\n z.string(),\n z.object({\n text: z.string({ error: 'sidebar badge needs a \"text\" field' }),\n variant: z\n .enum(\n [\"default\", \"info\", \"note\", \"success\", \"tip\", \"warning\", \"caution\", \"danger\"],\n {\n error:\n '\"variant\" must be one of: default, info, note, success, tip, warning, caution, danger',\n },\n )\n .default(\"default\"),\n }),\n]);\n\nconst sidebarFrontmatterSchema = z\n .object({\n order: z.number({ error: '\"sidebar.order\" must be a number' }).optional(),\n label: z.string({ error: '\"sidebar.label\" must be a string' }).optional(),\n badge: sidebarBadgeSchema.optional(),\n hidden: z.boolean({ error: '\"sidebar.hidden\" must be true or false' }).optional(),\n hideChildren: z\n .boolean({ error: '\"sidebar.hideChildren\" must be true or false' })\n .optional(),\n })\n .optional();\n\nconst heroActionSchema = z.object({\n text: z.string({ error: 'hero action needs a \"text\" field' }),\n link: z.string({ error: 'hero action needs a \"link\" field' }),\n variant: z\n .enum([\"primary\", \"secondary\", \"outline\"], {\n error: 'hero action \"variant\" must be \"primary\", \"secondary\", or \"outline\"',\n })\n .default(\"primary\"),\n icon: z.string().optional(),\n});\n\nconst heroSchema = z\n .object({\n title: z.string().optional(),\n tagline: z.string().optional(),\n actions: z.array(heroActionSchema).optional(),\n })\n .optional();\n\nconst prevNextFrontmatterSchema = z\n .union([\n z.string(),\n z.object({ link: z.string().optional(), label: z.string().optional() }),\n z.literal(false),\n ])\n .optional();\n\nconst headElementSchema = z.object({\n tag: z.enum([\"meta\", \"link\", \"script\", \"style\"], {\n error: 'head element \"tag\" must be \"meta\", \"link\", \"script\", or \"style\"',\n }),\n attrs: z.record(z.string(), z.string()).default({}),\n content: z.string().optional(),\n});\n\n// ---------------------------------------------------------------------------\n// Base docs schema\n// ---------------------------------------------------------------------------\n\nfunction baseDocSchema() {\n return z.object({\n title: z.string({\n error: (iss) =>\n iss.input === undefined\n ? 'Missing required \"title\" in frontmatter. Every doc needs:\\n\\n ---\\n title: \"Your Page Title\"\\n ---'\n : `\"title\" must be a string, received ${typeof iss.input}`,\n }),\n description: z.string({ error: '\"description\" must be a string' }).optional(),\n template: z\n .enum([\"doc\", \"splash\"], {\n error: '\"template\" must be \"doc\" or \"splash\"',\n })\n .default(\"doc\"),\n sidebar: sidebarFrontmatterSchema,\n hero: heroSchema,\n head: z.array(headElementSchema).default([]),\n draft: z.boolean({ error: '\"draft\" must be true or false' }).default(false),\n noindex: z.boolean({ error: '\"noindex\" must be true or false' }).default(false),\n /** Include this page in llms.txt and AI consumption indexes */\n llms: z.boolean({ error: '\"llms\" must be true or false' }).default(true),\n /** Signal AI crawlers to deprioritize this page */\n aiDeprioritize: z\n .boolean({ error: '\"aiDeprioritize\" must be true or false' })\n .default(false),\n pagefind: z.boolean({ error: '\"pagefind\" must be true or false' }).default(true),\n tableOfContents: z\n .object({\n minHeadingLevel: z\n .number({ error: '\"minHeadingLevel\" must be a number (1-6)' })\n .int()\n .min(1)\n .max(6)\n .default(2),\n maxHeadingLevel: z\n .number({ error: '\"maxHeadingLevel\" must be a number (1-6)' })\n .int()\n .min(1)\n .max(6)\n .default(3),\n })\n .refine((v) => v.minHeadingLevel <= v.maxHeadingLevel, {\n message: \"minHeadingLevel must be <= maxHeadingLevel\",\n })\n .optional(),\n lastUpdated: z.coerce\n .date({ error: '\"lastUpdated\" must be a valid date (e.g. 2024-01-15)' })\n .optional(),\n /**\n * Explicit per-page social/OG image override (path or absolute URL).\n * When omitted, the page route is expected to fall back to a\n * programmatically-generated card or the site-wide `config.socialImage`.\n */\n socialImage: z\n .string({ error: '\"socialImage\" must be a string (path or URL)' })\n .optional(),\n prev: prevNextFrontmatterSchema,\n next: prevNextFrontmatterSchema,\n });\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Build a customizable docs schema. Use this when composing schemas outside\n * the `docsCollection()` factory (e.g. multiple docs collections with\n * different shapes).\n */\nexport function defineDocSchema(config: DocSchemaConfig = {}) {\n const base = baseDocSchema();\n if (config.fields) {\n return base.extend(config.fields);\n }\n return base;\n}\n\n/** Default docs schema. Equivalent to `defineDocSchema()`. */\nexport const docsSchema = defineDocSchema();\n\n/** Schema for partials (`<Render file=\"...\" />` snippets). */\nexport const partialsSchema = z\n .object({\n /**\n * Declared parameters this partial accepts.\n * Suffix with `?` for optional params: `[\"name\", \"deprecated?\"]`\n */\n params: z.array(z.string()).optional(),\n })\n .default({});\n"],"mappings":";;;;;;;;;;;;;;;;AAyBA,MAAM,qBAAqB,EAAE,MAAM,CACjC,EAAE,QAAQ,EACV,EAAE,OAAO;CACP,MAAM,EAAE,OAAO,EAAE,OAAO,wCAAsC,CAAC;CAC/D,SAAS,EACN,KACC;EAAC;EAAW;EAAQ;EAAQ;EAAW;EAAO;EAAW;EAAW;EAAS,EAC7E,EACE,OACE,2FACH,CACF,CACA,QAAQ,UAAU;CACtB,CAAC,CACH,CAAC;AAEF,MAAM,2BAA2B,EAC9B,OAAO;CACN,OAAO,EAAE,OAAO,EAAE,OAAO,sCAAoC,CAAC,CAAC,UAAU;CACzE,OAAO,EAAE,OAAO,EAAE,OAAO,sCAAoC,CAAC,CAAC,UAAU;CACzE,OAAO,mBAAmB,UAAU;CACpC,QAAQ,EAAE,QAAQ,EAAE,OAAO,4CAA0C,CAAC,CAAC,UAAU;CACjF,cAAc,EACX,QAAQ,EAAE,OAAO,kDAAgD,CAAC,CAClE,UAAU;CACd,CAAC,CACD,UAAU;AAEb,MAAM,mBAAmB,EAAE,OAAO;CAChC,MAAM,EAAE,OAAO,EAAE,OAAO,sCAAoC,CAAC;CAC7D,MAAM,EAAE,OAAO,EAAE,OAAO,sCAAoC,CAAC;CAC7D,SAAS,EACN,KAAK;EAAC;EAAW;EAAa;EAAU,EAAE,EACzC,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MAAM;EAE/E,MAAM,EAAE,QAAQ,EAAE,OAAO,kCAAgC,CAAC,CAAC,QAAQ,KAAK;EAExE,gBAAgB,EACb,QAAQ,EAAE,OAAO,4CAA0C,CAAC,CAC5D,QAAQ,MAAM;EACjB,UAAU,EAAE,QAAQ,EAAE,OAAO,sCAAoC,CAAC,CAAC,QAAQ,KAAK;EAChF,iBAAiB,EACd,OAAO;GACN,iBAAiB,EACd,OAAO,EAAE,OAAO,8CAA4C,CAAC,CAC7D,KAAK,CACL,IAAI,EAAE,CACN,IAAI,EAAE,CACN,QAAQ,EAAE;GACb,iBAAiB,EACd,OAAO,EAAE,OAAO,8CAA4C,CAAC,CAC7D,KAAK,CACL,IAAI,EAAE,CACN,IAAI,EAAE,CACN,QAAQ,EAAE;GACd,CAAC,CACD,QAAQ,MAAM,EAAE,mBAAmB,EAAE,iBAAiB,EACrD,SAAS,8CACV,CAAC,CACD,UAAU;EACb,aAAa,EAAE,OACZ,KAAK,EAAE,OAAO,0DAAwD,CAAC,CACvE,UAAU;EAMb,aAAa,EACV,OAAO,EAAE,OAAO,kDAAgD,CAAC,CACjE,UAAU;EACb,MAAM;EACN,MAAM;EACP,CAAC;;;;;;;AAYJ,SAAgB,gBAAgB,SAA0B,EAAE,EAAE;CAC5D,MAAM,OAAO,eAAe;AAC5B,KAAI,OAAO,OACT,QAAO,KAAK,OAAO,OAAO,OAAO;AAEnC,QAAO;;;AAIT,MAAa,aAAa,iBAAiB;;AAG3C,MAAa,iBAAiB,EAC3B,OAAO,EAKN,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU,EACvC,CAAC,CACD,QAAQ,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"schemas.js","names":[],"sources":["../src/schemas.ts"],"sourcesContent":["/**\n * Content schemas for Nimbus.\n *\n * `docsSchema` is the default frontmatter contract for the `docs` collection.\n * `partialsSchema` is the contract for `<Render file=\"...\" />` partials.\n * `defineDocSchema(config)` returns a customizable schema for advanced users\n * composing schemas outside the `docsCollection()` factory.\n *\n * Error messages target content authors, not framework developers.\n * Astro 6 ships Zod v4 via `astro/zod`. The v4 API uses a single `error`\n * field on every schema constructor — NOT v3's `required_error` /\n * `invalid_type_error` / `errorMap`.\n */\n\nimport { z } from \"astro/zod\";\n\nexport interface DocSchemaConfig {\n /** Additional frontmatter fields merged into the default schema. */\n fields?: Record<string, z.ZodTypeAny>;\n}\n\n// ---------------------------------------------------------------------------\n// Building blocks\n// ---------------------------------------------------------------------------\n\nconst sidebarBadgeSchema = z.union([\n z.string(),\n z.object({\n text: z.string({ error: 'sidebar badge needs a \"text\" field' }),\n variant: z\n .enum(\n [\"default\", \"info\", \"note\", \"success\", \"tip\", \"warning\", \"caution\", \"danger\"],\n {\n error:\n '\"variant\" must be one of: default, info, note, success, tip, warning, caution, danger',\n },\n )\n .default(\"default\"),\n }),\n]);\n\nconst sidebarFrontmatterSchema = z\n .object({\n order: z.number({ error: '\"sidebar.order\" must be a number' }).optional(),\n label: z.string({ error: '\"sidebar.label\" must be a string' }).optional(),\n badge: sidebarBadgeSchema.optional(),\n hidden: z.boolean({ error: '\"sidebar.hidden\" must be true or false' }).optional(),\n hideChildren: z\n .boolean({ error: '\"sidebar.hideChildren\" must be true or false' })\n .optional(),\n })\n .optional();\n\nconst heroActionSchema = z.object({\n text: z.string({ error: 'hero action needs a \"text\" field' }),\n link: z.string({ error: 'hero action needs a \"link\" field' }),\n variant: z\n .enum([\"primary\", \"secondary\", \"outline\"], {\n error: 'hero action \"variant\" must be \"primary\", \"secondary\", or \"outline\"',\n })\n .default(\"primary\"),\n icon: z.string().optional(),\n});\n\nconst heroSchema = z\n .object({\n title: z.string().optional(),\n tagline: z.string().optional(),\n actions: z.array(heroActionSchema).optional(),\n })\n .optional();\n\nconst prevNextFrontmatterSchema = z\n .union([\n z.string(),\n z.object({ link: z.string().optional(), label: z.string().optional() }),\n z.literal(false),\n ])\n .optional();\n\nconst headElementSchema = z.object({\n tag: z.enum([\"meta\", \"link\", \"script\", \"style\"], {\n error: 'head element \"tag\" must be \"meta\", \"link\", \"script\", or \"style\"',\n }),\n attrs: z.record(z.string(), z.string()).default({}),\n content: z.string().optional(),\n});\n\n// ---------------------------------------------------------------------------\n// Base docs schema\n// ---------------------------------------------------------------------------\n\nfunction baseDocSchema() {\n return z.object({\n title: z.string({\n error: (iss) =>\n iss.input === undefined\n ? 'Missing required \"title\" in frontmatter. Every doc needs:\\n\\n ---\\n title: \"Your Page Title\"\\n ---'\n : `\"title\" must be a string, received ${typeof iss.input}`,\n }),\n description: z.string({ error: '\"description\" must be a string' }).optional(),\n template: z\n .enum([\"doc\", \"splash\"], {\n error: '\"template\" must be \"doc\" or \"splash\"',\n })\n .default(\"doc\"),\n sidebar: sidebarFrontmatterSchema,\n hero: heroSchema,\n head: z.array(headElementSchema).default([]),\n draft: z.boolean({ error: '\"draft\" must be true or false' }).default(false),\n noindex: z.boolean({ error: '\"noindex\" must be true or false' }).default(false),\n /** Include this page in llms.txt and AI consumption indexes */\n llms: z.boolean({ error: '\"llms\" must be true or false' }).default(true),\n /** Signal AI crawlers to deprioritize this page */\n aiDeprioritize: z\n .boolean({ error: '\"aiDeprioritize\" must be true or false' })\n .default(false),\n pagefind: z.boolean({ error: '\"pagefind\" must be true or false' }).default(true),\n tableOfContents: z\n .object({\n minHeadingLevel: z\n .number({ error: '\"minHeadingLevel\" must be a number (1-6)' })\n .int()\n .min(1)\n .max(6)\n .default(2),\n maxHeadingLevel: z\n .number({ error: '\"maxHeadingLevel\" must be a number (1-6)' })\n .int()\n .min(1)\n .max(6)\n .default(3),\n })\n .refine((v) => v.minHeadingLevel <= v.maxHeadingLevel, {\n message: \"minHeadingLevel must be <= maxHeadingLevel\",\n })\n .optional(),\n lastUpdated: z.coerce\n .date({ error: '\"lastUpdated\" must be a valid date (e.g. 2024-01-15)' })\n .optional(),\n /**\n * Explicit per-page social/OG image override (path or absolute URL).\n * When omitted, the page route is expected to fall back to a\n * programmatically-generated card or the site-wide `config.socialImage`.\n */\n socialImage: z\n .string({ error: '\"socialImage\" must be a string (path or URL)' })\n .optional(),\n prev: prevNextFrontmatterSchema,\n next: prevNextFrontmatterSchema,\n /**\n * Versioning rename escape hatch.\n *\n * When a page is renamed between versions (the URL slug changes), the\n * newer version's frontmatter declares the slug it had in an older\n * version. The framework uses this to link the pages as cross-version\n * alternates and to emit a `<link rel=\"canonical\">` to the current\n * version's URL.\n *\n * Example: `docs-v1/old-name.mdx` was renamed in v2 to `new-name.mdx`.\n * On the new page (`docs/new-name.mdx`, current version), set:\n *\n * previousSlug: old-name\n *\n * Now `/new-name` and `/v1/old-name` are linked as the same logical\n * page in `<head>` alternates, and the v1 page's canonical points to\n * `/new-name`.\n *\n * Accepts a single slug string (the page's id in the older version)\n * or an array of strings when the page has been renamed across more\n * than one version.\n */\n previousSlug: z\n .union([z.string(), z.array(z.string())], {\n error: '\"previousSlug\" must be a string or array of strings',\n })\n .optional(),\n });\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Build a customizable docs schema. Use this when composing schemas outside\n * the `docsCollection()` factory (e.g. multiple docs collections with\n * different shapes).\n */\nexport function defineDocSchema(config: DocSchemaConfig = {}) {\n const base = baseDocSchema();\n if (config.fields) {\n return base.extend(config.fields);\n }\n return base;\n}\n\n/** Default docs schema. Equivalent to `defineDocSchema()`. */\nexport const docsSchema = defineDocSchema();\n\n/** Schema for partials (`<Render file=\"...\" />` snippets). */\nexport const partialsSchema = z\n .object({\n /**\n * Declared parameters this partial accepts.\n * Suffix with `?` for optional params: `[\"name\", \"deprecated?\"]`\n */\n params: z.array(z.string()).optional(),\n })\n .default({});\n\n// ---------------------------------------------------------------------------\n// Components collection — used by sites documenting their own UI components.\n// Pair with `componentsCollection()` from `nimbus-docs/content`. Authoring\n// pattern: hero `<Showcase>` block + `<Example>` blocks in the MDX body, with\n// `props` declared in frontmatter for a generated prop table.\n// ---------------------------------------------------------------------------\n\n/** One row in a component's `props` frontmatter array. */\nconst componentPropSchema = z.object({\n name: z.string({ error: 'prop needs a \"name\"' }),\n type: z.string({ error: 'prop needs a \"type\"' }),\n defaultValue: z.string().optional(),\n required: z.boolean().default(false),\n description: z.string({ error: 'prop needs a \"description\"' }),\n});\n\nexport type ComponentProp = z.infer<typeof componentPropSchema>;\n\n/** Default schema for the components collection. */\nexport const componentsSchema = z.object({\n title: z.string({\n error: (iss) =>\n iss.input === undefined\n ? 'Missing \"title\" in frontmatter — display name used in the sidebar and page header.'\n : `\"title\" must be a string, received ${typeof iss.input}`,\n }),\n tagline: z.string({\n error: (iss) =>\n iss.input === undefined\n ? 'Missing \"tagline\" in frontmatter — one-sentence summary shown under the title.'\n : `\"tagline\" must be a string, received ${typeof iss.input}`,\n }),\n props: z.array(componentPropSchema).default([]),\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAyBA,MAAM,qBAAqB,EAAE,MAAM,CACjC,EAAE,QAAQ,EACV,EAAE,OAAO;CACP,MAAM,EAAE,OAAO,EAAE,OAAO,wCAAsC,CAAC;CAC/D,SAAS,EACN,KACC;EAAC;EAAW;EAAQ;EAAQ;EAAW;EAAO;EAAW;EAAW;EAAS,EAC7E,EACE,OACE,2FACH,CACF,CACA,QAAQ,UAAU;CACtB,CAAC,CACH,CAAC;AAEF,MAAM,2BAA2B,EAC9B,OAAO;CACN,OAAO,EAAE,OAAO,EAAE,OAAO,sCAAoC,CAAC,CAAC,UAAU;CACzE,OAAO,EAAE,OAAO,EAAE,OAAO,sCAAoC,CAAC,CAAC,UAAU;CACzE,OAAO,mBAAmB,UAAU;CACpC,QAAQ,EAAE,QAAQ,EAAE,OAAO,4CAA0C,CAAC,CAAC,UAAU;CACjF,cAAc,EACX,QAAQ,EAAE,OAAO,kDAAgD,CAAC,CAClE,UAAU;CACd,CAAC,CACD,UAAU;AAEb,MAAM,mBAAmB,EAAE,OAAO;CAChC,MAAM,EAAE,OAAO,EAAE,OAAO,sCAAoC,CAAC;CAC7D,MAAM,EAAE,OA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AAQ,EAAE,CAAC;;AAUd,MAAM,sBAAsB,EAAE,OAAO;CACnC,MAAM,EAAE,OAAO,EAAE,OAAO,yBAAuB,CAAC;CAChD,MAAM,EAAE,OAAO,EAAE,OAAO,yBAAuB,CAAC;CAChD,cAAc,EAAE,QAAQ,CAAC,UAAU;CACnC,UAAU,EAAE,SAAS,CAAC,QAAQ,MAAM;CACpC,aAAa,EAAE,OAAO,EAAE,OAAO,gCAA8B,CAAC;CAC/D,CAAC;;AAKF,MAAa,mBAAmB,EAAE,OAAO;CACvC,OAAO,EAAE,OAAO,EACd,QAAQ,QACN,IAAI,UAAU,SACV,yFACA,sCAAsC,OAAO,IAAI,SACxD,CAAC;CACF,SAAS,EAAE,OAAO,EAChB,QAAQ,QACN,IAAI,UAAU,SACV,qFACA,wCAAwC,OAAO,IAAI,SAC1D,CAAC;CACF,OAAO,EAAE,MAAM,oBAAoB,CAAC,QAAQ,EAAE,CAAC;CAChD,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -36,6 +36,99 @@ interface NimbusConfig {
|
|
|
36
36
|
* without running Pagefind at build time.
|
|
37
37
|
*/
|
|
38
38
|
search?: SearchConfig | false;
|
|
39
|
+
/**
|
|
40
|
+
* Versioned-docs manifest. Absent means the site is unversioned (the
|
|
41
|
+
* default; no behavior change). When set, declares:
|
|
42
|
+
*
|
|
43
|
+
* - `current` — label for the primary `docs` collection (e.g. `"v3"`).
|
|
44
|
+
* The current version's content lives in `src/content/docs/`; this
|
|
45
|
+
* field is the *name* used in URLs / UI / sidebar — there is no
|
|
46
|
+
* `docs-v3` collection.
|
|
47
|
+
* - `others` — label list for non-current versions. Each entry `<slug>`
|
|
48
|
+
* must correspond to a registered Astro collection named
|
|
49
|
+
* `docs-<slug>` (e.g. `"v2"` → collection `docs-v2` at
|
|
50
|
+
* `src/content/docs-v2/`). Order is preserved; the picker and any
|
|
51
|
+
* ordered enumeration will use it as-is.
|
|
52
|
+
* - `deprecated` — subset of `others` that should render deprecation
|
|
53
|
+
* UX (banner + sidebar badge + search demotion). P0 stores the list;
|
|
54
|
+
* the visible behavior lands in P3. Default `[]`.
|
|
55
|
+
* - `hidden` — subset of `others` that should be URL-reachable but
|
|
56
|
+
* omitted from the picker, search index, and any other surface that
|
|
57
|
+
* enumerates "all versions." Default `[]`.
|
|
58
|
+
*
|
|
59
|
+
* P0 ships the data layer only. Picker UI, cross-version `<link rel="alternate">`,
|
|
60
|
+
* canonical pointers, and deprecation banners land in later phases.
|
|
61
|
+
*/
|
|
62
|
+
versions?: VersionsConfig;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Resolved versions manifest. See `NimbusConfig.versions` for field meanings.
|
|
66
|
+
*/
|
|
67
|
+
interface VersionsConfig {
|
|
68
|
+
current: string;
|
|
69
|
+
others: string[];
|
|
70
|
+
deprecated?: string[];
|
|
71
|
+
hidden?: string[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Return shape for `getVersions()`. Normalises optional fields to empty
|
|
75
|
+
* arrays so consumers don't branch on `undefined`. `all` is `[current,
|
|
76
|
+
* ...others]` in manifest order, useful for picker enumeration.
|
|
77
|
+
*/
|
|
78
|
+
interface ResolvedVersions {
|
|
79
|
+
current: string;
|
|
80
|
+
others: string[];
|
|
81
|
+
deprecated: string[];
|
|
82
|
+
hidden: string[];
|
|
83
|
+
all: string[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A single page in the cross-version alternates graph. Returned by
|
|
87
|
+
* `getVersionAlternates()` as part of each entry's record.
|
|
88
|
+
*/
|
|
89
|
+
interface VersionPageRef {
|
|
90
|
+
/** Astro collection ID — `"docs"` or `"docs-<slug>"`. */
|
|
91
|
+
collection: string;
|
|
92
|
+
/** Version slug — `current` for `docs`, the suffix for `docs-<v>`. */
|
|
93
|
+
version: string;
|
|
94
|
+
/** Page slug (entry.id) within the collection. */
|
|
95
|
+
slug: string;
|
|
96
|
+
/** Resolved URL path with leading slash, no trailing slash. */
|
|
97
|
+
url: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Per-page record in the alternates table. `self` describes the entry
|
|
101
|
+
* being looked up; `alternates` lists every other entry in the same
|
|
102
|
+
* SEO-equivalence class; `canonical` points at the current-version
|
|
103
|
+
* sibling when one exists and isn't `self`.
|
|
104
|
+
*/
|
|
105
|
+
interface VersionAlternateRecord {
|
|
106
|
+
self: VersionPageRef;
|
|
107
|
+
alternates: VersionPageRef[];
|
|
108
|
+
canonical: VersionPageRef | null;
|
|
109
|
+
}
|
|
110
|
+
/** Build-time alternates table indexed by `${collection}:${entryId}`. */
|
|
111
|
+
type VersionAlternatesTable = Record<string, VersionAlternateRecord>;
|
|
112
|
+
/**
|
|
113
|
+
* Versioning status for a single page's collection. Returned by
|
|
114
|
+
* `getVersionStatus()`. Drives the deprecation banner, Pagefind
|
|
115
|
+
* facet filters, and hidden-version exclusion in the layout.
|
|
116
|
+
*
|
|
117
|
+
* Fields:
|
|
118
|
+
* - `version` — the version slug this page belongs to (`current` for
|
|
119
|
+
* `docs`, `v1`/`v2`/… for `docs-<slug>`).
|
|
120
|
+
* - `isCurrent` — true when `version === versions.current`.
|
|
121
|
+
* - `isDeprecated` — true when `version` is listed in `versions.deprecated`.
|
|
122
|
+
* Triggers the deprecation banner + Pagefind `status:deprecated` filter.
|
|
123
|
+
* - `isHidden` — true when `version` is listed in `versions.hidden`.
|
|
124
|
+
* Hidden versions are URL-reachable but excluded from search and
|
|
125
|
+
* any picker/listing surface.
|
|
126
|
+
*/
|
|
127
|
+
interface VersionStatus {
|
|
128
|
+
version: string;
|
|
129
|
+
isCurrent: boolean;
|
|
130
|
+
isDeprecated: boolean;
|
|
131
|
+
isHidden: boolean;
|
|
39
132
|
}
|
|
40
133
|
interface FeaturesConfig {
|
|
41
134
|
search?: boolean;
|
|
@@ -73,6 +166,19 @@ interface HeadElement {
|
|
|
73
166
|
}
|
|
74
167
|
interface SidebarConfig {
|
|
75
168
|
items?: SidebarConfigItem[];
|
|
169
|
+
/**
|
|
170
|
+
* How the sidebar rail filters the tree on each page.
|
|
171
|
+
*
|
|
172
|
+
* - `"full"` (default) — show the entire tree on every page. Best for
|
|
173
|
+
* small / flat sites; pairs naturally with the header section-tab
|
|
174
|
+
* strip when one exists.
|
|
175
|
+
* - `"section"` — scope to the current top-level section. Best for
|
|
176
|
+
* large sites where the full rail would overflow; cross-section nav
|
|
177
|
+
* must come from the header tabs.
|
|
178
|
+
*
|
|
179
|
+
* @default "full"
|
|
180
|
+
*/
|
|
181
|
+
scope?: "full" | "section";
|
|
76
182
|
}
|
|
77
183
|
/**
|
|
78
184
|
* A top-level section derived from the sidebar tree — used to render the
|
|
@@ -232,6 +338,17 @@ interface BasePageProps {
|
|
|
232
338
|
* same prop without touching the layout.
|
|
233
339
|
*/
|
|
234
340
|
lastUpdated?: Date;
|
|
341
|
+
/**
|
|
342
|
+
* Astro collection ID for this page (e.g. `"docs"`, `"docs-v1"`).
|
|
343
|
+
* Forwarded to `NimbusHead` so it can look up cross-version alternates
|
|
344
|
+
* and the canonical override. Pass `entry.collection` from your route.
|
|
345
|
+
*/
|
|
346
|
+
collection?: string;
|
|
347
|
+
/**
|
|
348
|
+
* Astro entry id (slug) for this page. Forwarded to `NimbusHead` for
|
|
349
|
+
* the alternates lookup. Pass `entry.id` from your route.
|
|
350
|
+
*/
|
|
351
|
+
entryId?: string;
|
|
235
352
|
}
|
|
236
353
|
/**
|
|
237
354
|
* Props passed to a Nimbus docs layout (e.g. `DocsLayout.astro`).
|
|
@@ -270,5 +387,5 @@ interface DocsPageProps extends BasePageProps {
|
|
|
270
387
|
prevNext: PrevNext;
|
|
271
388
|
}
|
|
272
389
|
//#endregion
|
|
273
|
-
export { BadgeVariant, BannerProps, BasePageProps, Breadcrumb, DocsPageProps, FeaturesConfig, HeadElement, NimbusConfig, PrevNext, PrevNextLink, PrevNextOverrides, SearchConfig, SearchProvider, SearchResult, SidebarBadge, SidebarConfig, SidebarConfigItem, SidebarExternalLinkItem, SidebarGroupItem, SidebarItem, SidebarLinkItem, SidebarSection, TOCItem };
|
|
390
|
+
export { BadgeVariant, BannerProps, BasePageProps, Breadcrumb, DocsPageProps, FeaturesConfig, HeadElement, NimbusConfig, PrevNext, PrevNextLink, PrevNextOverrides, ResolvedVersions, SearchConfig, SearchProvider, SearchResult, SidebarBadge, SidebarConfig, SidebarConfigItem, SidebarExternalLinkItem, SidebarGroupItem, SidebarItem, SidebarLinkItem, SidebarSection, TOCItem, VersionAlternateRecord, VersionAlternatesTable, VersionPageRef, VersionStatus, VersionsConfig };
|
|
274
391
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;AAQA;;UAAiB,YAAA;EAyBR;EAvBP,IAAA;EACA,KAAA;EACA,WAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;AAQA;;UAAiB,YAAA;EAyBR;EAvBP,IAAA;EACA,KAAA;EACA,WAAA;EAqDW;EAnDX,IAAA;EACA,MAAA;EALA;EAOA,SAAA;EALA;EAOA,MAAA;EAJA;EAMA,WAAA;EAFA;EAIA,MAAA;EAAA;;;;;EAMA,WAAA;EAKU;EAHV,cAAA;EAIW;EAFX,IAAA,GAAO,WAAA;EACP,OAAA,GAAU,aAAA;EACV,QAAA,GAAW,cAAA;EA8BA;;;AAMb;;EA9BE,MAAA,GAAS,YAAA;EA8BoB;;;;;;;AAY/B;;;;;;;;;;;AAYA;;;;;EA9BE,QAAA,GAAW,cAAA;AAAA;;;;UAMI,cAAA;EACf,OAAA;EACA,MAAA;EACA,UAAA;EACA,MAAA;AAAA;;;;;;UAQe,gBAAA;EACf,OAAA;EACA,MAAA;EACA,UAAA;EACA,MAAA;EACA,GAAA;AAAA;;;;AAgDF;UAzCiB,cAAA;;EAEf,UAAA;EAwCA;EAtCA,OAAA;EAwCA;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;;;;;;;;;;;;;;UAmBe,aAAA,SAAsB,aAAA;EAuB3B;EApBV,QAAA;EAoBkB;EAlBlB,QAAA;;EAEA,KAAA;;EAIA,OAAA;;EAEA,MAAA,GAAS,WAAA;;EAIT,OAAA,EAAS,WAAA;;EAET,QAAA,EAAU,OAAA;;EAEV,WAAA,EAAa,UAAA;;EAEb,QAAA,EAAU,QAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nimbus-docs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Docs, for humans and agents",
|
|
@@ -56,11 +56,6 @@
|
|
|
56
56
|
"dist",
|
|
57
57
|
"src/components"
|
|
58
58
|
],
|
|
59
|
-
"scripts": {
|
|
60
|
-
"build": "tsdown",
|
|
61
|
-
"dev": "tsdown --watch",
|
|
62
|
-
"typecheck": "tsc --noEmit"
|
|
63
|
-
},
|
|
64
59
|
"peerDependencies": {
|
|
65
60
|
"astro": ">=6.4.0"
|
|
66
61
|
},
|
|
@@ -77,5 +72,10 @@
|
|
|
77
72
|
"astro": "^6.4.0",
|
|
78
73
|
"tsdown": "^0.20.3",
|
|
79
74
|
"typescript": "^5.8.3"
|
|
75
|
+
},
|
|
76
|
+
"scripts": {
|
|
77
|
+
"build": "tsdown",
|
|
78
|
+
"dev": "tsdown --watch",
|
|
79
|
+
"typecheck": "tsc --noEmit"
|
|
80
80
|
}
|
|
81
|
-
}
|
|
81
|
+
}
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
import { existsSync } from "node:fs";
|
|
30
30
|
import { join } from "node:path";
|
|
31
31
|
import { config } from "virtual:nimbus/config";
|
|
32
|
+
import {
|
|
33
|
+
getCollectionLlmsUrl,
|
|
34
|
+
getVersionAlternates,
|
|
35
|
+
getVersionStatus,
|
|
36
|
+
} from "../index.js";
|
|
32
37
|
import type { HeadElement } from "../types.js";
|
|
33
38
|
|
|
34
39
|
export interface Props {
|
|
@@ -52,6 +57,16 @@ export interface Props {
|
|
|
52
57
|
lastUpdated?: Date;
|
|
53
58
|
/** Per-page head extras, appended after `config.head`. */
|
|
54
59
|
head?: HeadElement[];
|
|
60
|
+
/**
|
|
61
|
+
* Astro collection ID for this page — used to look up cross-version
|
|
62
|
+
* alternates when versioning is configured. Pass `entry.collection`
|
|
63
|
+
* from your route. Optional: when omitted (e.g. on hand-built pages
|
|
64
|
+
* outside the docs collections), no alternate/canonical tags are
|
|
65
|
+
* emitted from the versioning layer.
|
|
66
|
+
*/
|
|
67
|
+
collection?: string;
|
|
68
|
+
/** Astro entry id (slug) for this page. Pass `entry.id` from your route. */
|
|
69
|
+
entryId?: string;
|
|
55
70
|
}
|
|
56
71
|
|
|
57
72
|
const {
|
|
@@ -63,13 +78,60 @@ const {
|
|
|
63
78
|
socialImage,
|
|
64
79
|
lastUpdated,
|
|
65
80
|
head: pageHead = [],
|
|
81
|
+
collection,
|
|
82
|
+
entryId,
|
|
66
83
|
} = Astro.props;
|
|
67
84
|
|
|
68
85
|
// ---- Derived values -------------------------------------------------------
|
|
69
86
|
|
|
70
87
|
const hasSite = !!Astro.site;
|
|
88
|
+
|
|
89
|
+
// Cross-version alternates and canonical override. When the page is part
|
|
90
|
+
// of a versioned-docs class with a current-version sibling that isn't
|
|
91
|
+
// `self`, `record.canonical` points to it — we emit that URL as the
|
|
92
|
+
// canonical instead of the page's own URL, so search engines treat the
|
|
93
|
+
// current version as authoritative.
|
|
94
|
+
const versionRecord =
|
|
95
|
+
collection && entryId ? await getVersionAlternates(collection, entryId) : null;
|
|
96
|
+
const versionCanonicalPath = versionRecord?.canonical?.url ?? null;
|
|
97
|
+
|
|
98
|
+
// Hidden-version suppression. Hidden versions are URL-reachable but
|
|
99
|
+
// excluded from every agent-discovery and SEO surface. When the page
|
|
100
|
+
// belongs to a hidden version we strip:
|
|
101
|
+
// - the markdown alternate link (no `.md` route is guaranteed to exist
|
|
102
|
+
// for hidden pages, and even if one did, agents shouldn't be guided
|
|
103
|
+
// to it)
|
|
104
|
+
// - the LLM-index hint (the per-version `/<v>/llms.txt` is not emitted
|
|
105
|
+
// for hidden versions, so the link would 404)
|
|
106
|
+
// - cross-version `<link rel="alternate">` tags (other pages shouldn't
|
|
107
|
+
// advertise this hidden page either)
|
|
108
|
+
// Canonical and `<meta robots>` are left alone — hidden pages still get
|
|
109
|
+
// the normal `noindex` behavior the user opts into via frontmatter.
|
|
110
|
+
const versionStatus =
|
|
111
|
+
collection ? await getVersionStatus(collection) : null;
|
|
112
|
+
const isHiddenVersion = versionStatus?.isHidden === true;
|
|
113
|
+
|
|
114
|
+
// Agent index hint — point readers' AI tooling at the right per-collection
|
|
115
|
+
// llms.txt. Version pages point at `/v<n>/llms.txt`, non-primary
|
|
116
|
+
// collection pages point at `/<collection>/llms.txt`, primary docs
|
|
117
|
+
// pages point at the root `/llms.txt`. When `collection` is omitted
|
|
118
|
+
// (hand-built routes outside the docs system), we fall back to the
|
|
119
|
+
// root index. Hidden-version pages emit no LLM hint (see above).
|
|
120
|
+
const llmsIndexPath =
|
|
121
|
+
isHiddenVersion
|
|
122
|
+
? null
|
|
123
|
+
: collection
|
|
124
|
+
? await getCollectionLlmsUrl(collection)
|
|
125
|
+
: "/llms.txt";
|
|
126
|
+
const llmsIndexUrl =
|
|
127
|
+
llmsIndexPath && Astro.site
|
|
128
|
+
? new URL(llmsIndexPath, Astro.site).href
|
|
129
|
+
: llmsIndexPath;
|
|
130
|
+
|
|
71
131
|
const canonical = Astro.site
|
|
72
|
-
?
|
|
132
|
+
? versionCanonicalPath
|
|
133
|
+
? new URL(versionCanonicalPath, Astro.site).href
|
|
134
|
+
: new URL(Astro.url.pathname, Astro.site).href
|
|
73
135
|
: null;
|
|
74
136
|
|
|
75
137
|
const fullTitle = title !== config.title ? `${title} | ${config.title}` : title;
|
|
@@ -130,7 +192,24 @@ const mergedHead = [...(config.head ?? []), ...pageHead];
|
|
|
130
192
|
<link rel="icon" type="image/svg+xml" href={faviconHref} />
|
|
131
193
|
{hasSite && canonical && <link rel="canonical" href={canonical} />}
|
|
132
194
|
{hasSite && <link rel="sitemap" href="/sitemap-index.xml" />}
|
|
133
|
-
{markdownUrl &&
|
|
195
|
+
{markdownUrl && !isHiddenVersion && (
|
|
196
|
+
<link rel="alternate" type="text/markdown" href={markdownUrl} />
|
|
197
|
+
)}
|
|
198
|
+
{hasSite && llmsIndexUrl && (
|
|
199
|
+
<link
|
|
200
|
+
rel="alternate"
|
|
201
|
+
type="text/plain"
|
|
202
|
+
href={llmsIndexUrl}
|
|
203
|
+
title="LLM index"
|
|
204
|
+
/>
|
|
205
|
+
)}
|
|
206
|
+
{!isHiddenVersion && versionRecord?.alternates.map((alt) => (
|
|
207
|
+
<link
|
|
208
|
+
rel="alternate"
|
|
209
|
+
data-version={alt.version}
|
|
210
|
+
href={Astro.site ? new URL(alt.url, Astro.site).href : alt.url}
|
|
211
|
+
/>
|
|
212
|
+
))}
|
|
134
213
|
|
|
135
214
|
<meta property="og:title" content={fullTitle} />
|
|
136
215
|
<meta property="og:type" content={ogType} />
|