Skip to content

Commit

Permalink
fix: add reactive theme content in zh-CN
Browse files Browse the repository at this point in the history
  • Loading branch information
kaivanwong committed Mar 7, 2024
1 parent dcc3340 commit b6c9964
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/content/docs/zh-cn/guides/markdown-content.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,38 @@ export default defineConfig({
});
```

#### 浅色和深色模式

为了使它们响应你的网站样式,需要加入一些 CSS 片段:

```css title="基于媒体查询的深色模式"
@media (prefers-color-scheme: dark) {
.astro-code,
.astro-code span {
color: var(--shiki-dark) !important;
background-color: var(--shiki-dark-bg) !important;
/* Optional, if you also want font styles */
font-style: var(--shiki-dark-font-style) !important;
font-weight: var(--shiki-dark-font-weight) !important;
text-decoration: var(--shiki-dark-text-decoration) !important;
}
}
```

```css title="基于类名的深色模式"
html.dark .astro-code,
html.dark .astro-code span {
color: var(--shiki-dark) !important;
background-color: var(--shiki-dark-bg) !important;
/* Optional, if you also want font styles */
font-style: var(--shiki-dark-font-style) !important;
font-weight: var(--shiki-dark-font-weight) !important;
text-decoration: var(--shiki-dark-text-decoration) !important;
}
```

> [Shiki](https://shiki.style/guide/dual-themes#query-based-dark-mode) 中使用的类名是 `.shiki`,这里需要使用 `.astro-code`
#### 添加你自己的主题

你可以从本地文件导入自定义主题,而不是使用 Shiki 的预定义主题之一。
Expand Down

0 comments on commit b6c9964

Please sign in to comment.