@analogjs/vite-plugin-nitro 2.8.0-beta.10 → 2.8.0-beta.11
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/package.json
CHANGED
|
@@ -8,6 +8,7 @@ import { I18nPrerenderOptions } from '../options.js';
|
|
|
8
8
|
*
|
|
9
9
|
* The default locale's routes are included both with and without the prefix
|
|
10
10
|
* so that `/about` and `/en/about` both render.
|
|
11
|
+
* Routes that already have a configured locale prefix are kept as-is.
|
|
11
12
|
*
|
|
12
13
|
* @param routes - The original routes to expand
|
|
13
14
|
* @param i18n - The i18n prerender configuration
|
|
@@ -6,30 +6,32 @@
|
|
|
6
6
|
*
|
|
7
7
|
* The default locale's routes are included both with and without the prefix
|
|
8
8
|
* so that `/about` and `/en/about` both render.
|
|
9
|
+
* Routes that already have a configured locale prefix are kept as-is.
|
|
9
10
|
*
|
|
10
11
|
* @param routes - The original routes to expand
|
|
11
12
|
* @param i18n - The i18n prerender configuration
|
|
12
13
|
* @returns Expanded routes with locale prefixes
|
|
13
14
|
*/
|
|
14
15
|
export function expandRoutesWithLocales(routes, i18n) {
|
|
15
|
-
const expanded =
|
|
16
|
+
const expanded = new Set();
|
|
16
17
|
for (const route of routes) {
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
// API routes and explicitly localized routes don't need locale prefixes.
|
|
19
|
+
const firstSegment = route.split('/').filter(Boolean)[0];
|
|
20
|
+
if (route.includes('/_analog/') ||
|
|
21
|
+
route.startsWith('/api/') ||
|
|
22
|
+
i18n.locales.includes(firstSegment)) {
|
|
23
|
+
expanded.add(route);
|
|
20
24
|
continue;
|
|
21
25
|
}
|
|
22
26
|
for (const locale of i18n.locales) {
|
|
23
27
|
const prefix = `/${locale}`;
|
|
24
28
|
const localizedRoute = route === '/' ? prefix : `${prefix}${route}`;
|
|
25
|
-
expanded.
|
|
29
|
+
expanded.add(localizedRoute);
|
|
26
30
|
}
|
|
27
31
|
// Keep the unprefixed route for the default locale
|
|
28
|
-
|
|
29
|
-
expanded.push(route);
|
|
30
|
-
}
|
|
32
|
+
expanded.add(route);
|
|
31
33
|
}
|
|
32
|
-
return expanded;
|
|
34
|
+
return [...expanded];
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
35
37
|
* Creates a post-rendering hook that injects the `lang` attribute
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-prerender.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-nitro/src/lib/utils/i18n-prerender.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"i18n-prerender.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-nitro/src/lib/utils/i18n-prerender.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAgB,EAChB,IAA0B;IAE1B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAEnC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,yEAAyE;QACzE,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACzD,IACE,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC;YAC3B,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;YACzB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,EACnC,CAAC;YACD,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACpB,SAAS;QACX,CAAC;QAED,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YAC5B,MAAM,cAAc,GAAG,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,KAAK,EAAE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