astro 4.2.7 → 4.2.8
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/content/utils.d.ts +1 -1
- package/dist/content/utils.js +23 -11
- package/dist/core/build/generate.js +3 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/runtime/server/endpoint.js +3 -1
- package/dist/vite-plugin-astro-server/response.js +1 -5
- package/dist/vite-plugin-markdown/content-entry-type.js +4 -3
- package/dist/vite-plugin-markdown/index.js +3 -26
- package/package.json +3 -3
package/dist/content/utils.d.ts
CHANGED
|
@@ -119,7 +119,7 @@ export declare function getContentEntryIdAndSlug({ entry, contentDir, collection
|
|
|
119
119
|
};
|
|
120
120
|
export declare function getEntryType(entryPath: string, paths: Pick<ContentPaths, 'config' | 'contentDir'>, contentFileExts: string[], dataFileExts: string[]): 'content' | 'data' | 'config' | 'ignored';
|
|
121
121
|
export declare function hasUnderscoreBelowContentDirectoryPath(fileUrl: URL, contentDir: ContentPaths['contentDir']): boolean;
|
|
122
|
-
export declare function
|
|
122
|
+
export declare function safeParseFrontmatter(source: string, id?: string): matter.GrayMatterFile<string>;
|
|
123
123
|
/**
|
|
124
124
|
* The content config is loaded separately from other `src/` files.
|
|
125
125
|
* This global observable lets dependent plugins (like the content flag plugin)
|
package/dist/content/utils.js
CHANGED
|
@@ -6,7 +6,8 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
6
6
|
import { normalizePath } from "vite";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
9
|
-
import {
|
|
9
|
+
import { MarkdownError } from "../core/errors/index.js";
|
|
10
|
+
import { isYAMLException } from "../core/errors/utils.js";
|
|
10
11
|
import { CONTENT_FLAGS, CONTENT_TYPES_FILE } from "./consts.js";
|
|
11
12
|
import { errorMap } from "./error-map.js";
|
|
12
13
|
import { createImage } from "./runtime-assets.js";
|
|
@@ -199,16 +200,27 @@ function getYAMLErrorLine(rawData, objectKey) {
|
|
|
199
200
|
const numNewlinesBeforeKey = dataBeforeKey.split("\n").length;
|
|
200
201
|
return numNewlinesBeforeKey;
|
|
201
202
|
}
|
|
202
|
-
function
|
|
203
|
+
function safeParseFrontmatter(source, id) {
|
|
203
204
|
try {
|
|
204
|
-
matter
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
205
|
+
return matter(source);
|
|
206
|
+
} catch (err) {
|
|
207
|
+
const markdownError = new MarkdownError({
|
|
208
|
+
name: "MarkdownError",
|
|
209
|
+
message: err.message,
|
|
210
|
+
stack: err.stack,
|
|
211
|
+
location: id ? {
|
|
212
|
+
file: id
|
|
213
|
+
} : void 0
|
|
214
|
+
});
|
|
215
|
+
if (isYAMLException(err)) {
|
|
216
|
+
markdownError.setLocation({
|
|
217
|
+
file: id,
|
|
218
|
+
line: err.mark.line,
|
|
219
|
+
column: err.mark.column
|
|
220
|
+
});
|
|
221
|
+
markdownError.setMessage(err.reason);
|
|
211
222
|
}
|
|
223
|
+
throw markdownError;
|
|
212
224
|
}
|
|
213
225
|
}
|
|
214
226
|
const globalContentConfigObserver = contentObservable({ status: "init" });
|
|
@@ -356,6 +368,6 @@ export {
|
|
|
356
368
|
loadContentConfig,
|
|
357
369
|
msg,
|
|
358
370
|
parseEntrySlug,
|
|
359
|
-
|
|
360
|
-
|
|
371
|
+
reloadContentConfigObserver,
|
|
372
|
+
safeParseFrontmatter
|
|
361
373
|
};
|
|
@@ -334,8 +334,8 @@ function addPageName(pathname, opts) {
|
|
|
334
334
|
const pageName = shouldAppendForwardSlash(trailingSlash, buildFormat) ? pathname.replace(/\/?$/, "/").replace(/^\//, "") : pathname.replace(/^\//, "");
|
|
335
335
|
opts.pageNames.push(pageName);
|
|
336
336
|
}
|
|
337
|
-
function getUrlForPath(pathname, base, origin, format, routeType) {
|
|
338
|
-
const ending = format === "directory" ? "/" : ".html";
|
|
337
|
+
function getUrlForPath(pathname, base, origin, format, trailingSlash, routeType) {
|
|
338
|
+
const ending = format === "directory" ? trailingSlash === "never" ? "" : "/" : ".html";
|
|
339
339
|
let buildPathname;
|
|
340
340
|
if (pathname === "/" || pathname === "") {
|
|
341
341
|
buildPathname = base;
|
|
@@ -389,6 +389,7 @@ async function generatePath(pathname, pipeline, gopts, route) {
|
|
|
389
389
|
pipeline.getConfig().base,
|
|
390
390
|
pipeline.getStaticBuildOptions().origin,
|
|
391
391
|
pipeline.getConfig().build.format,
|
|
392
|
+
pipeline.getConfig().trailingSlash,
|
|
392
393
|
route.type
|
|
393
394
|
);
|
|
394
395
|
const request = createRequest({
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
|
|
|
23
23
|
base: restart.container.settings.config.base
|
|
24
24
|
})
|
|
25
25
|
);
|
|
26
|
-
const currentVersion = "4.2.
|
|
26
|
+
const currentVersion = "4.2.8";
|
|
27
27
|
if (currentVersion.includes("-")) {
|
|
28
28
|
logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
|
|
29
29
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -36,7 +36,7 @@ function serverStart({
|
|
|
36
36
|
host,
|
|
37
37
|
base
|
|
38
38
|
}) {
|
|
39
|
-
const version = "4.2.
|
|
39
|
+
const version = "4.2.8";
|
|
40
40
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
41
41
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
42
42
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -258,7 +258,7 @@ function printHelp({
|
|
|
258
258
|
message.push(
|
|
259
259
|
linebreak(),
|
|
260
260
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
261
|
-
`v${"4.2.
|
|
261
|
+
`v${"4.2.8"}`
|
|
262
262
|
)} ${headline}`
|
|
263
263
|
);
|
|
264
264
|
}
|
|
@@ -23,7 +23,9 @@ Found handlers: ${Object.keys(mod).map((exp) => JSON.stringify(exp)).join(", ")}
|
|
|
23
23
|
return new Response(null, { status: 404 });
|
|
24
24
|
}
|
|
25
25
|
const response = await handler.call(mod, context);
|
|
26
|
-
response.
|
|
26
|
+
if (response.status === 404 || response.status === 500) {
|
|
27
|
+
response.headers.set(REROUTE_DIRECTIVE_HEADER, "no");
|
|
28
|
+
}
|
|
27
29
|
return response;
|
|
28
30
|
}
|
|
29
31
|
export {
|
|
@@ -44,11 +44,7 @@ async function writeWebResponse(res, webResponse) {
|
|
|
44
44
|
}
|
|
45
45
|
const _headers = Object.fromEntries(headers.entries());
|
|
46
46
|
if (headers.has("set-cookie")) {
|
|
47
|
-
|
|
48
|
-
_headers["set-cookie"] = headers.getSetCookie().toString();
|
|
49
|
-
} else {
|
|
50
|
-
_headers["set-cookie"] = headers.get("set-cookie");
|
|
51
|
-
}
|
|
47
|
+
_headers["set-cookie"] = headers.getSetCookie();
|
|
52
48
|
}
|
|
53
49
|
res.writeHead(status, _headers);
|
|
54
50
|
if (body) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { safeParseFrontmatter } from "../content/utils.js";
|
|
2
3
|
const markdownContentEntryType = {
|
|
3
4
|
extensions: [".md"],
|
|
4
|
-
async getEntryInfo({ contents }) {
|
|
5
|
-
const parsed =
|
|
5
|
+
async getEntryInfo({ contents, fileUrl }) {
|
|
6
|
+
const parsed = safeParseFrontmatter(contents, fileURLToPath(fileUrl));
|
|
6
7
|
return {
|
|
7
8
|
data: parsed.data,
|
|
8
9
|
body: parsed.content,
|
|
@@ -2,39 +2,16 @@ import {
|
|
|
2
2
|
createMarkdownProcessor,
|
|
3
3
|
InvalidAstroDataError
|
|
4
4
|
} from "@astrojs/markdown-remark";
|
|
5
|
-
import matter from "gray-matter";
|
|
6
5
|
import fs from "node:fs";
|
|
7
6
|
import path from "node:path";
|
|
8
7
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
9
8
|
import { normalizePath } from "vite";
|
|
10
|
-
import { AstroError, AstroErrorData
|
|
9
|
+
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
10
|
+
import { safeParseFrontmatter } from "../content/utils.js";
|
|
11
11
|
import { isMarkdownFile } from "../core/util.js";
|
|
12
12
|
import { shorthash } from "../runtime/server/shorthash.js";
|
|
13
13
|
import { getFileInfo } from "../vite-plugin-utils/index.js";
|
|
14
14
|
import { getMarkdownCodeForImages } from "./images.js";
|
|
15
|
-
function safeMatter(source, id) {
|
|
16
|
-
try {
|
|
17
|
-
return matter(source);
|
|
18
|
-
} catch (err) {
|
|
19
|
-
const markdownError = new MarkdownError({
|
|
20
|
-
name: "MarkdownError",
|
|
21
|
-
message: err.message,
|
|
22
|
-
stack: err.stack,
|
|
23
|
-
location: {
|
|
24
|
-
file: id
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
if (err.name === "YAMLException") {
|
|
28
|
-
markdownError.setLocation({
|
|
29
|
-
file: id,
|
|
30
|
-
line: err.mark.line,
|
|
31
|
-
column: err.mark.column
|
|
32
|
-
});
|
|
33
|
-
markdownError.setMessage(err.reason);
|
|
34
|
-
}
|
|
35
|
-
throw markdownError;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
15
|
const astroServerRuntimeModulePath = normalizePath(
|
|
39
16
|
fileURLToPath(new URL("../runtime/server/index.js", import.meta.url))
|
|
40
17
|
);
|
|
@@ -57,7 +34,7 @@ function markdown({ settings, logger }) {
|
|
|
57
34
|
if (isMarkdownFile(id)) {
|
|
58
35
|
const { fileId, fileUrl } = getFileInfo(id, settings.config);
|
|
59
36
|
const rawFile = await fs.promises.readFile(fileId, "utf-8");
|
|
60
|
-
const raw =
|
|
37
|
+
const raw = safeParseFrontmatter(rawFile, id);
|
|
61
38
|
const fileURL = pathToFileURL(fileId);
|
|
62
39
|
const renderResult = await processor.render(raw.content, {
|
|
63
40
|
// @ts-expect-error passing internal prop
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.8",
|
|
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",
|
|
@@ -163,8 +163,8 @@
|
|
|
163
163
|
"yargs-parser": "^21.1.1",
|
|
164
164
|
"zod": "^3.22.4",
|
|
165
165
|
"@astrojs/internal-helpers": "0.2.1",
|
|
166
|
-
"@astrojs/
|
|
167
|
-
"@astrojs/
|
|
166
|
+
"@astrojs/telemetry": "3.0.4",
|
|
167
|
+
"@astrojs/markdown-remark": "4.2.1"
|
|
168
168
|
},
|
|
169
169
|
"optionalDependencies": {
|
|
170
170
|
"sharp": "^0.32.6"
|