惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 聂微东
MyScale Blog
MyScale Blog
The GitHub Blog
The GitHub Blog
C
Check Point Blog
M
MIT News - Artificial intelligence
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
H
Help Net Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
DataBreaches.Net
大猫的无限游戏
大猫的无限游戏
D
Docker
Last Week in AI
Last Week in AI
IT之家
IT之家
F
Fortinet All Blogs
A
About on SuperTechFans
P
Proofpoint News Feed
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog RSS Feed
博客园_首页
月光博客
月光博客
博客园 - 司徒正美
Y
Y Combinator Blog

Yesterday17's Blog

2026 新年解密红包 / Melody Flag | Yesterday17's Blog 谈谈 Iori 的设计思路(二):如何实现一个 Showroom 录制工具? | Yesterday17's Blog 谈谈 Iori 的设计思路(一):从 Nico Timeshift 说起 | Yesterday17's Blog Iori Minyami 0.1.0 发布 | Yesterday17's Blog 2025 新年解密红包 / Melody Flag | Yesterday17's Blog 使用 Cloudflare Warp 解决罗森票务的海外登录问题 | Yesterday17's Blog How To Blog 04: The Astro v5 Era | Yesterday17's Blog 谈谈 tokio::select! 的公平性 | Yesterday17's Blog Learning Pingora 05 - Connect with TLS | Yesterday17's Blog Leaving Bytedance | Yesterday17's Blog 大橋彩香 AsiaTour「Reflection」上海公演 个人向记录 & Repo | Yesterday17's Blog Recoving from burnout - What happened? | Yesterday17 Yubikey 重建手册 | Yesterday17's Blog 🪧 Blog Migration Accouncement | Yesterday17's Blog Learn Your IDE - VSCode 是如何仅重启插件的? | Yesterday17's Blog How To Blog 02: Astro❤️Password | Yesterday17's Blog How To Blog 01: Why, How, and the Future | Yesterday17's Blog Learning Pingora 04 - Establish L4 Connection | Yesterday17's Blog Learning Pingora 03 - Upstreams and Peers | Yesterday17's Blog Learning Pingora 02 - A Simple HTTP Server | Yesterday17's Blog Learning Pingora 01 - Getting Started | Yesterday17's Blog 2024 新年解密红包 / Melody Flag | Yesterday17's Blog 向新的一年飞驰——记录 2023 | Yesterday17's Blog 「サクラノ刻」对话选摘(2) | Yesterday17's Blog PGP Key Revocation 注销声明 | Yesterday17's Blog 「サクラノ刻」对话选摘(1) | Yesterday17's Blog 2023 新年解密红包 / Melody Flag | Yesterday17's Blog 『蒼の彼方のフォーリズム』通关感想 | Yesterday17's Blog 单显卡直通教程 | Yesterday17's Blog 对博客与笔记的思考 | Yesterday17's Blog
How To Blog 03: Heimus | Yesterday17's Blog
Yesterday17 · 2024-05-24 · via Yesterday17's Blog

搞定密码之后,下一个需要解决的就是黑幕了。我们期望的黑幕效果和原来博客的版本基本一致,所以 CSS 部分可以直接沿用过来:

body heimu,

body heimu a,

body a heimu {

display: inline;

background-color: #252525;

color: #252525 !important;

text-shadow: none;

}

body heimu:hover,

body heimu:active {

transition: color 0.13s linear;

color: #fff !important;

}

body heimu:hover a,

body a:hover heimu {

transition: color 0.13s linear;

color: #add8e6 !important;

}

但如何才能做到只对需要黑幕的博客文章启用这段 CSS 呢?这里我们写了一个简单的 rehype 插件:

function rehypeHeimuPlugin() {

return function transformer(tree, file) {

const value = file.value;

if (typeof value === "string") {

if (value.includes("<heimu>")) {

tree.children.push({

type: "element",

tagName: "style",

properties: {},

children: [

{

type: "text",

value: `

body heimu,

body heimu a,

body a heimu {

display: inline;

background-color: #252525;

color: #252525 !important;

text-shadow: none;

}

body heimu:hover,

body heimu:active {

transition: color 0.13s linear;

color: #fff !important;

}

body heimu:hover a,

body a:hover heimu {

transition: color 0.13s linear;

color: #add8e6 !important;

}

`.trim(),

},

],

});

}

}

};

},

原理也很简单,不多说了(