astro 3.5.0 → 3.5.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/@types/astro.d.ts +13 -8
- package/dist/assets/vite-plugin-assets.js +9 -3
- package/dist/cli/info/index.js +7 -3
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/logger/node.js +1 -0
- package/dist/core/messages.js +2 -2
- package/dist/core/render/route-cache.js +15 -17
- package/dist/core/routing/manifest/create.js +6 -7
- package/package.json +3 -3
package/dist/@types/astro.d.ts
CHANGED
|
@@ -1345,6 +1345,8 @@ export interface AstroUserConfig {
|
|
|
1345
1345
|
* @description
|
|
1346
1346
|
*
|
|
1347
1347
|
* Configures experimental i18n routing and allows you to specify some customization options.
|
|
1348
|
+
*
|
|
1349
|
+
* See our guide for more information on [internationalization in Astro](/en/guides/internationalization/)
|
|
1348
1350
|
*/
|
|
1349
1351
|
i18n?: {
|
|
1350
1352
|
/**
|
|
@@ -1355,6 +1357,8 @@ export interface AstroUserConfig {
|
|
|
1355
1357
|
* @description
|
|
1356
1358
|
*
|
|
1357
1359
|
* The default locale of your website/application. This is a required field.
|
|
1360
|
+
*
|
|
1361
|
+
* No particular language format or syntax is enforced, but we suggest using lower-case and hyphens as needed (e.g. "es", "pt-br") for greatest compatibility.
|
|
1358
1362
|
*/
|
|
1359
1363
|
defaultLocale: string;
|
|
1360
1364
|
/**
|
|
@@ -1364,7 +1368,7 @@ export interface AstroUserConfig {
|
|
|
1364
1368
|
* @version 3.5.0
|
|
1365
1369
|
* @description
|
|
1366
1370
|
*
|
|
1367
|
-
* A list of all locales supported by the website (e.g. `['en', 'es', '
|
|
1371
|
+
* A list of all locales supported by the website (e.g. `['en', 'es', 'pt-br']`). This list should also include the `defaultLocale`. This is a required field.
|
|
1368
1372
|
*
|
|
1369
1373
|
* No particular language format or syntax is enforced, but your folder structure must match exactly the locales in the list.
|
|
1370
1374
|
*/
|
|
@@ -1382,14 +1386,14 @@ export interface AstroUserConfig {
|
|
|
1382
1386
|
*
|
|
1383
1387
|
* #### Example
|
|
1384
1388
|
*
|
|
1385
|
-
* The following example configures your content fallback strategy to redirect unavailable pages in `/pt/` to their `es` version, and unavailable pages in `/fr/` to their `en` version. Unavailable `/es/` pages will return a 404.
|
|
1389
|
+
* The following example configures your content fallback strategy to redirect unavailable pages in `/pt-br/` to their `es` version, and unavailable pages in `/fr/` to their `en` version. Unavailable `/es/` pages will return a 404.
|
|
1386
1390
|
*
|
|
1387
1391
|
* ```js
|
|
1388
1392
|
* export defualt defineConfig({
|
|
1389
1393
|
* experimental: {
|
|
1390
1394
|
* i18n: {
|
|
1391
1395
|
* defaultLocale: "en",
|
|
1392
|
-
* locales: ["en", "fr", "pt", "es"],
|
|
1396
|
+
* locales: ["en", "fr", "pt-br", "es"],
|
|
1393
1397
|
* fallback: {
|
|
1394
1398
|
* pt: "es",
|
|
1395
1399
|
* fr: "en"
|
|
@@ -1408,14 +1412,15 @@ export interface AstroUserConfig {
|
|
|
1408
1412
|
* @version 3.5.0
|
|
1409
1413
|
* @description
|
|
1410
1414
|
*
|
|
1411
|
-
* Controls the routing strategy to determine your site URLs.
|
|
1415
|
+
* Controls the routing strategy to determine your site URLs. Set this based on your folder/URL path configuration for your default language:
|
|
1412
1416
|
*
|
|
1413
|
-
* - `prefix-other-locales`(default): Only non-default languages will display a language prefix.
|
|
1414
|
-
*
|
|
1417
|
+
* - `prefix-other-locales`(default): Only non-default languages will display a language prefix.
|
|
1418
|
+
* The `defaultLocale` will not show a language prefix and content files do not exist in a localized folder.
|
|
1419
|
+
* URLs will be of the form `example.com/[locale]/content/` for all non-default languages, but `example.com/content/` for the default locale.
|
|
1415
1420
|
* - `prefix-always`: All URLs will display a language prefix.
|
|
1416
|
-
* URLs will be of the form `example.com/[
|
|
1421
|
+
* URLs will be of the form `example.com/[locale]/content/` for every route, including the default language.
|
|
1422
|
+
* Localized folders are used for every language, including the default.
|
|
1417
1423
|
*
|
|
1418
|
-
* Note: Astro requires all content to exist within a `/[lang]/` folder, even for the default language.
|
|
1419
1424
|
*/
|
|
1420
1425
|
routingStrategy?: 'prefix-always' | 'prefix-other-locales';
|
|
1421
1426
|
};
|
|
@@ -136,7 +136,7 @@ function assets({
|
|
|
136
136
|
configResolved(viteConfig) {
|
|
137
137
|
resolvedConfig = viteConfig;
|
|
138
138
|
},
|
|
139
|
-
async load(id) {
|
|
139
|
+
async load(id, options) {
|
|
140
140
|
if (id !== removeQueryString(id)) {
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
@@ -148,8 +148,14 @@ function assets({
|
|
|
148
148
|
message: AstroErrorData.ImageNotFound.message(id)
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
if (options?.ssr) {
|
|
152
|
+
return `export default ${getProxyCode(meta, isServerLikeOutput(settings.config))}`;
|
|
153
|
+
} else {
|
|
154
|
+
if (!globalThis.astroAsset.referencedImages)
|
|
155
|
+
globalThis.astroAsset.referencedImages = /* @__PURE__ */ new Set();
|
|
156
|
+
globalThis.astroAsset.referencedImages.add(meta.fsPath);
|
|
157
|
+
return `export default ${JSON.stringify(meta)}`;
|
|
158
|
+
}
|
|
153
159
|
}
|
|
154
160
|
}
|
|
155
161
|
}
|
package/dist/cli/info/index.js
CHANGED
|
@@ -35,11 +35,15 @@ async function copyToClipboard(text) {
|
|
|
35
35
|
} else if (system === "win32") {
|
|
36
36
|
command = "clip";
|
|
37
37
|
} else {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
try {
|
|
39
|
+
const output = execSync("which xclip", { encoding: "utf8" });
|
|
40
|
+
if (output[0] !== "/") {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
command = "xclip -sel clipboard -l 1";
|
|
44
|
+
} catch (e) {
|
|
40
45
|
return;
|
|
41
46
|
}
|
|
42
|
-
command = "xclip -sel clipboard -l 1";
|
|
43
47
|
}
|
|
44
48
|
console.log();
|
|
45
49
|
const { shouldCopy } = await prompts({
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -20,7 +20,7 @@ async function dev(inlineConfig) {
|
|
|
20
20
|
base: restart.container.settings.config.base
|
|
21
21
|
})
|
|
22
22
|
);
|
|
23
|
-
const currentVersion = "3.5.
|
|
23
|
+
const currentVersion = "3.5.1";
|
|
24
24
|
if (currentVersion.includes("-")) {
|
|
25
25
|
logger.warn(null, msg.prerelease({ currentVersion }));
|
|
26
26
|
}
|
package/dist/core/logger/node.js
CHANGED
package/dist/core/messages.js
CHANGED
|
@@ -50,7 +50,7 @@ function serverStart({
|
|
|
50
50
|
base,
|
|
51
51
|
isRestart = false
|
|
52
52
|
}) {
|
|
53
|
-
const version = "3.5.
|
|
53
|
+
const version = "3.5.1";
|
|
54
54
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
55
55
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
56
56
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -235,7 +235,7 @@ function printHelp({
|
|
|
235
235
|
message.push(
|
|
236
236
|
linebreak(),
|
|
237
237
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
238
|
-
`v${"3.5.
|
|
238
|
+
`v${"3.5.1"}`
|
|
239
239
|
)} ${headline}`
|
|
240
240
|
);
|
|
241
241
|
}
|
|
@@ -10,32 +10,30 @@ async function callGetStaticPaths({
|
|
|
10
10
|
ssr
|
|
11
11
|
}) {
|
|
12
12
|
const cached = routeCache.get(route);
|
|
13
|
-
if (
|
|
13
|
+
if (!mod) {
|
|
14
|
+
throw new Error("This is an error caused by Astro and not your code. Please file an issue.");
|
|
15
|
+
}
|
|
16
|
+
if (cached?.staticPaths) {
|
|
14
17
|
return cached.staticPaths;
|
|
15
|
-
if (mod) {
|
|
16
|
-
validateDynamicRouteModule(mod, { ssr, route });
|
|
17
18
|
}
|
|
19
|
+
validateDynamicRouteModule(mod, { ssr, route });
|
|
18
20
|
if (ssr && !route.prerender) {
|
|
19
21
|
const entry = Object.assign([], { keyed: /* @__PURE__ */ new Map() });
|
|
20
22
|
routeCache.set(route, { ...cached, staticPaths: entry });
|
|
21
23
|
return entry;
|
|
22
24
|
}
|
|
23
25
|
let staticPaths = [];
|
|
24
|
-
if (mod) {
|
|
25
|
-
|
|
26
|
-
throw new Error("Unexpected Error.");
|
|
27
|
-
}
|
|
28
|
-
if (mod) {
|
|
29
|
-
staticPaths = await mod.getStaticPaths({
|
|
30
|
-
// Q: Why the cast?
|
|
31
|
-
// A: So users downstream can have nicer typings, we have to make some sacrifice in our internal typings, which necessitate a cast here
|
|
32
|
-
paginate: generatePaginateFunction(route),
|
|
33
|
-
rss() {
|
|
34
|
-
throw new AstroError(AstroErrorData.GetStaticPathsRemovedRSSHelper);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
26
|
+
if (!mod.getStaticPaths) {
|
|
27
|
+
throw new Error("Unexpected Error.");
|
|
38
28
|
}
|
|
29
|
+
staticPaths = await mod.getStaticPaths({
|
|
30
|
+
// Q: Why the cast?
|
|
31
|
+
// A: So users downstream can have nicer typings, we have to make some sacrifice in our internal typings, which necessitate a cast here
|
|
32
|
+
paginate: generatePaginateFunction(route),
|
|
33
|
+
rss() {
|
|
34
|
+
throw new AstroError(AstroErrorData.GetStaticPathsRemovedRSSHelper);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
39
37
|
validateGetStaticPathsResult(staticPaths, logger, route);
|
|
40
38
|
const keyedStaticPaths = staticPaths;
|
|
41
39
|
keyedStaticPaths.keyed = /* @__PURE__ */ new Map();
|
|
@@ -34,9 +34,8 @@ function getParts(part, file) {
|
|
|
34
34
|
});
|
|
35
35
|
return result;
|
|
36
36
|
}
|
|
37
|
-
function getPattern(segments, config) {
|
|
37
|
+
function getPattern(segments, config, addTrailingSlash) {
|
|
38
38
|
const base = config.base;
|
|
39
|
-
const addTrailingSlash = config.trailingSlash;
|
|
40
39
|
const pathname = segments.map((segment) => {
|
|
41
40
|
if (segment.length === 1 && segment[0].spread) {
|
|
42
41
|
return "(?:\\/(.*?))?";
|
|
@@ -224,7 +223,7 @@ function createRouteManifest({ settings, cwd, fsMod }, logger) {
|
|
|
224
223
|
components.push(item.file);
|
|
225
224
|
const component = item.file;
|
|
226
225
|
const trailingSlash = item.isPage ? settings.config.trailingSlash : "never";
|
|
227
|
-
const pattern = getPattern(segments, settings.config);
|
|
226
|
+
const pattern = getPattern(segments, settings.config, trailingSlash);
|
|
228
227
|
const generate = getRouteGenerator(segments, trailingSlash);
|
|
229
228
|
const pathname = segments.every((segment) => segment.length === 1 && !segment[0].dynamic) ? `/${segments.map((segment) => segment[0].content).join("/")}` : null;
|
|
230
229
|
const route = `/${segments.map(([{ dynamic, content }]) => dynamic ? `[${content}]` : content).join("/")}`.toLowerCase();
|
|
@@ -270,7 +269,7 @@ function createRouteManifest({ settings, cwd, fsMod }, logger) {
|
|
|
270
269
|
const type = resolved.endsWith(".astro") ? "page" : "endpoint";
|
|
271
270
|
const isPage = type === "page";
|
|
272
271
|
const trailingSlash = isPage ? config.trailingSlash : "never";
|
|
273
|
-
const pattern = getPattern(segments, settings.config);
|
|
272
|
+
const pattern = getPattern(segments, settings.config, trailingSlash);
|
|
274
273
|
const generate = getRouteGenerator(segments, trailingSlash);
|
|
275
274
|
const pathname = segments.every((segment) => segment.length === 1 && !segment[0].dynamic) ? `/${segments.map((segment) => segment[0].content).join("/")}` : null;
|
|
276
275
|
const params = segments.flat().filter((p) => p.dynamic).map((p) => p.content);
|
|
@@ -300,7 +299,7 @@ This route collides with: "${collision.component}".`
|
|
|
300
299
|
validateSegment(s);
|
|
301
300
|
return getParts(s, from);
|
|
302
301
|
});
|
|
303
|
-
const pattern = getPattern(segments, settings.config);
|
|
302
|
+
const pattern = getPattern(segments, settings.config, trailingSlash);
|
|
304
303
|
const generate = getRouteGenerator(segments, trailingSlash);
|
|
305
304
|
const pathname = segments.every((segment) => segment.length === 1 && !segment[0].dynamic) ? `/${segments.map((segment) => segment[0].content).join("/")}` : null;
|
|
306
305
|
const params = segments.flat().filter((p) => p.dynamic).map((p) => p.content);
|
|
@@ -383,7 +382,7 @@ This route collides with: "${collision.component}".`
|
|
|
383
382
|
pathname,
|
|
384
383
|
route,
|
|
385
384
|
segments,
|
|
386
|
-
pattern: getPattern(segments, config),
|
|
385
|
+
pattern: getPattern(segments, config, config.trailingSlash),
|
|
387
386
|
type: "fallback"
|
|
388
387
|
});
|
|
389
388
|
}
|
|
@@ -439,7 +438,7 @@ This route collides with: "${collision.component}".`
|
|
|
439
438
|
pathname,
|
|
440
439
|
route,
|
|
441
440
|
segments,
|
|
442
|
-
pattern: getPattern(segments, config),
|
|
441
|
+
pattern: getPattern(segments, config, config.trailingSlash),
|
|
443
442
|
type: "fallback"
|
|
444
443
|
});
|
|
445
444
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.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",
|
|
@@ -165,8 +165,8 @@
|
|
|
165
165
|
"yargs-parser": "^21.1.1",
|
|
166
166
|
"zod": "^3.22.4",
|
|
167
167
|
"@astrojs/internal-helpers": "0.2.1",
|
|
168
|
-
"@astrojs/
|
|
169
|
-
"@astrojs/
|
|
168
|
+
"@astrojs/telemetry": "3.0.4",
|
|
169
|
+
"@astrojs/markdown-remark": "3.4.0"
|
|
170
170
|
},
|
|
171
171
|
"optionalDependencies": {
|
|
172
172
|
"sharp": "^0.32.5"
|