@astrojs/starlight 0.37.7 → 0.38.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/components/ContentNotice.astro +1 -1
  3. package/components/MobileTableOfContents.astro +2 -2
  4. package/components/Page.astro +3 -3
  5. package/components/Select.astro +2 -2
  6. package/components/SocialIcons.astro +1 -1
  7. package/components/TableOfContents.astro +2 -2
  8. package/global.d.ts +9 -3
  9. package/index.ts +39 -1
  10. package/integrations/asides.ts +1 -1
  11. package/integrations/remark-rehype.ts +2 -11
  12. package/integrations/virtual-user-config.ts +31 -17
  13. package/integrations/vite-layer-order.ts +38 -35
  14. package/package.json +12 -148
  15. package/schema.ts +3 -9
  16. package/schemas/badge.ts +9 -8
  17. package/schemas/components.ts +1 -1
  18. package/schemas/expressiveCode.ts +0 -3
  19. package/schemas/favicon.ts +4 -6
  20. package/schemas/head.ts +3 -2
  21. package/schemas/hero.ts +1 -1
  22. package/schemas/i18n.ts +148 -153
  23. package/schemas/icon.ts +1 -1
  24. package/schemas/pagefind.ts +5 -4
  25. package/schemas/prevNextLink.ts +6 -8
  26. package/schemas/sidebar.ts +33 -27
  27. package/schemas/site-title.ts +4 -6
  28. package/schemas/social.ts +3 -2
  29. package/schemas/tableOfContents.ts +3 -3
  30. package/style/props.css +7 -2
  31. package/types.ts +1 -1
  32. package/user-components/Aside.astro +1 -1
  33. package/user-components/Card.astro +1 -1
  34. package/user-components/Icon.astro +1 -1
  35. package/user-components/LinkButton.astro +1 -1
  36. package/user-components/TabItem.astro +1 -1
  37. package/user-components/rehype-file-tree.ts +1 -1
  38. package/user-components/rehype-tabs.ts +1 -1
  39. package/utils/createTranslationSystem.ts +1 -1
  40. package/utils/error-map.ts +98 -57
  41. package/utils/navigation.ts +11 -10
  42. package/utils/plugins.ts +75 -40
  43. package/utils/routing/data.ts +3 -9
  44. package/utils/routing/index.ts +16 -24
  45. package/utils/routing/types.ts +5 -17
  46. package/utils/slugs.ts +11 -12
  47. package/utils/starlight-page.ts +13 -23
  48. package/utils/translations.ts +3 -4
  49. package/utils/user-config.ts +28 -65
  50. package/virtual.d.ts +6 -3
  51. /package/{components → components-internals}/Icons.ts +0 -0
  52. /package/{components → components-internals}/SidebarPersistState.ts +0 -0
  53. /package/{components → components-internals}/TableOfContents/TableOfContentsList.astro +0 -0
  54. /package/{components → components-internals}/TableOfContents/starlight-toc.ts +0 -0
package/schema.ts CHANGED
@@ -27,7 +27,7 @@ const StarlightFrontmatterSchema = (context: SchemaContext) =>
27
27
  *
28
28
  * Can also be set to `false` to disable showing an edit link on this page.
29
29
  */
30
- editUrl: z.union([z.string().url(), z.boolean()]).optional().default(true),
30
+ editUrl: z.union([z.url(), z.boolean()]).optional().default(true),
31
31
 
32
32
  /** Set custom `<head>` tags just for this page. */
33
33
  head: HeadConfigSchema({ source: 'content' }),
@@ -91,7 +91,7 @@ const StarlightFrontmatterSchema = (context: SchemaContext) =>
91
91
  /** HTML attributes to add to the sidebar link. */
92
92
  attrs: SidebarLinkItemHTMLAttributesSchema(),
93
93
  })
94
- .default({}),
94
+ .prefault({}),
95
95
 
96
96
  /** Display an announcement banner at the top of this page. */
97
97
  banner: z
@@ -113,14 +113,8 @@ const StarlightFrontmatterSchema = (context: SchemaContext) =>
113
113
  /** Type of Starlight’s default frontmatter schema. */
114
114
  type DefaultSchema = ReturnType<typeof StarlightFrontmatterSchema>;
115
115
 
116
- /** Plain object, union, and intersection Zod types. */
117
- type BaseSchemaWithoutEffects =
118
- | z.AnyZodObject
119
- | z.ZodUnion<[BaseSchemaWithoutEffects, ...BaseSchemaWithoutEffects[]]>
120
- | z.ZodDiscriminatedUnion<string, z.AnyZodObject[]>
121
- | z.ZodIntersection<BaseSchemaWithoutEffects, BaseSchemaWithoutEffects>;
122
116
  /** Base subset of Zod types that we support passing to the `extend` option. */
123
- type BaseSchema = BaseSchemaWithoutEffects | z.ZodEffects<BaseSchemaWithoutEffects>;
117
+ type BaseSchema = z.core.$ZodType;
124
118
 
125
119
  /** Type that extends Starlight’s default schema with an optional, user-defined schema. */
126
120
  type ExtendedSchema<T extends BaseSchema = never> = [T] extends [never]
package/schemas/badge.ts CHANGED
@@ -5,19 +5,20 @@ const badgeBaseSchema = z.object({
5
5
  class: z.string().optional(),
6
6
  });
7
7
 
8
- const badgeSchema = badgeBaseSchema.extend({
8
+ const badgeSchema = z.object({
9
+ ...badgeBaseSchema.shape,
9
10
  text: z.string(),
10
11
  });
11
12
 
12
- const i18nBadgeSchema = badgeBaseSchema.extend({
13
- text: z.union([z.string(), z.record(z.string())]),
13
+ const i18nBadgeSchema = z.object({
14
+ ...badgeBaseSchema.shape,
15
+ text: z.union([z.string(), z.record(z.string(), z.string())]),
14
16
  });
15
17
 
16
- export const BadgeComponentSchema = badgeSchema
17
- .extend({
18
- size: z.enum(['small', 'medium', 'large']).default('small'),
19
- })
20
- .passthrough();
18
+ export const BadgeComponentSchema = z.looseObject({
19
+ ...badgeSchema.shape,
20
+ size: z.enum(['small', 'medium', 'large']).default('small'),
21
+ });
21
22
 
22
23
  export type BadgeComponentProps = z.input<typeof BadgeComponentSchema>;
23
24
 
@@ -261,5 +261,5 @@ export function ComponentConfigSchema() {
261
261
  */
262
262
  EditLink: z.string().default('@astrojs/starlight/components/EditLink.astro'),
263
263
  })
264
- .default({});
264
+ .prefault({});
265
265
  }
@@ -9,7 +9,4 @@ export const ExpressiveCodeSchema = () =>
9
9
  ),
10
10
  z.boolean(),
11
11
  ])
12
- .describe(
13
- 'Define how code blocks are rendered by passing options to Expressive Code, or disable the integration by passing `false`.'
14
- )
15
12
  .optional();
@@ -20,9 +20,10 @@ export const FaviconSchema = () =>
20
20
  const ext = extname(pathname).toLowerCase();
21
21
 
22
22
  if (!isFaviconExt(ext)) {
23
- ctx.addIssue({
24
- code: z.ZodIssueCode.custom,
23
+ ctx.issues.push({
24
+ code: 'custom',
25
25
  message: 'favicon must be a .ico, .gif, .jpg, .png, or .svg file',
26
+ input: favicon,
26
27
  });
27
28
 
28
29
  return z.NEVER;
@@ -32,10 +33,7 @@ export const FaviconSchema = () =>
32
33
  href: favicon,
33
34
  type: faviconTypeMap[ext],
34
35
  };
35
- })
36
- .describe(
37
- 'The default favicon for your site which should be a path to an image in the `public/` directory.'
38
- );
36
+ });
39
37
 
40
38
  function isFaviconExt(ext: string): ext is keyof typeof faviconTypeMap {
41
39
  return ext in faviconTypeMap;
package/schemas/head.ts CHANGED
@@ -17,7 +17,7 @@ export const HeadConfigSchema = ({
17
17
  /** Name of the HTML tag to add to `<head>`, e.g. `'meta'`, `'link'`, or `'script'`. */
18
18
  tag: z.enum(['title', 'base', 'link', 'style', 'meta', 'script', 'noscript', 'template']),
19
19
  /** Attributes to set on the tag, e.g. `{ rel: 'stylesheet', href: '/custom.css' }`. */
20
- attrs: z.record(z.union([z.string(), z.boolean(), z.undefined()])).optional(),
20
+ attrs: z.record(z.string(), z.union([z.string(), z.boolean(), z.undefined()])).optional(),
21
21
  /** Content to place inside the tag (optional). */
22
22
  content: z.string().optional(),
23
23
  })
@@ -30,7 +30,7 @@ export const HeadConfigSchema = ({
30
30
  };
31
31
  const code =
32
32
  source === 'config' ? JSON.stringify(correctTag, null, 2) : yaml.dump([correctTag]);
33
- ctx.addIssue({
33
+ ctx.issues.push({
34
34
  code: 'custom',
35
35
  message:
36
36
  `The \`head\` configuration includes a \`meta\` tag with \`content\` which is invalid HTML.\n` +
@@ -40,6 +40,7 @@ export const HeadConfigSchema = ({
40
40
  : '') +
41
41
  `in the \`attrs\` object:\n\n` +
42
42
  code,
43
+ input: config,
43
44
  });
44
45
  })
45
46
  )
package/schemas/hero.ts CHANGED
@@ -62,7 +62,7 @@ export const HeroSchema = ({ image }: SchemaContext) =>
62
62
  })
63
63
  .optional(),
64
64
  /** HTML attributes to add to the link */
65
- attrs: z.record(z.union([z.string(), z.number(), z.boolean()])).optional(),
65
+ attrs: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(),
66
66
  })
67
67
  .array()
68
68
  .default([]),
package/schemas/i18n.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'astro/zod';
2
2
 
3
- interface i18nSchemaOpts<T extends z.AnyZodObject = z.SomeZodObject> {
3
+ interface i18nSchemaOpts<T extends z.ZodObject = BaseExtendSchema> {
4
4
  /**
5
5
  * Extend Starlight’s i18n schema with additional fields.
6
6
  *
@@ -19,147 +19,152 @@ interface i18nSchemaOpts<T extends z.AnyZodObject = z.SomeZodObject> {
19
19
  }
20
20
 
21
21
  const defaultI18nSchema = () =>
22
- starlightI18nSchema().merge(pagefindI18nSchema()).merge(expressiveCodeI18nSchema());
22
+ z.object({
23
+ ...starlightI18nSchema().shape,
24
+ ...pagefindI18nSchema().shape,
25
+ ...expressiveCodeI18nSchema().shape,
26
+ });
23
27
  /** Type of Starlight’s default i18n schema, including extensions from Pagefind and Expressive Code. */
24
28
  type DefaultI18nSchema = ReturnType<typeof defaultI18nSchema>;
25
29
 
26
30
  /**
27
- * Based on the the return type of Zod’s `merge()` method. Merges the type of two `z.object()` schemas.
28
- * Also sets them as “passthrough” schemas as that’s how we use them. In practice whether or not the types
29
- * are passthrough or not doesnt matter too much.
31
+ * Based on the the return type of Zod’s `extend()` method. Adds fields from one `z.object()` schema
32
+ * to another.
33
+ * Also sets the resulting schema as “loose” as thats how we use it. In practice whether or not
34
+ * the types are loose or not doesn’t matter too much.
30
35
  *
31
- * @see https://github.com/colinhacks/zod/blob/3032e240a0c227692bb96eedf240ed493c53f54c/src/types.ts#L2656-L2660
36
+ * @see https://github.com/colinhacks/zod/blob/9712a6707f3d4584f222729965f3b78f076f0435/packages/zod/src/v4/classic/schemas.ts#L1187
32
37
  */
33
- type MergeSchemas<A extends z.AnyZodObject, B extends z.AnyZodObject> = z.ZodObject<
34
- z.objectUtil.extendShape<A['shape'], B['shape']>,
35
- 'passthrough',
36
- B['_def']['catchall']
38
+ type MergeSchemas<A extends z.ZodObject, B extends z.ZodObject> = z.ZodObject<
39
+ z.util.Extend<A['shape'], B['shape']>,
40
+ z.core.$loose
37
41
  >;
38
42
  /** Type that extends Starlight’s default i18n schema with an optional, user-defined schema. */
39
- type ExtendedSchema<T extends z.AnyZodObject> = T extends z.AnyZodObject
43
+ type ExtendedSchema<T extends z.ZodObject> = T extends z.ZodObject
40
44
  ? MergeSchemas<DefaultI18nSchema, T>
41
45
  : DefaultI18nSchema;
46
+ /** Type representing an empty Zod object schema used as the default for the `extend` option. */
47
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
48
+ type BaseExtendSchema = z.ZodObject<{}>;
42
49
 
43
50
  /** Content collection schema for Starlight’s optional `i18n` collection. */
44
- export function i18nSchema<T extends z.AnyZodObject = z.SomeZodObject>({
51
+ export function i18nSchema<T extends z.ZodObject = BaseExtendSchema>({
45
52
  extend = z.object({}) as T,
46
53
  }: i18nSchemaOpts<T> = {}): ExtendedSchema<T> {
47
- return defaultI18nSchema().merge(extend).passthrough() as ExtendedSchema<T>;
54
+ return z.looseObject({
55
+ ...defaultI18nSchema().shape,
56
+ ...extend.shape,
57
+ }) as ExtendedSchema<T>;
48
58
  }
49
- export type i18nSchemaOutput = z.output<ReturnType<typeof i18nSchema>>;
59
+ export type i18nSchemaOutput = z.output<ExtendedSchema<BaseExtendSchema>>;
50
60
 
51
61
  export function builtinI18nSchema() {
52
- return starlightI18nSchema()
53
- .required()
54
- .strict()
55
- .merge(pagefindI18nSchema())
56
- .merge(expressiveCodeI18nSchema());
62
+ return z.object({
63
+ ...z.strictObject({ ...starlightI18nSchema().required().shape }).shape,
64
+ ...pagefindI18nSchema().shape,
65
+ ...expressiveCodeI18nSchema().shape,
66
+ });
57
67
  }
58
68
 
59
69
  function starlightI18nSchema() {
60
70
  return z
61
71
  .object({
62
- 'skipLink.label': z
63
- .string()
64
- .describe(
65
- 'Text displayed in the accessible “Skip link” when a keyboard user first tabs into a page.'
66
- ),
72
+ 'skipLink.label': z.string().meta({
73
+ description:
74
+ 'Text displayed in the accessible “Skip link” when a keyboard user first tabs into a page.',
75
+ }),
67
76
 
68
- 'search.label': z.string().describe('Text displayed in the search bar.'),
77
+ 'search.label': z.string().meta({ description: 'Text displayed in the search bar.' }),
69
78
 
70
- 'search.ctrlKey': z
71
- .string()
72
- .describe(
73
- 'Visible representation of the Control key potentially used in the shortcut key to open the search modal.'
74
- ),
79
+ 'search.ctrlKey': z.string().meta({
80
+ description:
81
+ 'Visible representation of the Control key potentially used in the shortcut key to open the search modal.',
82
+ }),
75
83
 
76
84
  'search.cancelLabel': z
77
85
  .string()
78
- .describe('Text for the “Cancel” button that closes the search modal.'),
86
+ .meta({ description: 'Text for the “Cancel” button that closes the search modal.' }),
79
87
 
80
- 'search.devWarning': z
81
- .string()
82
- .describe('Warning displayed when opening the Search in a dev environment.'),
88
+ 'search.devWarning': z.string().meta({
89
+ description: 'Warning displayed when opening the Search in a dev environment.',
90
+ }),
83
91
 
84
92
  'themeSelect.accessibleLabel': z
85
93
  .string()
86
- .describe('Accessible label for the theme selection dropdown.'),
94
+ .meta({ description: 'Accessible label for the theme selection dropdown.' }),
87
95
 
88
- 'themeSelect.dark': z.string().describe('Name of the dark color theme.'),
96
+ 'themeSelect.dark': z.string().meta({ description: 'Name of the dark color theme.' }),
89
97
 
90
- 'themeSelect.light': z.string().describe('Name of the light color theme.'),
98
+ 'themeSelect.light': z.string().meta({ description: 'Name of the light color theme.' }),
91
99
 
92
- 'themeSelect.auto': z
93
- .string()
94
- .describe('Name of the automatic color theme that syncs with system preferences.'),
100
+ 'themeSelect.auto': z.string().meta({
101
+ description: 'Name of the automatic color theme that syncs with system preferences.',
102
+ }),
95
103
 
96
104
  'languageSelect.accessibleLabel': z
97
105
  .string()
98
- .describe('Accessible label for the language selection dropdown.'),
106
+ .meta({ description: 'Accessible label for the language selection dropdown.' }),
99
107
 
100
108
  'menuButton.accessibleLabel': z
101
109
  .string()
102
- .describe('Accessible label for the mobile menu button.'),
110
+ .meta({ description: 'Accessible label for the mobile menu button.' }),
103
111
 
104
- 'sidebarNav.accessibleLabel': z
105
- .string()
106
- .describe(
107
- 'Accessible label for the main sidebar `<nav>` element to distinguish it from other `<nav>` landmarks on the page.'
108
- ),
112
+ 'sidebarNav.accessibleLabel': z.string().meta({
113
+ description:
114
+ 'Accessible label for the main sidebar `<nav>` element to distinguish it from other `<nav>` landmarks on the page.',
115
+ }),
109
116
 
110
117
  'tableOfContents.onThisPage': z
111
118
  .string()
112
- .describe('Title for the table of contents component.'),
119
+ .meta({ description: 'Title for the table of contents component.' }),
113
120
 
114
- 'tableOfContents.overview': z
115
- .string()
116
- .describe(
117
- 'Label used for the first link in the table of contents, linking to the page title.'
118
- ),
121
+ 'tableOfContents.overview': z.string().meta({
122
+ description:
123
+ 'Label used for the first link in the table of contents, linking to the page title.',
124
+ }),
119
125
 
120
- 'i18n.untranslatedContent': z
121
- .string()
122
- .describe(
123
- 'Notice informing users they are on a page that is not yet translated to their language.'
124
- ),
126
+ 'i18n.untranslatedContent': z.string().meta({
127
+ description:
128
+ 'Notice informing users they are on a page that is not yet translated to their language.',
129
+ }),
125
130
 
126
- 'page.editLink': z.string().describe('Text for the link to edit a page.'),
131
+ 'page.editLink': z.string().meta({ description: 'Text for the link to edit a page.' }),
127
132
 
128
- 'page.lastUpdated': z
129
- .string()
130
- .describe('Text displayed in front of the last updated date in the page footer.'),
133
+ 'page.lastUpdated': z.string().meta({
134
+ description: 'Text displayed in front of the last updated date in the page footer.',
135
+ }),
131
136
 
132
- 'page.previousLink': z
133
- .string()
134
- .describe('Label shown on the “previous page” pagination arrow in the page footer.'),
137
+ 'page.previousLink': z.string().meta({
138
+ description: 'Label shown on the “previous page” pagination arrow in the page footer.',
139
+ }),
135
140
 
136
- 'page.nextLink': z
137
- .string()
138
- .describe('Label shown on the “next page” pagination arrow in the page footer.'),
141
+ 'page.nextLink': z.string().meta({
142
+ description: 'Label shown on the “next page” pagination arrow in the page footer.',
143
+ }),
139
144
 
140
- 'page.draft': z
141
- .string()
142
- .describe(
143
- 'Development-only notice informing users they are on a page that is a draft which will not be included in production builds.'
144
- ),
145
+ 'page.draft': z.string().meta({
146
+ description:
147
+ 'Development-only notice informing users they are on a page that is a draft which will not be included in production builds.',
148
+ }),
145
149
 
146
- '404.text': z.string().describe('Text shown on Starlight’s default 404 page'),
147
- 'aside.tip': z.string().describe('Text shown on the tip aside variant'),
148
- 'aside.note': z.string().describe('Text shown on the note aside variant'),
149
- 'aside.caution': z.string().describe('Text shown on the warning aside variant'),
150
- 'aside.danger': z.string().describe('Text shown on the danger aside variant'),
150
+ '404.text': z.string().meta({ description: 'Text shown on Starlight’s default 404 page' }),
151
+ 'aside.tip': z.string().meta({ description: 'Text shown on the tip aside variant' }),
152
+ 'aside.note': z.string().meta({ description: 'Text shown on the note aside variant' }),
153
+ 'aside.caution': z.string().meta({ description: 'Text shown on the warning aside variant' }),
154
+ 'aside.danger': z.string().meta({ description: 'Text shown on the danger aside variant' }),
151
155
 
152
156
  'fileTree.directory': z
153
157
  .string()
154
- .describe('Label for the directory icon in the file tree component.'),
158
+ .meta({ description: 'Label for the directory icon in the file tree component.' }),
155
159
 
156
- 'builtWithStarlight.label': z
157
- .string()
158
- .describe(
159
- 'Label for the “Built with Starlight” badge optionally displayed in the site footer.'
160
- ),
160
+ 'builtWithStarlight.label': z.string().meta({
161
+ description:
162
+ 'Label for the “Built with Starlight” badge optionally displayed in the site footer.',
163
+ }),
161
164
 
162
- 'heading.anchorLabel': z.string().describe('Label for anchor links in Markdown content.'),
165
+ 'heading.anchorLabel': z
166
+ .string()
167
+ .meta({ description: 'Label for anchor links in Markdown content.' }),
163
168
  })
164
169
  .partial();
165
170
  }
@@ -167,65 +172,55 @@ function starlightI18nSchema() {
167
172
  function pagefindI18nSchema() {
168
173
  return z
169
174
  .object({
170
- 'pagefind.clear_search': z
171
- .string()
172
- .describe(
173
- 'Pagefind UI translation. English default value: `"Clear"`. See https://pagefind.app/docs/ui/#translations'
174
- ),
175
-
176
- 'pagefind.load_more': z
177
- .string()
178
- .describe(
179
- 'Pagefind UI translation. English default value: `"Load more results"`. See https://pagefind.app/docs/ui/#translations'
180
- ),
181
-
182
- 'pagefind.search_label': z
183
- .string()
184
- .describe(
185
- 'Pagefind UI translation. English default value: `"Search this site"`. See https://pagefind.app/docs/ui/#translations'
186
- ),
187
-
188
- 'pagefind.filters_label': z
189
- .string()
190
- .describe(
191
- 'Pagefind UI translation. English default value: `"Filters"`. See https://pagefind.app/docs/ui/#translations'
192
- ),
193
-
194
- 'pagefind.zero_results': z
195
- .string()
196
- .describe(
197
- 'Pagefind UI translation. English default value: `"No results for [SEARCH_TERM]"`. See https://pagefind.app/docs/ui/#translations'
198
- ),
199
-
200
- 'pagefind.many_results': z
201
- .string()
202
- .describe(
203
- 'Pagefind UI translation. English default value: `"[COUNT] results for [SEARCH_TERM]"`. See https://pagefind.app/docs/ui/#translations'
204
- ),
205
-
206
- 'pagefind.one_result': z
207
- .string()
208
- .describe(
209
- 'Pagefind UI translation. English default value: `"[COUNT] result for [SEARCH_TERM]"`. See https://pagefind.app/docs/ui/#translations'
210
- ),
211
-
212
- 'pagefind.alt_search': z
213
- .string()
214
- .describe(
215
- 'Pagefind UI translation. English default value: `"No results for [SEARCH_TERM]. Showing results for [DIFFERENT_TERM] instead"`. See https://pagefind.app/docs/ui/#translations'
216
- ),
217
-
218
- 'pagefind.search_suggestion': z
219
- .string()
220
- .describe(
221
- 'Pagefind UI translation. English default value: `"No results for [SEARCH_TERM]. Try one of the following searches:"`. See https://pagefind.app/docs/ui/#translations'
222
- ),
223
-
224
- 'pagefind.searching': z
225
- .string()
226
- .describe(
227
- 'Pagefind UI translation. English default value: `"Searching for [SEARCH_TERM]..."`. See https://pagefind.app/docs/ui/#translations'
228
- ),
175
+ 'pagefind.clear_search': z.string().meta({
176
+ description:
177
+ 'Pagefind UI translation. English default value: `"Clear"`. See https://pagefind.app/docs/ui/#translations',
178
+ }),
179
+
180
+ 'pagefind.load_more': z.string().meta({
181
+ description:
182
+ 'Pagefind UI translation. English default value: `"Load more results"`. See https://pagefind.app/docs/ui/#translations',
183
+ }),
184
+
185
+ 'pagefind.search_label': z.string().meta({
186
+ description:
187
+ 'Pagefind UI translation. English default value: `"Search this site"`. See https://pagefind.app/docs/ui/#translations',
188
+ }),
189
+
190
+ 'pagefind.filters_label': z.string().meta({
191
+ description:
192
+ 'Pagefind UI translation. English default value: `"Filters"`. See https://pagefind.app/docs/ui/#translations',
193
+ }),
194
+
195
+ 'pagefind.zero_results': z.string().meta({
196
+ description:
197
+ 'Pagefind UI translation. English default value: `"No results for [SEARCH_TERM]"`. See https://pagefind.app/docs/ui/#translations',
198
+ }),
199
+
200
+ 'pagefind.many_results': z.string().meta({
201
+ description:
202
+ 'Pagefind UI translation. English default value: `"[COUNT] results for [SEARCH_TERM]"`. See https://pagefind.app/docs/ui/#translations',
203
+ }),
204
+
205
+ 'pagefind.one_result': z.string().meta({
206
+ description:
207
+ 'Pagefind UI translation. English default value: `"[COUNT] result for [SEARCH_TERM]"`. See https://pagefind.app/docs/ui/#translations',
208
+ }),
209
+
210
+ 'pagefind.alt_search': z.string().meta({
211
+ description:
212
+ 'Pagefind UI translation. English default value: `"No results for [SEARCH_TERM]. Showing results for [DIFFERENT_TERM] instead"`. See https://pagefind.app/docs/ui/#translations',
213
+ }),
214
+
215
+ 'pagefind.search_suggestion': z.string().meta({
216
+ description:
217
+ 'Pagefind UI translation. English default value: `"No results for [SEARCH_TERM]. Try one of the following searches:"`. See https://pagefind.app/docs/ui/#translations',
218
+ }),
219
+
220
+ 'pagefind.searching': z.string().meta({
221
+ description:
222
+ 'Pagefind UI translation. English default value: `"Searching for [SEARCH_TERM]..."`. See https://pagefind.app/docs/ui/#translations',
223
+ }),
229
224
  })
230
225
  .partial();
231
226
  }
@@ -233,17 +228,17 @@ function pagefindI18nSchema() {
233
228
  function expressiveCodeI18nSchema() {
234
229
  return z
235
230
  .object({
236
- 'expressiveCode.copyButtonCopied': z
237
- .string()
238
- .describe('Expressive Code UI translation. English default value: `"Copied!"`'),
231
+ 'expressiveCode.copyButtonCopied': z.string().meta({
232
+ description: 'Expressive Code UI translation. English default value: `"Copied!"`',
233
+ }),
239
234
 
240
- 'expressiveCode.copyButtonTooltip': z
241
- .string()
242
- .describe('Expressive Code UI translation. English default value: `"Copy to clipboard"`'),
235
+ 'expressiveCode.copyButtonTooltip': z.string().meta({
236
+ description: 'Expressive Code UI translation. English default value: `"Copy to clipboard"`',
237
+ }),
243
238
 
244
- 'expressiveCode.terminalWindowFallbackTitle': z
245
- .string()
246
- .describe('Expressive Code UI translation. English default value: `"Terminal window"`'),
239
+ 'expressiveCode.terminalWindowFallbackTitle': z.string().meta({
240
+ description: 'Expressive Code UI translation. English default value: `"Terminal window"`',
241
+ }),
247
242
  })
248
243
  .partial();
249
244
  }
package/schemas/icon.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from 'astro/zod';
2
- import { Icons, type StarlightIcon } from '../components/Icons';
2
+ import { Icons, type StarlightIcon } from '../components-internals/Icons';
3
3
 
4
4
  const iconNames = Object.keys(Icons) as [StarlightIcon, ...StarlightIcon[]];
5
5
 
@@ -57,7 +57,7 @@ const pagefindIndexOptionsSchema = z.object({
57
57
  *
58
58
  * @see https://pagefind.app/docs/multisite/#filtering-results-by-index
59
59
  */
60
- mergeFilter: z.record(z.string(), z.string().or(z.array(z.string()).nonempty())).optional(),
60
+ mergeFilter: z.record(z.string(), z.string().or(z.tuple([z.string()], z.string()))).optional(),
61
61
  /**
62
62
  * Language of this index.
63
63
  *
@@ -68,7 +68,7 @@ const pagefindIndexOptionsSchema = z.object({
68
68
  * Configure how search result rankings are calculated by Pagefind.
69
69
  */
70
70
  // We apply a default value to merged indexes in order to share the same ranking for them and the current site when not set explicitly.
71
- ranking: pagefindRankingWeightsSchema.default({}),
71
+ ranking: pagefindRankingWeightsSchema.prefault({}),
72
72
  });
73
73
 
74
74
  const pagefindSchema = z.object({
@@ -80,7 +80,7 @@ const pagefindSchema = z.object({
80
80
  */
81
81
  indexWeight: indexWeightSchema,
82
82
  /** Configure how search result rankings are calculated by Pagefind. */
83
- ranking: pagefindRankingWeightsSchema.default({}),
83
+ ranking: pagefindRankingWeightsSchema.prefault({}),
84
84
  /**
85
85
  * Configure how search indexes from different sites are merged by Pagefind.
86
86
  *
@@ -93,7 +93,8 @@ const pagefindSchema = z.object({
93
93
  *
94
94
  * @see https://github.com/CloudCannon/pagefind/blob/v1.3.0/pagefind_web_js/lib/coupled_search.ts#L549
95
95
  */
96
- pagefindIndexOptionsSchema.extend({
96
+ z.object({
97
+ ...pagefindIndexOptionsSchema.shape,
97
98
  /**
98
99
  * Set Pagefind’s `bundlePath` mergeIndex option.
99
100
  *
@@ -5,14 +5,12 @@ export const PrevNextLinkConfigSchema = () =>
5
5
  .union([
6
6
  z.boolean(),
7
7
  z.string(),
8
- z
9
- .object({
10
- /** The navigation link URL. */
11
- link: z.string().optional(),
12
- /** The navigation link text. */
13
- label: z.string().optional(),
14
- })
15
- .strict(),
8
+ z.strictObject({
9
+ /** The navigation link URL. */
10
+ link: z.string().optional(),
11
+ /** The navigation link text. */
12
+ label: z.string().optional(),
13
+ }),
16
14
  ])
17
15
  .optional();
18
16