增加 FUwari 代码块双主题
256 字
1 分钟
增加 FUwari 代码块双主题
这篇文章来记录一下美化博客的代码。代码模块跟随主题变动而变化
修改代码
astro.config.mjs
// 。。。 修改此处代码expressiveCode({ // themes: [expressiveCodeConfig.theme, expressiveCodeConfig.theme], themes: expressiveCodeConfig.themes, plugins: [ pluginCollapsibleSections(), pluginLineNumbers(), pluginLanguageBadge(), pluginCustomCopyButton(), ], defaultProps: { wrap: true, overridesByLang: { shellsession: { showLineNumbers: false, }, }, }, // styleOverrides: { // codeBackground: "var(--codeblock-bg)", // borderRadius: "0.75rem", // borderColor: "none", // codeFontSize: "0.875rem", // codeFontFamily: // "'JetBrains Mono Variable', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace", // codeLineHeight: "1.5rem", // frames: { // editorBackground: "var(--codeblock-bg)", // terminalBackground: "var(--codeblock-bg)", // terminalTitlebarBackground: "var(--codeblock-topbar-bg)", // editorTabBarBackground: "var(--codeblock-topbar-bg)", // editorActiveTabBackground: "none", // editorActiveTabIndicatorBottomColor: "var(--primary)", // editorActiveTabIndicatorTopColor: "none", // editorTabBarBorderBottomColor: "var(--codeblock-topbar-bg)", // terminalTitlebarBorderBottomColor: "none", // }, // textMarkers: { // delHue: 0, // insHue: 180, // markHue: 250, // }, // }, // frames: { // showCopyToClipboardButton: false, // }, }),
// 。。。 修改此处代码src/types/config.ts
// 。。。下滑至最下面export type ExpressiveCodeConfig = { theme: string[];};src/config.ts
// 。。。下滑至最下面
export const expressiveCodeConfig: ExpressiveCodeConfig = { // Note: Some styles (such as background color) are being overridden, see the astro.config.mjs file. // Please select a dark theme, as this blog theme currently only supports dark background color theme: ["github-light", "github-dark"],};src/utils/setting-utils.ts
// Set the theme for Expressive Code const isDarkMode = document.documentElement.classList.contains("dark"); document.documentElement.setAttribute( "data-theme", expressiveCodeConfig.theme[Number(isDarkMode)], );演示效果
晚上

白天

支持与分享
如果这篇文章对你有帮助,欢迎分享给更多人或赞助支持!
相关文章 智能推荐
1
增强Fuwari的代码块功能
前端 2025-09-17
2
FUwari 二级导航
前端 2025-10-24
3
Fuwari 部署指南(教程)
前端 该文章为 Fuwari 部署指南,作者因静态站点方案优势选择基于 Astro 框架和 fuwari 主题的静态博客。指南先介绍 Astro 及 fuwari 特性,接着阐述搭建需求,详细说明本地部署、博客配置(基本配置与创建文章)、部署上线(准备工作及连接 Cloudflare 流程)步骤,最后提及在src/components/Footer.astro添加 ICP 备案和运行时间的个性化操作,并给出相关参考链接。
4
Fuwari链接卡片
前端 2025-09-22
5
Fuwari链接外部跳转
前端 网站内的链接点击直接新标签页打开
随机文章 随机推荐