hexo-theme-shokax 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/_config.yml +2 -1
- package/_images.yml +1 -92
- package/layout/_partials/footer.pug +1 -1
- package/package.json +3 -2
- package/scripts/filters/locals.js +48 -59
- package/scripts/filters/post.js +13 -19
- package/scripts/generaters/archive.js +111 -135
- package/scripts/generaters/config.js +31 -38
- package/scripts/generaters/images.js +19 -24
- package/scripts/generaters/index.js +96 -105
- package/scripts/generaters/pages.js +15 -18
- package/scripts/generaters/script.js +86 -90
- package/scripts/helpers/asset.js +123 -134
- package/scripts/helpers/engine.js +127 -185
- package/scripts/helpers/list_categories.js +102 -133
- package/scripts/helpers/symbols_count_time.js +53 -67
- package/scripts/plugin/index.js +42 -46
- package/scripts/plugin/lib/injects-point.js +19 -20
- package/scripts/plugin/lib/injects.js +58 -81
- package/scripts/tags/links.js +48 -75
- package/scripts/tags/media.js +13 -18
- package/source/css/_common/components/highlight/highlight.styl +4 -0
- package/source/css/_common/outline/header/image.styl +4 -0
- package/source/css/_common/outline/header/waves.styl +4 -0
- package/source/css/_common/scaffolding/animate.styl +4 -0
- package/source/css/_mixins.styl +5 -3
- package/source/js/_app/fireworks.js +11 -1
- package/source/js/_app/global.js +6 -2
- package/source/js/_app/page.js +66 -0
package/scripts/tags/links.js
CHANGED
@@ -1,85 +1,58 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
image: #icon image (nullable)
|
10
|
-
color: #block color (nullable)
|
11
|
-
{% endlinks %}
|
12
|
-
|
13
|
-
{% linksfile [path] %}
|
14
|
-
*/
|
15
|
-
|
16
|
-
const fs = require('fs')
|
17
|
-
const path = require('path')
|
18
|
-
const yaml = require('js-yaml')
|
19
|
-
|
20
|
-
function linkGrid (args, content) {
|
21
|
-
const theme = hexo.theme.config
|
22
|
-
|
23
|
-
if (!args[0] && !content) {
|
24
|
-
return
|
25
|
-
}
|
26
|
-
|
27
|
-
if (args[0]) {
|
28
|
-
const filepath = path.join(hexo.source_dir, args[0])
|
29
|
-
if (fs.existsSync(filepath)) {
|
30
|
-
content = fs.readFileSync(filepath)
|
1
|
+
'use strict';
|
2
|
+
import fs from 'node:fs';
|
3
|
+
import path from 'node:path';
|
4
|
+
import yaml from 'js-yaml';
|
5
|
+
function linkGrid(args, content) {
|
6
|
+
const theme = hexo.theme.config;
|
7
|
+
if (!args[0] && !content) {
|
8
|
+
return;
|
31
9
|
}
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
const siteHost = new URL(hexo.config.url).hostname || hexo.config.url
|
39
|
-
|
40
|
-
const list = yaml.load(content)
|
41
|
-
|
42
|
-
let result = ''
|
43
|
-
|
44
|
-
list.forEach((item) => {
|
45
|
-
if (!item.url || !item.site) {
|
46
|
-
return
|
10
|
+
if (args[0]) {
|
11
|
+
const filepath = path.join(hexo.source_dir, args[0]);
|
12
|
+
if (fs.existsSync(filepath)) {
|
13
|
+
content = fs.readFileSync(filepath);
|
14
|
+
}
|
47
15
|
}
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
if (item.url) {
|
52
|
-
urlparam = new URL(item.url, hexo.config.url)
|
16
|
+
if (!content) {
|
17
|
+
return;
|
53
18
|
}
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
19
|
+
const siteHost = new URL(hexo.config.url).hostname || hexo.config.url;
|
20
|
+
const list = yaml.load(content);
|
21
|
+
let result = '';
|
22
|
+
list.forEach((item) => {
|
23
|
+
if (!item.url || !item.site) {
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
let urlparam = {
|
27
|
+
protocol: undefined,
|
28
|
+
hostname: undefined
|
29
|
+
};
|
30
|
+
if (item.url) {
|
31
|
+
urlparam = new URL(item.url, hexo.config.url);
|
32
|
+
}
|
33
|
+
let item_image = item.image || theme.assets + '/404.png';
|
34
|
+
if (!item_image.startsWith('//') && !item_image.startsWith('http')) {
|
35
|
+
item_image = theme.statics + item_image;
|
36
|
+
}
|
37
|
+
item.color = item.color ? ` style="--block-color:${item.color};"` : '';
|
38
|
+
result += `<div class="item" title="${item.owner || item.site}"${item.color}>`;
|
39
|
+
if (urlparam.protocol && urlparam.hostname !== siteHost) {
|
40
|
+
const durl = Buffer.from(item.url).toString('base64');
|
41
|
+
result += `<span class="exturl image" data-url="${durl}" data-background-image="${item_image}"></span>
|
68
42
|
<div class="info">
|
69
43
|
<span class="exturl title" data-url="${durl}">${item.site}</span>
|
70
44
|
<p class="desc">${item.desc || item.url}</p>
|
71
|
-
</div></div
|
72
|
-
|
73
|
-
|
45
|
+
</div></div>`;
|
46
|
+
}
|
47
|
+
else {
|
48
|
+
result += `<a href="${item.url}" class="image" data-background-image="${item_image}"></a>
|
74
49
|
<div class="info">
|
75
50
|
<a href="${item.url}" class="title">${item.site}</a>
|
76
51
|
<p class="desc">${item.desc || item.url}</p>
|
77
|
-
</div></div
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
return `<div class="links">${result}</div>`
|
52
|
+
</div></div>`;
|
53
|
+
}
|
54
|
+
});
|
55
|
+
return `<div class="links">${result}</div>`;
|
82
56
|
}
|
83
|
-
|
84
|
-
hexo.extend.tag.register('
|
85
|
-
hexo.extend.tag.register('linksfile', linkGrid, { ends: false, async: true })
|
57
|
+
hexo.extend.tag.register('links', linkGrid, { ends: true });
|
58
|
+
hexo.extend.tag.register('linksfile', linkGrid, { ends: false, async: true });
|
package/scripts/tags/media.js
CHANGED
@@ -1,19 +1,14 @@
|
|
1
|
-
'use strict'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
return `<div class="media-container"><div class="player" data-type="${args[0]}" data-src='${JSON.stringify(list)}'></div></div>`
|
14
|
-
}
|
1
|
+
'use strict';
|
2
|
+
import yaml from 'js-yaml';
|
3
|
+
function postMedia(args, content) {
|
4
|
+
if (!args[0] || !content) {
|
5
|
+
return;
|
6
|
+
}
|
7
|
+
const list = yaml.load(content);
|
8
|
+
switch (args[0]) {
|
9
|
+
case 'video':
|
10
|
+
case 'audio':
|
11
|
+
return `<div class="media-container"><div class="player" data-type="${args[0]}" data-src='${JSON.stringify(list)}'></div></div>`;
|
12
|
+
}
|
15
13
|
}
|
16
|
-
|
17
|
-
hexo.extend.tag.register('media', postMedia, { ends: true })
|
18
|
-
|
19
|
-
// return `<video src="${args}" preload="metadata" controls playsinline poster="">Sorry, your browser does not support the video tag.</video>`;
|
14
|
+
hexo.extend.tag.register('media', postMedia, { ends: true });
|
package/source/css/_mixins.styl
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
$mobile-wdith = hexo-config('experiments.mobileWidth')
|
2
|
+
|
1
3
|
the-transition(duration = .2s, function = ease-in-out, delay = 0s, property = all) {
|
2
4
|
transition:property duration function delay;
|
3
5
|
}
|
@@ -15,7 +17,7 @@ mobile-small() {
|
|
15
17
|
}
|
16
18
|
|
17
19
|
mobile() {
|
18
|
-
@media (max-width:
|
20
|
+
@media (max-width: $mobile-wdith) {
|
19
21
|
{block};
|
20
22
|
}
|
21
23
|
}
|
@@ -27,13 +29,13 @@ tablet-mobile() {
|
|
27
29
|
}
|
28
30
|
|
29
31
|
tablet-desktop() {
|
30
|
-
@media (min-width:
|
32
|
+
@media (min-width: $mobile-wdith) {
|
31
33
|
{block};
|
32
34
|
}
|
33
35
|
}
|
34
36
|
|
35
37
|
tablet() {
|
36
|
-
@media (min-width:
|
38
|
+
@media (min-width: $mobile-wdith) and (max-width: 1043px) {
|
37
39
|
{block};
|
38
40
|
}
|
39
41
|
}
|
@@ -120,8 +120,18 @@ const render = anime({
|
|
120
120
|
ctx.clearRect(0, 0, canvasEl.width, canvasEl.height);
|
121
121
|
}
|
122
122
|
});
|
123
|
+
const hasAncestor = function (node, name) {
|
124
|
+
name = name.toUpperCase();
|
125
|
+
do {
|
126
|
+
if (node === null || node === undefined)
|
127
|
+
break;
|
128
|
+
if (node.nodeName === name)
|
129
|
+
return true;
|
130
|
+
} while (node = node.parentNode);
|
131
|
+
return false;
|
132
|
+
};
|
123
133
|
document.addEventListener(tap, function (e) {
|
124
|
-
if (e.target
|
134
|
+
if (hasAncestor(e.target, 'a')) {
|
125
135
|
return;
|
126
136
|
}
|
127
137
|
render.play();
|
package/source/js/_app/global.js
CHANGED
@@ -184,8 +184,12 @@ const scrollHandle = function (event) {
|
|
184
184
|
else { }
|
185
185
|
scrollAction.y = window.scrollY;
|
186
186
|
const scrollPercent = Math.round(Math.min(100 * window.scrollY / contentVisibilityHeight, 100)) + '%';
|
187
|
-
backToTop.child('span').innerText
|
188
|
-
|
187
|
+
if (backToTop.child('span').innerText !== scrollPercent) {
|
188
|
+
backToTop.child('span').innerText = scrollPercent;
|
189
|
+
}
|
190
|
+
if ($dom('#sidebar').hasClass('affix') || $dom('#sidebar').hasClass('on')) {
|
191
|
+
$dom('.percent').changeOrGetWidth(scrollPercent);
|
192
|
+
}
|
189
193
|
};
|
190
194
|
const pagePosition = function () {
|
191
195
|
if (CONFIG.auto_scroll) {
|
package/source/js/_app/page.js
CHANGED
@@ -332,6 +332,31 @@ const postBeauty = function () {
|
|
332
332
|
btns: []
|
333
333
|
}).player.load(JSON.parse(element.attr('data-src'))).fetch();
|
334
334
|
});
|
335
|
+
const angleDown = document.querySelectorAll('.show-btn .i-angle-down');
|
336
|
+
if (angleDown.length) {
|
337
|
+
if (!window.IntersectionObserver)
|
338
|
+
return;
|
339
|
+
const io = new IntersectionObserver((entries) => {
|
340
|
+
entries.forEach(entry => {
|
341
|
+
if (entry.isIntersecting) {
|
342
|
+
angleDown.forEach(i => {
|
343
|
+
i.classList.remove('stop-animation');
|
344
|
+
});
|
345
|
+
}
|
346
|
+
else {
|
347
|
+
angleDown.forEach(i => {
|
348
|
+
i.classList.add('stop-animation');
|
349
|
+
});
|
350
|
+
}
|
351
|
+
});
|
352
|
+
}, {
|
353
|
+
root: null,
|
354
|
+
threshold: 0.5
|
355
|
+
});
|
356
|
+
angleDown.forEach(i => {
|
357
|
+
io.observe(i);
|
358
|
+
});
|
359
|
+
}
|
335
360
|
};
|
336
361
|
const tabFormat = function () {
|
337
362
|
let first_tab;
|
@@ -546,6 +571,47 @@ const domInit = function () {
|
|
546
571
|
toolPlayer.player.mini();
|
547
572
|
});
|
548
573
|
}
|
574
|
+
const createIntersectionObserver = function () {
|
575
|
+
if (!window.IntersectionObserver)
|
576
|
+
return;
|
577
|
+
new IntersectionObserver(([entry]) => {
|
578
|
+
if (entry.isIntersecting) {
|
579
|
+
document.querySelectorAll('.parallax>use').forEach(i => {
|
580
|
+
i.classList.remove('stop-animation');
|
581
|
+
});
|
582
|
+
document.querySelectorAll('#imgs .item').forEach(i => {
|
583
|
+
i.classList.remove('stop-animation');
|
584
|
+
});
|
585
|
+
}
|
586
|
+
else {
|
587
|
+
document.querySelectorAll('.parallax>use').forEach(i => {
|
588
|
+
i.classList.add('stop-animation');
|
589
|
+
});
|
590
|
+
document.querySelectorAll('#imgs .item').forEach(i => {
|
591
|
+
i.classList.add('stop-animation');
|
592
|
+
});
|
593
|
+
}
|
594
|
+
}, {
|
595
|
+
root: null,
|
596
|
+
threshold: 0.2
|
597
|
+
}).observe(document.getElementById('waves'));
|
598
|
+
new IntersectionObserver(([entry]) => {
|
599
|
+
if (entry.isIntersecting) {
|
600
|
+
document.querySelectorAll('.with-love>i').forEach(i => {
|
601
|
+
i.classList.remove('stop-animation');
|
602
|
+
});
|
603
|
+
}
|
604
|
+
else {
|
605
|
+
document.querySelectorAll('.with-love>i').forEach(i => {
|
606
|
+
i.classList.add('stop-animation');
|
607
|
+
});
|
608
|
+
}
|
609
|
+
}, {
|
610
|
+
root: null,
|
611
|
+
threshold: 0.2
|
612
|
+
}).observe(document.querySelector('.with-love'));
|
613
|
+
};
|
614
|
+
createIntersectionObserver();
|
549
615
|
};
|
550
616
|
const pjaxReload = function () {
|
551
617
|
pagePosition();
|