给hexo博客添加一个Sakana~

来自开源项目itorr/sakana

脑阔疼ﻩ٥一同制作完成

效果如下

教程

写入到root_blog\themes\butterfly\source\css\custom.css文件中并引用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
html .sakana-box {
position: fixed;
right: 0;
bottom: 0;
transform-origin: 100% 100%; /* 从右下开始变换 */
}
.sakana-box {
width: 500px;
height: 80px;
position: relative;
pointer-events: none;
z-index: 100;
}
@media screen and (max-width: 768px){
.sakana-box {
width: 500px;
height: 80px;
position: relative;
pointer-events: none;
}
}
@media screen and (max-width: 768px){
html .sakana-box {
position: inherit;
right: 0;
bottom: 0;
transform-origin: 36% 160%;
}
}
[data-theme="light"] .layout > div:first-child:not(.recent-posts) {
background: rgba(255, 255, 255, .8);
-webkit-backdrop-filter: none;
backdrop-filter: none!important;
}
[data-theme="dark"] .layout > div:first-child:not(.recent-posts) {
background: rgba(15, 15, 15, .75);
-webkit-backdrop-filter: none;
backdrop-filter: none!important;
}
html.hide-aside .layout > div:first-child {
width: 90%;
}

直接写入到root_blog\source\link\index.md文件中

1
2
3
4
5
6
7
8
9
<div class="sakana-box"></div>
<script src="https://gcore.jsdelivr.net/gh/linjiangyu2/halo@master/js/sakana.js"></script>
<script>
Sakana.init({
el: '.sakana-box', // 启动元素 node 或 选择器
scale: .5, // 缩放倍数
canSwitchCharacter: true, // 允许换角色
});
</script>

修改root_blog\themes\butterfly_config.yml

1
2
3
4
5
6
7
8
9
10
inject:
head:
+ - <link rel="stylesheet" href="/css/custom.css">
......
pjax:
enable: true
exclude:
+ - /link/
# - xxxx
# - xxxx

就可以得到一个Sakana了~

这里我还给Heo的音乐播放器加上了

效果如下

修改index.html文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  <link rel="apple-touch-icon-precomposed" sizes="180x180" href="./img/icon-r.webp">
<meta name="description" content="念念不忘 必有回响">
+ <style>
+ html .sakana-box{
+ position: fixed;
+ right: 0;
+ bottom: 0;
+ transform-origin: 100% 100%; /* 从右下开始变换 */
+ }
+ </style>
......
<script src="./js/APlayer.min.js"></script>
<script src="./js/Meting2.min.js"></script>
<script async data-pjax src="./js/main.js"></script>
+ <div class="sakana-box"></div>
+ <script src="https://cdn.jsdelivr.net/gh/linjiangyu2/halo/js/sakana.js"></script>
+ <script>
+ // 取消静音
+ Sakana.setMute(false);
+ // 启动
+ Sakana.init({
+ el: '.sakana-box', // 启动元素 node 或 选择器
+ scale: .5, // 缩放倍数
+ canSwitchCharacter: true, // 允许换角色
+ });
+ </script>
</body>
</html>

然后

1
2
3
# git add index.html
# git commit -m 'none'
# git push

推到github就可以了