Skip to content

Commit c9a0eaf

Browse files
committed
Update astro.config.mjs
1 parent 9ce34e4 commit c9a0eaf

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

docs/astro.config.mjs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,26 @@ import { ExpressiveCodeTheme } from "@astrojs/starlight/expressive-code";
44
import fs from "node:fs";
55
import starlightImageZoom from "starlight-image-zoom";
66

7-
const jsoncStringLight = fs.readFileSync(
7+
function readFileSyncSafe(url) {
8+
if (url.protocol === "file:") {
9+
return fs.readFileSync(url, "utf-8");
10+
} else {
11+
throw new Error("Invalid URL protocol");
12+
}
13+
}
14+
15+
const jsoncStringLight = readFileSyncSafe(
816
new URL(
917
"./src/themes/expressive-code/Snazzy-Light-color-theme.json",
1018
import.meta.url
11-
),
12-
"utf-8"
19+
)
1320
);
1421

15-
const jsoncStringDark = fs.readFileSync(
22+
const jsoncStringDark = readFileSyncSafe(
1623
new URL(
1724
"./src/themes/expressive-code/aura-soft-dark-soft-text-color-theme.json",
1825
import.meta.url
19-
),
20-
"utf-8"
26+
)
2127
);
2228

2329
const darkMode = ExpressiveCodeTheme.fromJSONString(jsoncStringDark);

0 commit comments

Comments
 (0)