astro 5.13.2 → 5.13.3

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.
@@ -31,10 +31,10 @@ const GET = async ({ request }) => {
31
31
  }
32
32
  let inputBuffer = void 0;
33
33
  const isRemoteImage = isRemotePath(transform.src);
34
- const sourceUrl = isRemoteImage ? new URL(transform.src) : new URL(transform.src, url.origin);
35
34
  if (isRemoteImage && isRemoteAllowed(transform.src, imageConfig) === false) {
36
35
  return new Response("Forbidden", { status: 403 });
37
36
  }
37
+ const sourceUrl = new URL(transform.src, url.origin);
38
38
  inputBuffer = await loadRemoteImage(sourceUrl, isRemoteImage ? new Headers() : request.headers);
39
39
  if (!inputBuffer) {
40
40
  return new Response("Not Found", { status: 404 });
@@ -164,7 +164,7 @@ ${contentConfig.error.message}`);
164
164
  logger.info("Content config changed");
165
165
  shouldClear = true;
166
166
  }
167
- if (previousAstroVersion && previousAstroVersion !== "5.13.2") {
167
+ if (previousAstroVersion && previousAstroVersion !== "5.13.3") {
168
168
  logger.info("Astro version changed");
169
169
  shouldClear = true;
170
170
  }
@@ -172,8 +172,8 @@ ${contentConfig.error.message}`);
172
172
  logger.info("Clearing content store");
173
173
  this.#store.clearAll();
174
174
  }
175
- if ("5.13.2") {
176
- await this.#store.metaStore().set("astro-version", "5.13.2");
175
+ if ("5.13.3") {
176
+ await this.#store.metaStore().set("astro-version", "5.13.3");
177
177
  }
178
178
  if (currentConfigDigest) {
179
179
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -65,6 +65,9 @@ function file(fileName, options) {
65
65
  logger.debug(`Found object with ${entries.length} entries in ${fileName}`);
66
66
  store.clear();
67
67
  for (const [id, rawItem] of entries) {
68
+ if (id === "$schema" && typeof rawItem === "string") {
69
+ continue;
70
+ }
68
71
  const parsedData = await parseData({ id, data: rawItem, filePath });
69
72
  store.set({ id, data: parsedData, filePath: normalizedFilePath });
70
73
  }
@@ -504,6 +504,9 @@ async function generateJSONSchema(fsMod, collectionConfig, collectionKey, collec
504
504
  if (!zodSchemaForJson && collectionConfig.type === CONTENT_LAYER_TYPE) {
505
505
  zodSchemaForJson = await getContentLayerSchema(collectionConfig, collectionKey);
506
506
  }
507
+ if (collectionConfig.type === CONTENT_LAYER_TYPE && collectionConfig.loader.name === "file-loader") {
508
+ zodSchemaForJson = z.object({}).catchall(zodSchemaForJson);
509
+ }
507
510
  if (zodSchemaForJson instanceof z.ZodObject) {
508
511
  zodSchemaForJson = zodSchemaForJson.extend({
509
512
  $schema: z.string().optional()
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "5.13.2";
1
+ const ASTRO_VERSION = "5.13.3";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
4
4
  const REWRITE_DIRECTIVE_HEADER_VALUE = "yes";
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
22
22
  await telemetry.record([]);
23
23
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
24
24
  const logger = restart.container.logger;
25
- const currentVersion = "5.13.2";
25
+ const currentVersion = "5.13.3";
26
26
  const isPrerelease = currentVersion.includes("-");
27
27
  if (!isPrerelease) {
28
28
  try {
@@ -37,7 +37,7 @@ function serverStart({
37
37
  host,
38
38
  base
39
39
  }) {
40
- const version = "5.13.2";
40
+ const version = "5.13.3";
41
41
  const localPrefix = `${dim("\u2503")} Local `;
42
42
  const networkPrefix = `${dim("\u2503")} Network `;
43
43
  const emptyPrefix = " ".repeat(11);
@@ -274,7 +274,7 @@ function printHelp({
274
274
  message.push(
275
275
  linebreak(),
276
276
  ` ${bgGreen(black(` ${commandName} `))} ${green(
277
- `v${"5.13.2"}`
277
+ `v${"5.13.3"}`
278
278
  )} ${headline}`
279
279
  );
280
280
  }
@@ -117,7 +117,7 @@ async function syncInternal({
117
117
  settings.timer.end("Sync content layer");
118
118
  } else {
119
119
  const paths = getContentPaths(settings.config, fs);
120
- if (paths.config.exists || // Legacy collections don't require a config file
120
+ if (paths.config.exists || paths.liveConfig.exists || // Legacy collections don't require a config file
121
121
  settings.config.legacy?.collections && fs.existsSync(paths.contentDir)) {
122
122
  settings.injectedTypes.push({
123
123
  filename: CONTENT_TYPES_FILE
@@ -74,6 +74,12 @@ export declare function getLocaleByPath(path: string, locales: Locales): string;
74
74
  * - transforms all letters to be lower case;
75
75
  */
76
76
  export declare function normalizeTheLocale(locale: string): string;
77
+ /**
78
+ *
79
+ * Given a path or path segment, this function:
80
+ * - removes the `.html` extension if it exists
81
+ */
82
+ export declare function normalizeThePath(path: string): string;
77
83
  /**
78
84
  * Returns an array of only locales, by picking the `code`
79
85
  * @param locales
@@ -10,7 +10,7 @@ function requestHasLocale(locales) {
10
10
  };
11
11
  }
12
12
  function pathHasLocale(path, locales) {
13
- const segments = path.split("/");
13
+ const segments = path.split("/").map(normalizeThePath);
14
14
  for (const segment of segments) {
15
15
  for (const locale of locales) {
16
16
  if (typeof locale === "string") {
@@ -132,6 +132,9 @@ function getLocaleByPath(path, locales) {
132
132
  function normalizeTheLocale(locale) {
133
133
  return locale.replaceAll("_", "-").toLowerCase();
134
134
  }
135
+ function normalizeThePath(path) {
136
+ return path.endsWith(".html") ? path.slice(0, -5) : path;
137
+ }
135
138
  function getAllCodes(locales) {
136
139
  const result = [];
137
140
  for (const loopLocale of locales) {
@@ -277,6 +280,7 @@ export {
277
280
  getLocaleRelativeUrlList,
278
281
  getPathByLocale,
279
282
  normalizeTheLocale,
283
+ normalizeThePath,
280
284
  notFound,
281
285
  pathHasLocale,
282
286
  redirectToDefaultLocale,
@@ -1,4 +1,4 @@
1
- import { getAllCodes, normalizeTheLocale } from "./index.js";
1
+ import { getAllCodes, normalizeTheLocale, normalizeThePath } from "./index.js";
2
2
  function parseLocale(header) {
3
3
  if (header === "*") {
4
4
  return [{ locale: header, qualityValue: void 0 }];
@@ -102,7 +102,7 @@ function computePreferredLocaleList(request, locales) {
102
102
  return result;
103
103
  }
104
104
  function computeCurrentLocale(pathname, locales, defaultLocale) {
105
- for (const segment of pathname.split("/")) {
105
+ for (const segment of pathname.split("/").map(normalizeThePath)) {
106
106
  for (const locale of locales) {
107
107
  if (typeof locale === "string") {
108
108
  if (!segment.includes(locale)) continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "5.13.2",
3
+ "version": "5.13.3",
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",