From 15a2355f054d08c8ac24a6e1260ac28c4080861d Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sun, 9 Nov 2025 15:26:34 -0500 Subject: [PATCH] feat: use two styles --- astro.config.mjs | 69 ++++++++++++++++++++++++++++++++++++++++- public/styles/posts.css | 9 +++--- 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index 3ac90be..86b2383 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -4,6 +4,70 @@ import remarkMath from "remark-math"; import rehypeKatex from "rehype-katex"; import path from "path"; +const midnight = { + name: "midnight", + type: "dark", + colors: { + "editor.background": "#121212", + "editor.foreground": "#e0e0e0", + }, + tokenColors: [ + { + scope: [ + "keyword", + "storage.type", + "storage.modifier", + "keyword.control", + "keyword.operator.new", + ], + settings: { foreground: "#7aa2f7" }, + }, + { + scope: [ + "string", + "constant", + "constant.numeric", + "constant.language", + "constant.character", + "number", + ], + settings: { foreground: "#e5c07b" }, + }, + ], +}; + +const daylight = { + name: "daylight", + type: "light", + colors: { + "editor.background": "#f5f5f5", + "editor.foreground": "#1a1a1a", + }, + tokenColors: [ + { + scope: [ + "keyword", + "storage.type", + "storage.modifier", + "keyword.control", + "keyword.operator.new", + ], + settings: { foreground: "#3b5bdb" }, + }, + { + scope: [ + "string", + "constant", + "constant.numeric", + "constant.language", + "constant.character", + "number", + ], + settings: { foreground: "#996800" }, + }, + ], +}; + export default defineConfig({ build: { format: "file", @@ -23,7 +87,10 @@ export default defineConfig({ }, markdown: { shikiConfig: { - theme: "github-light", + themes: { + light: daylight, + dark: midnight, + }, langs: [], wrap: true, }, diff --git a/public/styles/posts.css b/public/styles/posts.css index dc49a8b..46399bd 100644 --- a/public/styles/posts.css +++ b/public/styles/posts.css @@ -118,12 +118,13 @@ article pre { padding: 1rem; overflow-x: auto; border-radius: 4px; - background: var(--code-bg) !important; border: 1px solid var(--border); } -pre * { - background: var(--code-bg) !important; +[data-theme="dark"] .astro-code, +[data-theme="dark"] .astro-code span { + color: var(--shiki-dark) !important; + background-color: var(--shiki-dark-bg) !important; } :not(pre) > code { @@ -133,7 +134,7 @@ pre * { white-space: nowrap; border: 1px solid var(--border); border-radius: 4px; - background: var(--code-bg) !important; + background: var(--code-bg); } .astro-code {