1
2
 <canvas class="fireworks" style="position: fixed;left: 0;top: 0;z-index: 41; pointer-events: none;" ></canvas> 
<script type="text/javascript" src="/js/firework.js"></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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
var canvasEl = document.querySelector('.fireworks');
var ctx = canvasEl.getContext('2d');
var numberOfParticules = 30;
var pointerX = 0;
var pointerY = 0;
var tap = "mousedown";
var colors = ["#fa5557", "#54b4f1", "#f3eed9", "#6f0000"];

function setCanvasSize() {
canvasEl.width = window.innerWidth * 2;
canvasEl.height = window.innerHeight * 2;
canvasEl.style.width = window.innerWidth + 'px';
canvasEl.style.height = window.innerHeight + 'px';
canvasEl.getContext('2d').scale(2, 2);
}

function updateCoords(e) {
pointerX = e.clientX || e.touches[0].clientX;
pointerY = e.clientY || e.touches[0].clientY;
}

function setParticuleDirection(p) {
var angle = anime.random(0, 360) * Math.PI / 180;
var value = anime.random(50, 180);
var radius = [-1, 1][anime.random(0, 1)] * value;
return {
x: p.x + radius * Math.cos(angle),
y: p.y + radius * Math.sin(angle)
}
}

function createParticule(x,y) {
var p = {};
p.x = x;
p.y = y;
p.color = colors[anime.random(0, colors.length - 1)];
p.radius = anime.random(16, 32);
p.endPos = setParticuleDirection(p);
p.draw = function() {
ctx.beginPath();
ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
ctx.fillStyle = p.color;
ctx.fill();
}
return p;
}

function createCircle(x,y) {
var p = {};
p.x = x;
p.y = y;
p.color = "#F00";
p.radius = 0.1;
p.alpha = .5;
p.lineWidth = 6;
p.draw = function() {
ctx.globalAlpha = p.alpha;
ctx.beginPath();
ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
ctx.lineWidth = p.lineWidth;
ctx.strokeStyle = p.color;
ctx.stroke();
ctx.globalAlpha = 1;
}
return p;
}

function renderParticule(anim) {
for (var i = 0; i < anim.animatables.length; i++) {
anim.animatables[i].target.draw();
}
}

function animateParticules(x, y) {
var circle = createCircle(x, y);
var particules = [];
for (var i = 0; i < numberOfParticules; i++) {
particules.push(createParticule(x, y));
}
anime.timeline().add({
targets: particules,
x: function(p) { return p.endPos.x; },
y: function(p) { return p.endPos.y; },
radius: 0.1,
duration: anime.random(1200, 1800),
easing: 'easeOutExpo',
update: renderParticule,
})
.add({
targets: circle,
radius: anime.random(80, 160),
lineWidth: 0,
alpha: {
value: 0,
easing: 'linear',
duration: anime.random(600, 800),
},
duration: anime.random(1200, 1800),
easing: 'easeOutExpo',
update: renderParticule,
}, 0);
}

var render = anime({
duration: Infinity,
update: function() {
ctx.clearRect(0, 0, canvasEl.width, canvasEl.height);
}
});

document.addEventListener(
tap,
function (e) {
"sidebar" !== e.target.id &&
"toggle-sidebar" !== e.target.id &&
"A" !== e.target.nodeName &&
"IMG" !== e.target.nodeName &&
(render.play(), updateCoords(e), animateParticules(pointerX, pointerY));
},
!1
)

setCanvasSize();
window.addEventListener('resize', setCanvasSize, false);



其中darkmodeJS可以自己添加,自定义交互逻辑以及检测目前的perfer ,但是比较麻烦.我这里直接用的大佬的插件,再覆盖上自己喜欢的样式,可惜的是按钮切换模式时的动效没了

刚刚开始的时候我把waline后端部署和前端静态网页部署搞混了~~~现在两个端都躺到vercel上了,不得不说vercel的部署太友好了,真是开箱即用,以下是参考教程:

把waline后端和你的blogs项目都扔到vercel上部署,按照上面的教程,取得Leancloud凭证,配置好 vercel-settings-environment variables

再搞个域名,然后在blog项目的 vercel-settings-domains配置一级域名 xxx.com cname解析,再配置好 www.xxx.com的重定向。

这里vercel会自动recommend这个方案,按照它上面的方式配置就好了,注意域名解析的时候的 address/value 值要写 cname-china.vercel-dns.com,以避免dns污染!

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
{# 导航部分 #}
<nav id="article-nav">
{# 上一篇文章链接 #}
{% if post.prev %}
<div id="article-nav-pre" class="article-nav-link-wrap">
<span class="article-nav-caption">{{ __('precious') }} {{ __('symbol.colon') }}</span>
<a class="article-nav-title" href="{{ url_for(post.prev.path) }}" >
{% if post.prev.title %}
{{ post.prev.title }}
{% else %}
(no title)
{% endif %}
</a>
</div>
{% endif %}
{# 下一篇文章链接 #}
{% if post.next %}
<div id="article-nav-next" class="article-nav-link-wrap">
<span class="article-nav-caption">{{ __('next') }} {{ __('symbol.colon') }} </span>
<a class="article-nav-title" href="{{ url_for(post.next.path) }}" >
{% if post.next.title %}
{{ post.next.title }}
{% else %}
(no title)
{% endif %}
</a>
</div>
</nav>
{% endif %}

#####然后在zh-CN.yml里面添加
precious: 上一篇
next: 下一篇