@astrojs/starlight 0.32.5 → 0.32.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/utils/routing/types.ts +2 -2
- package/utils/starlight-page.ts +1 -4
- package/utils/user-config.ts +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.32.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#3030](https://github.com/withastro/starlight/pull/3030) [`5bdf139`](https://github.com/withastro/starlight/commit/5bdf139191a20f19458b027617877c1063b46724) Thanks [@trueberryless](https://github.com/trueberryless)! - Updates the type of the `isFallback` field in route data from `true` to `boolean`, keeping it optional but allowing `false` as a possible value.
|
|
8
|
+
|
|
9
|
+
- [#3018](https://github.com/withastro/starlight/pull/3018) [`188b8cf`](https://github.com/withastro/starlight/commit/188b8cfa8ad8761365b8b557c4b9fea671050ed6) Thanks [@trueberryless](https://github.com/trueberryless)! - Adds validation for user config `routeMiddleware` so it does not conflict with [Astro's middleware](https://docs.astro.build/en/guides/middleware/).
|
|
10
|
+
|
|
3
11
|
## 0.32.5
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/package.json
CHANGED
package/utils/routing/types.ts
CHANGED
|
@@ -67,8 +67,8 @@ export interface Route extends LocaleData {
|
|
|
67
67
|
slug: string;
|
|
68
68
|
/** The slug or unique ID if using the `legacy.collections` flag. */
|
|
69
69
|
id: string;
|
|
70
|
-
/**
|
|
71
|
-
isFallback?:
|
|
70
|
+
/** Whether this page is untranslated in the current language and using fallback content from the default locale. */
|
|
71
|
+
isFallback?: boolean;
|
|
72
72
|
[key: string]: unknown;
|
|
73
73
|
}
|
|
74
74
|
|
package/utils/starlight-page.ts
CHANGED
|
@@ -105,7 +105,7 @@ export async function generateStarlightPageRouteData({
|
|
|
105
105
|
props: StarlightPageProps;
|
|
106
106
|
url: URL;
|
|
107
107
|
}): Promise<StarlightRouteData> {
|
|
108
|
-
const {
|
|
108
|
+
const { frontmatter, ...routeProps } = props;
|
|
109
109
|
const slug = urlToSlug(url);
|
|
110
110
|
const pageFrontmatter = await getStarlightPageFrontmatter(frontmatter);
|
|
111
111
|
const id = project.legacyCollections ? `${stripLeadingAndTrailingSlashes(slug)}.md` : slug;
|
|
@@ -163,9 +163,6 @@ export async function generateStarlightPageRouteData({
|
|
|
163
163
|
slug,
|
|
164
164
|
}),
|
|
165
165
|
};
|
|
166
|
-
if (isFallback) {
|
|
167
|
-
routeData.isFallback = true;
|
|
168
|
-
}
|
|
169
166
|
return routeData;
|
|
170
167
|
}
|
|
171
168
|
|
package/utils/user-config.ts
CHANGED
|
@@ -233,6 +233,21 @@ const UserConfigSchema = z.object({
|
|
|
233
233
|
.transform((string) => [string])
|
|
234
234
|
.or(z.string().array())
|
|
235
235
|
.default([])
|
|
236
|
+
.superRefine((middlewares, ctx) => {
|
|
237
|
+
// Regex pattern to match invalid middleware paths: https://regex101.com/r/kQH7xm/2
|
|
238
|
+
const invalidPathRegex = /^\.?\/src\/middleware(?:\/index)?\.[jt]s$/;
|
|
239
|
+
const invalidPaths = middlewares.filter((middleware) => invalidPathRegex.test(middleware));
|
|
240
|
+
for (const invalidPath of invalidPaths) {
|
|
241
|
+
ctx.addIssue({
|
|
242
|
+
code: 'custom',
|
|
243
|
+
message:
|
|
244
|
+
`The \`"${invalidPath}"\` path in your Starlight \`routeMiddleware\` config conflicts with Astro’s middleware locations.\n\n` +
|
|
245
|
+
`You should rename \`${invalidPath}\` to something else like \`./src/starlightRouteData.ts\` and update the \`routeMiddleware\` file path to match.\n\n` +
|
|
246
|
+
'- More about Starlight route middleware: https://starlight.astro.build/guides/route-data/#how-to-customize-route-data\n' +
|
|
247
|
+
'- More about Astro middleware: https://docs.astro.build/en/guides/middleware/',
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
})
|
|
236
251
|
.describe('Add middleware to process Starlight’s route data for each page.'),
|
|
237
252
|
});
|
|
238
253
|
|