feat: support light/dark theme in code blocks (#327)

Update Astro and its related dependencies. Support
light/dark theme in code-blocks.
This commit is contained in:
Sat Naing
2024-07-21 16:18:22 +07:00
committed by GitHub
parent 2a78fd6e59
commit 9de19c2c68
4 changed files with 1533 additions and 1642 deletions
+2 -1
View File
@@ -27,7 +27,8 @@ export default defineConfig({
], ],
], ],
shikiConfig: { shikiConfig: {
theme: "one-dark-pro", // For more themes, visit https://shiki.style/themes
themes: { light: "min-light", dark: "night-owl" },
wrap: true, wrap: true,
}, },
}, },
+1512 -1636
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -16,10 +16,10 @@
"lint": "eslint ." "lint": "eslint ."
}, },
"dependencies": { "dependencies": {
"@astrojs/check": "^0.4.1", "@astrojs/check": "^0.8.2",
"@astrojs/rss": "^4.0.2", "@astrojs/rss": "^4.0.7",
"@resvg/resvg-js": "^2.6.0", "@resvg/resvg-js": "^2.6.0",
"astro": "^4.2.1", "astro": "^4.12.2",
"fuse.js": "^7.0.0", "fuse.js": "^7.0.0",
"github-slugger": "^2.0.0", "github-slugger": "^2.0.0",
"remark-collapse": "^0.1.2", "remark-collapse": "^0.1.2",
@@ -29,8 +29,8 @@
"typescript": "^5.3.3" "typescript": "^5.3.3"
}, },
"devDependencies": { "devDependencies": {
"@astrojs/react": "^3.0.9", "@astrojs/react": "^3.6.0",
"@astrojs/sitemap": "^3.0.5", "@astrojs/sitemap": "^3.1.6",
"@astrojs/tailwind": "^5.1.0", "@astrojs/tailwind": "^5.1.0",
"@divriots/jampack": "^0.23.2", "@divriots/jampack": "^0.23.2",
"@tailwindcss/typography": "^0.5.10", "@tailwindcss/typography": "^0.5.10",
+14
View File
@@ -115,6 +115,10 @@
@apply bg-skin-card-muted; @apply bg-skin-card-muted;
} }
/* ===== Code Blocks & Syntax Highlighting ===== */
pre:has(code) {
@apply border border-skin-line;
}
code, code,
blockquote { blockquote {
word-wrap: break-word; word-wrap: break-word;
@@ -123,6 +127,16 @@
pre > code { pre > code {
white-space: pre; white-space: pre;
} }
/* Apply Dark Theme (if multi-theme specified) */
html[data-theme="dark"] pre:has(code),
html[data-theme="dark"] pre:has(code) span {
color: var(--shiki-dark) !important;
background-color: var(--shiki-dark-bg) !important;
font-style: var(--shiki-dark-font-style) !important;
font-weight: var(--shiki-dark-font-weight) !important;
text-decoration: var(--shiki-dark-text-decoration) !important;
}
} }
@layer components { @layer components {