astro 4.6.0 → 4.6.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.
@@ -1725,7 +1725,7 @@ export interface AstroUserConfig {
1725
1725
  * });
1726
1726
  * ```
1727
1727
  *
1728
- * Both page routes built and URLs returned by the `astro:i18n` helper functions [`getAbsoluteLocaleUrl()`](https://docs.astro.build/en/guides/internationalization/#getabsolutelocaleurl) and [`getAbsoluteLocaleUrlList()`](https://docs.astro.build/en/guides/internationalization/#getabsolutelocaleurllist) will use the options set in `i18n.domains`.
1728
+ * Both page routes built and URLs returned by the `astro:i18n` helper functions [`getAbsoluteLocaleUrl()`](https://docs.astro.build/en/reference/api-reference/#getabsolutelocaleurl) and [`getAbsoluteLocaleUrlList()`](https://docs.astro.build/en/reference/api-reference/#getabsolutelocaleurllist) will use the options set in `i18n.domains`.
1729
1729
  *
1730
1730
  * See the [Internationalization Guide](https://docs.astro.build/en/guides/internationalization/#domains-experimental) for more details, including the limitations of this experimental feature.
1731
1731
  */
@@ -1,3 +1,4 @@
1
+ import pLimit from "p-limit";
1
2
  import { ZodIssueCode, string as zodString } from "zod";
2
3
  import { AstroError, AstroErrorData } from "../core/errors/index.js";
3
4
  import { prependForwardSlash } from "../core/path.js";
@@ -58,28 +59,31 @@ function createGetCollection({
58
59
  if (!import.meta.env?.DEV && cacheEntriesByCollection.has(collection)) {
59
60
  entries = [...cacheEntriesByCollection.get(collection)];
60
61
  } else {
62
+ const limit = pLimit(10);
61
63
  entries = await Promise.all(
62
- lazyImports.map(async (lazyImport) => {
63
- const entry = await lazyImport();
64
- return type === "content" ? {
65
- id: entry.id,
66
- slug: entry.slug,
67
- body: entry.body,
68
- collection: entry.collection,
69
- data: entry.data,
70
- async render() {
71
- return render({
72
- collection: entry.collection,
73
- id: entry.id,
74
- renderEntryImport: await getRenderEntryImport(collection, entry.slug)
75
- });
76
- }
77
- } : {
78
- id: entry.id,
79
- collection: entry.collection,
80
- data: entry.data
81
- };
82
- })
64
+ lazyImports.map(
65
+ (lazyImport) => limit(async () => {
66
+ const entry = await lazyImport();
67
+ return type === "content" ? {
68
+ id: entry.id,
69
+ slug: entry.slug,
70
+ body: entry.body,
71
+ collection: entry.collection,
72
+ data: entry.data,
73
+ async render() {
74
+ return render({
75
+ collection: entry.collection,
76
+ id: entry.id,
77
+ renderEntryImport: await getRenderEntryImport(collection, entry.slug)
78
+ });
79
+ }
80
+ } : {
81
+ id: entry.id,
82
+ collection: entry.collection,
83
+ data: entry.data
84
+ };
85
+ })
86
+ )
83
87
  );
84
88
  cacheEntriesByCollection.set(collection, entries);
85
89
  }
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "4.6.0";
1
+ const ASTRO_VERSION = "4.6.1";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const ROUTE_TYPE_HEADER = "X-Astro-Route-Type";
4
4
  const DEFAULT_404_COMPONENT = "astro-default-404";
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
23
23
  base: restart.container.settings.config.base
24
24
  })
25
25
  );
26
- const currentVersion = "4.6.0";
26
+ const currentVersion = "4.6.1";
27
27
  if (currentVersion.includes("-")) {
28
28
  logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
29
29
  }
@@ -340,7 +340,7 @@ const MissingIndexForInternationalization = {
340
340
  const IncorrectStrategyForI18n = {
341
341
  name: "IncorrectStrategyForI18n",
342
342
  title: "You can't use the current function with the current strategy",
343
- message: (functionName) => `The function \`${functionName}' can only be used when the \`i18n.routing.strategy\` is set to \`"manual"\`.`
343
+ message: (functionName) => `The function \`${functionName}\` can only be used when the \`i18n.routing.strategy\` is set to \`"manual"\`.`
344
344
  };
345
345
  const NoPrerenderedRoutesWithDomains = {
346
346
  name: "NoPrerenderedRoutesWithDomains",
@@ -36,7 +36,7 @@ function serverStart({
36
36
  host,
37
37
  base
38
38
  }) {
39
- const version = "4.6.0";
39
+ const version = "4.6.1";
40
40
  const localPrefix = `${dim("\u2503")} Local `;
41
41
  const networkPrefix = `${dim("\u2503")} Network `;
42
42
  const emptyPrefix = " ".repeat(11);
@@ -261,7 +261,7 @@ function printHelp({
261
261
  message.push(
262
262
  linebreak(),
263
263
  ` ${bgGreen(black(` ${commandName} `))} ${green(
264
- `v${"4.6.0"}`
264
+ `v${"4.6.1"}`
265
265
  )} ${headline}`
266
266
  );
267
267
  }
@@ -216,7 +216,8 @@ class RenderContext {
216
216
  };
217
217
  const slots = new Slots(result, slotValues, pipeline.logger);
218
218
  const astroGlobalCombined = {
219
- ...astroGlobalPartial,
219
+ generator: astroGlobalPartial.generator,
220
+ glob: astroGlobalPartial.glob,
220
221
  cookies,
221
222
  get clientAddress() {
222
223
  return renderContext.clientAddress();
@@ -95,6 +95,6 @@ export type MiddlewarePayload = {
95
95
  export declare function redirectToDefaultLocale({ trailingSlash, format, base, defaultLocale, }: MiddlewarePayload): (context: APIContext, statusCode?: ValidRedirectStatus) => Response;
96
96
  export declare function notFound({ base, locales }: MiddlewarePayload): (context: APIContext, response?: Response) => Response | undefined;
97
97
  export type RedirectToFallback = (context: APIContext, response: Response) => Response;
98
- export declare function redirectToFallback({ fallback, locales, defaultLocale, strategy, }: MiddlewarePayload): (context: APIContext, response: Response) => Response;
98
+ export declare function redirectToFallback({ fallback, locales, defaultLocale, strategy, base, }: MiddlewarePayload): (context: APIContext, response: Response) => Response;
99
99
  export declare function createMiddleware(i18nManifest: SSRManifest['i18n'], base: SSRManifest['base'], trailingSlash: SSRManifest['trailingSlash'], format: SSRManifest['buildFormat']): import("../@types/astro.js").MiddlewareHandler;
100
100
  export {};
@@ -210,7 +210,8 @@ function redirectToFallback({
210
210
  fallback,
211
211
  locales,
212
212
  defaultLocale,
213
- strategy
213
+ strategy,
214
+ base
214
215
  }) {
215
216
  return function(context, response) {
216
217
  if (response.status >= 300 && fallback) {
@@ -233,7 +234,11 @@ function redirectToFallback({
233
234
  const pathFallbackLocale = getPathByLocale(fallbackLocale, locales);
234
235
  let newPathname;
235
236
  if (pathFallbackLocale === defaultLocale && strategy === "pathname-prefix-other-locales") {
236
- newPathname = context.url.pathname.replace(`/${urlLocale}`, ``);
237
+ if (context.url.pathname.includes(`${base}`)) {
238
+ newPathname = context.url.pathname.replace(`/${urlLocale}`, ``);
239
+ } else {
240
+ newPathname = context.url.pathname.replace(`/${urlLocale}`, `/`);
241
+ }
237
242
  } else {
238
243
  newPathname = context.url.pathname.replace(`/${urlLocale}`, `/${pathFallbackLocale}`);
239
244
  }
@@ -1,6 +1,5 @@
1
1
  import { ROUTE_TYPE_HEADER } from "../core/constants.js";
2
2
  import {
3
- getPathByLocale,
4
3
  normalizeTheLocale,
5
4
  notFound,
6
5
  redirectToDefaultLocale,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.6.0",
3
+ "version": "4.6.1",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",