From 5c27c7ce20454c5dd7a05c41bdcf4b69502b802e Mon Sep 17 00:00:00 2001 From: Gregory Linscheid Date: Sun, 7 Jun 2026 17:21:28 -0700 Subject: [PATCH] nits --- astro.config.mjs | 4 +++- src/components/BaseHead.astro | 1 + src/styles/code.css.ts | 24 +++++++++++------------- src/styles/global.css.ts | 2 ++ 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index d2c400f..8c8fa8a 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -25,7 +25,9 @@ export default defineConfig({ themes: { light: 'github-light', dark: 'github-dark' - } + }, + // CSS vars only — colors live in `code.css.ts` (`light-dark()` + dark-mode var fallback). + defaultColor: false } }, integrations: [ diff --git a/src/components/BaseHead.astro b/src/components/BaseHead.astro index 496fb34..595e3dc 100644 --- a/src/components/BaseHead.astro +++ b/src/components/BaseHead.astro @@ -15,6 +15,7 @@ const {title, description, image = '/blog/hello-world.jpg'} = Astro.props; + diff --git a/src/styles/code.css.ts b/src/styles/code.css.ts index 11b8cfc..10f873c 100644 --- a/src/styles/code.css.ts +++ b/src/styles/code.css.ts @@ -7,8 +7,9 @@ import {fonts, palette} from './tokens'; * Styles. */ -// Shiki dual themes: Astro sets --shiki-light/dark vars on .astro-code spans. -// https://docs.astro.build/en/guides/syntax-highlighting/ +// Shiki `.astro-code` layout + theming. `defaultColor: false` in `astro.config.mjs` emits +// `--shiki-*` vars only. We theme in CSS (not Shiki inline `light-dark()` — that stayed on +// the light branch in dark mode here). `@media (prefers-color-scheme: dark)` uses dark vars. globalStyle('pre.astro-code', { fontFamily: fonts.mono, @@ -17,11 +18,16 @@ globalStyle('pre.astro-code', { borderRadius: '10px', padding: '1.1em 1.25em', overflowX: 'auto', + maxWidth: '100%', margin: '1.5em 0', border: `1px solid ${palette.border}`, + color: 'light-dark(var(--shiki-light), var(--shiki-dark))', + backgroundColor: 'light-dark(var(--shiki-light-bg), var(--shiki-dark-bg))', '@media': { [media.dark]: { - borderColor: palette.borderDark + borderColor: palette.borderDark, + color: 'var(--shiki-dark)', + backgroundColor: 'var(--shiki-dark-bg)' }, [media.highContrast]: { borderWidth: '2px' @@ -30,18 +36,10 @@ globalStyle('pre.astro-code', { }); globalStyle('pre.astro-code span', { - color: 'var(--shiki-light)', - backgroundColor: 'var(--shiki-light-bg)', - fontStyle: 'var(--shiki-light-font-style)', - fontWeight: 'var(--shiki-light-font-weight)', - textDecoration: 'var(--shiki-light-text-decoration)', + color: 'light-dark(var(--shiki-light), var(--shiki-dark))', '@media': { [media.dark]: { - color: 'var(--shiki-dark)', - backgroundColor: 'var(--shiki-dark-bg)', - fontStyle: 'var(--shiki-dark-font-style)', - fontWeight: 'var(--shiki-dark-font-weight)', - textDecoration: 'var(--shiki-dark-text-decoration)' + color: 'var(--shiki-dark)' } } }); diff --git a/src/styles/global.css.ts b/src/styles/global.css.ts index f7fd2cb..5473522 100644 --- a/src/styles/global.css.ts +++ b/src/styles/global.css.ts @@ -19,6 +19,8 @@ globalStyle('html', { lineHeight: 1.65, color: palette.text, backgroundColor: palette.pageBg, + // Enables CSS `light-dark()` on code blocks. Dark vars fallback in `code.css.ts`. + colorScheme: 'light dark', textRendering: 'optimizeLegibility', WebkitFontSmoothing: 'antialiased', MozOsxFontSmoothing: 'grayscale',