Skip to content

Commit

Permalink
fix: Zhihu theme code block
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Nov 5, 2024
1 parent 7c9143c commit bda512f
Show file tree
Hide file tree
Showing 9 changed files with 917 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/setting/Basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const formData = reactive({
versionMap: {
midlight: "3.1.10",
daylight: "3.1.10",
Zhihu: "0.1.2",
Zhihu: "0.1.3",
Savor: "4.2.3",
} as any,
})
Expand Down
2 changes: 1 addition & 1 deletion composables/useStaticThemeMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const useStaticThemeMode = async () => {
const siyuanLightTheme = (query.lightTheme ?? setting.theme?.lightTheme ?? "Zhihu") as string
const siyuanDarkTheme = (query.darkTheme ?? setting.theme?.darkTheme ?? "Zhihu") as string
const siyuanThemeV = (query.themeVersion ?? setting.theme?.themeVersion ?? "0.1.2") as string
const detectedMode = color.preference
const detectedMode = color.preference == "system" ? "light" : color.preference
const isDarkMode = detectedMode === "dark"
useHead({
htmlAttrs: {
Expand Down
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default defineNuxtConfig({
viewport: "width=device-width, initial-scale=1",
htmlAttrs: {
lang: "zh_CN",
"data-theme-mode": "system",
"data-theme-mode": "light",
"data-light-theme": "Zhihu",
"data-dark-theme": "Zhihu",
},
Expand Down
2 changes: 1 addition & 1 deletion nuxt.node.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default defineNuxtConfig({
viewport: "width=device-width, initial-scale=1",
htmlAttrs: {
lang: "zh_CN",
"data-theme-mode": "system",
"data-theme-mode": "light",
"data-light-theme": "Zhihu",
"data-dark-theme": "Zhihu",
},
Expand Down
2 changes: 1 addition & 1 deletion nuxt.siyuan.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default defineNuxtConfig({
viewport: "width=device-width, initial-scale=1",
htmlAttrs: {
lang: "zh_CN",
"data-theme-mode": "system",
"data-theme-mode": "light",
"data-light-theme": "Zhihu",
"data-dark-theme": "Zhihu",
},
Expand Down
2 changes: 1 addition & 1 deletion nuxt.vercel.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default defineNuxtConfig({
viewport: "width=device-width, initial-scale=1",
htmlAttrs: {
lang: "zh_CN",
"data-theme-mode": "system",
"data-theme-mode": "light",
"data-light-theme": "Zhihu",
"data-dark-theme": "Zhihu",
},
Expand Down
5 changes: 4 additions & 1 deletion plugins/01.hljs.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ export default defineNuxtPlugin(({ vueApp }) => {
// 创建 <pre> 和 <code> 元素
const pre = document.createElement("pre")
const code = document.createElement("code")
const div = document.createElement("div")
div.className = "hljs"
// 将 block 的内容移动到 <code> 中
code.innerHTML = block.innerHTML
// 将 <code> 添加到 <pre> 中
pre.appendChild(code)
div.appendChild(pre)
// 将 <pre> 插入到 block 的位置,并移除原始的 block
block.parentNode?.insertBefore(pre, block)
block.parentNode?.insertBefore(div, block)
block.remove()
})

Expand Down

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion public/resources/appearance/themes/Zhihu/theme.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bda512f

Please sign in to comment.