2.2 KiB
2.2 KiB
+++ date = '2025-05-02T14:42:07+08:00' draft = false author = "paw" title = '让你的Hugo博客支持萌百式的黑幕' categories = ["blog"] tags = ["css","muhehehe"] +++
非常喜欢某明清时期知名文学评论家的一句话:"paw有可能很可爱 {{< muhehehe text=",但是paw很可爱有点不可能" title="出自《明朝-提瓦剌史》" >}}"
——【清】甘雨
TL;DR
首先新建static/css/muheheh.css,并且内容为:
.muhehehe,
.muhehehe a,
a .muhehehe,
.muhehehe a.new {
background-color: #252525;
color: #252525;
text-shadow: none;
}
.muhehehe:hover,
.muhehehe:active,
.muhehehe:hover .muhehehe,
.muhehehe:active .muhehehe {
color: white !important;
}
.muhehehe:hover a,
a:hover .muhehehe,
.muhehehe:active a,
a:active .muhehehe {
color: lightblue !important;
}
.muhehehe:hover .new,
.muhehehe .new:hover,
.new:hover .muhehehe,
.muhehehe:active .new,
.muhehehe .new:active,
.new:active .muhehehe {
color: #BA0000 !important;
}
然后在你的主题引入的外部header中添加上
<link rel="stylesheet" href="/css/muhehehe.css">
作为范例,paw的博客主题所引入的的外部header为layouts/partials/head_custom.html。
最后,我们{{}}再新建一个shortcode,文件地址为layouts/shortcodes/muhehehe.html,内容为
<span class="muhehehe" title="{{ default " qwq" (.Get "title" ) }}">{{ .Get "text" }}</span>
这样就完成啦,接下来就可以在你的.md文章里使用
{{</* muhehehe text="你想说的话" title="鼠标放上去时会显示的内容,默认为qwq" */>}}
来实现萌娘百科一样的黑幕效果啦。
效果:{{}}
QA环节之:为什么这个项目要叫做"muhehehe"呢
A:因为muhehehe很像是可爱小猫的奸奇笑声,背后隐藏着不可告人的秘密。尽管可爱小猫正在奸笑,但是也没人能拒他;{{}}