Hexo魔改记录

首页文章卡片擦亮效果

1、新增css内容

  • 新建文件/static/home.css或在已引入的css中新增以下内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#recent-posts > .recent-post-item:not(a)::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 200%;
background: linear-gradient(to right, transparent, white, transparent);
transform: translateX(-200%);
transition: transform 0.5s linear;
z-index: 1;
}
#recent-posts > .recent-post-item:not(a):hover::before {
transform: translateX(100%) skewX(-60deg);
}

2、引入内容

  • _config.anzhiyu.yml主题配置文件下inject配置项中head
  • 引入home.css文件
1
2
3
inject:
head:
- <link rel="stylesheet" href="/static/home.css"> # 首页文章卡片擦亮效果

页脚挂件

只需在主题中引入以下JavaScript代码,即可在页脚动态插入一个动物挂件。

需要开启 主题配置文件中的footer_bar选项,设置为true

将以下代码直接插入到主题的JavaScript文件中,其他主题可能需要调整插入位置。

1.新建一个footer-animal.js文件,将以下代码粘贴进去。

2.然后在_config.anzhiyu.ymlinject选项的bottom中添加 - <script src="/static/footer-animal.js" defer></script> # 页脚挂件。 根据你文件位置,自行调整。

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
43
44
45
46
47
48
49
50
51
52
53
javascript

function initFooterAnimal() {
const footerBar = document.querySelector('#footer-bar');
if (!footerBar) return console.error('找不到指定元素');

const footerAnimal = document.createElement('div');
footerAnimal.id = 'footer-animal';
footerAnimal.innerHTML = `
<img class="animal entered loaded"
src="https://i1.wp.com/ruom.wuaze.com/i/2024/10/19/473503.webp"
alt="动物" />
`;

footerBar.insertAdjacentElement('beforebegin', footerAnimal);

const style = document.createElement('style');
style.textContent = `
#footer-animal {
position: relative;
}
#footer-animal::before {
content: '';
position: absolute;
bottom: 0;
width: 100%;
height: 36px;
background: url(https://i1.wp.com/ruom.wuaze.com/i/2024/10/19/351933.webp) repeat center / auto 100%;
box-shadow: 0 4px 7px rgba(0,0,0,.15);
}
.animal {
position: relative;
max-width: min(974px, 100vw);
margin: 0 auto;
display: block;
}
#footer-bar {
margin-top: 0 !important;
}
@media screen and (max-width: 1023px) {
#footer-animal::before {
height: 4vw;
}
}
[data-theme=dark] #footer-animal {
filter: brightness(.8);
}
`;
document.head.appendChild(style);
}

document.addEventListener('DOMContentLoaded', initFooterAnimal);
document.addEventListener('pjax:success', initFooterAnimal);