File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -4,20 +4,26 @@ import { ExpressiveCodeTheme } from "@astrojs/starlight/expressive-code";
44import fs from "node:fs" ;
55import 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
2329const darkMode = ExpressiveCodeTheme . fromJSONString ( jsoncStringDark ) ;
You can’t perform that action at this time.
0 commit comments