Skip to content

Commit 6dec27b

Browse files
committed
Update astro.config.mjs
Update astro.config.mjs
1 parent d556062 commit 6dec27b

File tree

5 files changed

+296
-92
lines changed

5 files changed

+296
-92
lines changed

docs/astro.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default defineConfig({
3333
{
3434
label: "Introduction",
3535
link: "/introduction",
36-
},
36+
},
3737
{
3838
label: "Rules of Engagement",
3939
link: "/rules-of-engagement",

docs/ec.config.mjs

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,18 @@
11
import { pluginCollapsibleSections } from "@expressive-code/plugin-collapsible-sections";
22
import { ExpressiveCodeTheme } from "@astrojs/starlight/expressive-code";
3-
import fs from "node:fs";
4-
import path from "node:path";
3+
import { readFileSync } from "node:fs";
54

6-
// Define allowed paths relative to project root
7-
const ALLOWED_PATHS = ["src/themes/expressive-code"];
8-
9-
function readFileSyncSafe(url) {
10-
if (url.protocol !== "file:") {
11-
throw new Error("Invalid URL protocol");
12-
}
13-
14-
// Convert URL to filesystem path and normalize
15-
const filePath = path.normalize(url.pathname);
16-
17-
// Ensure path is within allowed directories
18-
const isAllowed = ALLOWED_PATHS.some((allowedPath) =>
19-
filePath.includes(path.normalize(allowedPath))
20-
);
21-
22-
if (!isAllowed) {
23-
throw new Error("Access to this directory is not allowed");
24-
}
25-
26-
return fs.readFileSync(url, "utf-8");
27-
}
28-
29-
const jsoncStringLight = readFileSyncSafe(
30-
new URL(
31-
"./src/themes/expressive-code/Snazzy-Light-color-theme.json",
32-
import.meta.url
33-
)
5+
// Load theme files as raw strings (supports JSON with comments/trailing commas)
6+
const jsoncStringLight = readFileSync(
7+
"./src/themes/expressive-code/Snazzy-Light-color-theme.json",
8+
"utf-8"
349
);
35-
36-
const jsoncStringDark = readFileSyncSafe(
37-
new URL(
38-
"./src/themes/expressive-code/aura-soft-dark-soft-text-color-theme.json",
39-
import.meta.url
40-
)
10+
const jsoncStringDark = readFileSync(
11+
"./src/themes/expressive-code/aura-soft-dark-soft-text-color-theme.json",
12+
"utf-8"
4113
);
4214

15+
// Create themes from raw JSONC strings
4316
const darkMode = ExpressiveCodeTheme.fromJSONString(jsoncStringDark);
4417
const lightMode = ExpressiveCodeTheme.fromJSONString(jsoncStringLight);
4518

0 commit comments

Comments
 (0)