hexo-theme-shokax 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.cjs +30 -0
- package/README.md +6 -5
- package/_config.yml +2 -1
- package/_images.yml +1 -92
- package/layout/_partials/footer.pug +1 -1
- package/package.json +5 -2
- package/scripts/filters/locals.js +44 -57
- package/scripts/filters/post.js +13 -19
- package/scripts/generaters/archive.js +115 -135
- package/scripts/generaters/config.js +35 -38
- package/scripts/generaters/images.js +23 -24
- package/scripts/generaters/index.js +100 -105
- package/scripts/generaters/pages.js +15 -18
- package/scripts/generaters/script.js +91 -90
- package/scripts/helpers/asset.js +128 -134
- package/scripts/helpers/engine.js +128 -185
- package/scripts/helpers/list_categories.js +103 -132
- package/scripts/helpers/symbols_count_time.js +54 -67
- package/scripts/plugin/index.js +47 -46
- package/scripts/plugin/lib/injects-point.js +20 -20
- package/scripts/plugin/lib/injects.js +63 -82
- package/scripts/tags/links.js +52 -75
- package/scripts/tags/media.js +17 -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/css/app.styl +9 -6
- package/source/js/_app/fireworks.js +11 -1
- package/source/js/_app/global.js +6 -2
- package/source/js/_app/page.js +66 -0
@@ -1,89 +1,70 @@
|
|
1
|
-
'use strict'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
const
|
7
|
-
const
|
8
|
-
|
9
|
-
|
1
|
+
'use strict';
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
8
|
+
const injects_point_1 = __importDefault(require("./injects-point"));
|
9
|
+
const defaultExtname = '.pug';
|
10
10
|
class StylusInject {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
this.files.push(path.resolve(this.base_dir, file))
|
19
|
-
}
|
11
|
+
constructor(base_dir) {
|
12
|
+
this.base_dir = base_dir;
|
13
|
+
this.files = [];
|
14
|
+
}
|
15
|
+
push(file) {
|
16
|
+
this.files.push(node_path_1.default.resolve(this.base_dir, file));
|
17
|
+
}
|
20
18
|
}
|
21
|
-
|
22
|
-
// Defining view types
|
23
19
|
class ViewInject {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}
|
28
|
-
|
29
|
-
raw (name, raw, ...args) {
|
30
|
-
// Set default extname
|
31
|
-
if (path.extname(name) === '') {
|
32
|
-
name += defaultExtname
|
20
|
+
constructor(base_dir) {
|
21
|
+
this.base_dir = base_dir;
|
22
|
+
this.raws = [];
|
33
23
|
}
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
24
|
+
raw(name, raw, ...args) {
|
25
|
+
if (node_path_1.default.extname(name) === '') {
|
26
|
+
name += defaultExtname;
|
27
|
+
}
|
28
|
+
this.raws.push({ name, raw, args });
|
29
|
+
}
|
30
|
+
file(name, file, ...args) {
|
31
|
+
if (node_path_1.default.extname(name) === '') {
|
32
|
+
name += node_path_1.default.extname(file);
|
33
|
+
}
|
34
|
+
this.raw(name, node_fs_1.default.readFileSync(node_path_1.default.resolve(this.base_dir, file), 'utf8'), ...args);
|
41
35
|
}
|
42
|
-
// Get absolute path base on hexo dir
|
43
|
-
this.raw(name, fs.readFileSync(path.resolve(this.base_dir, file), 'utf8'), ...args)
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
// Init injects
|
48
|
-
function initInject (base_dir) {
|
49
|
-
const injects = {}
|
50
|
-
points.styles.forEach(item => {
|
51
|
-
injects[item] = new StylusInject(base_dir)
|
52
|
-
})
|
53
|
-
points.views.forEach(item => {
|
54
|
-
injects[item] = new ViewInject(base_dir)
|
55
|
-
})
|
56
|
-
return injects
|
57
36
|
}
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
hexo.theme.config.injects[type] = injects[type].files
|
68
|
-
})
|
69
|
-
|
70
|
-
// Inject views
|
71
|
-
points.views.forEach(type => {
|
72
|
-
const configs = Object.create(null)
|
73
|
-
hexo.theme.config.injects[type] = []
|
74
|
-
// Add or override view.
|
75
|
-
injects[type].raws.forEach((injectObj, index) => {
|
76
|
-
const name = `inject/${type}/${injectObj.name}`
|
77
|
-
hexo.theme.setView(name, injectObj.raw)
|
78
|
-
configs[name] = {
|
79
|
-
layout: name,
|
80
|
-
locals: injectObj.args[0],
|
81
|
-
options: injectObj.args[1],
|
82
|
-
order: injectObj.args[2] || index
|
83
|
-
}
|
84
|
-
})
|
85
|
-
// Views sort.
|
86
|
-
hexo.theme.config.injects[type] = Object.values(configs)
|
87
|
-
.sort((x, y) => x.order - y.order)
|
88
|
-
})
|
37
|
+
function initInject(base_dir) {
|
38
|
+
const injects = {};
|
39
|
+
injects_point_1.default.styles.forEach(item => {
|
40
|
+
injects[item] = new StylusInject(base_dir);
|
41
|
+
});
|
42
|
+
injects_point_1.default.views.forEach(item => {
|
43
|
+
injects[item] = new ViewInject(base_dir);
|
44
|
+
});
|
45
|
+
return injects;
|
89
46
|
}
|
47
|
+
exports.default = (hexo) => {
|
48
|
+
const injects = initInject(hexo.base_dir);
|
49
|
+
hexo.execFilterSync('theme_inject', injects);
|
50
|
+
hexo.theme.config.injects = {};
|
51
|
+
injects_point_1.default.styles.forEach(type => {
|
52
|
+
hexo.theme.config.injects[type] = injects[type].files;
|
53
|
+
});
|
54
|
+
injects_point_1.default.views.forEach(type => {
|
55
|
+
const configs = Object.create(null);
|
56
|
+
hexo.theme.config.injects[type] = [];
|
57
|
+
injects[type].raws.forEach((injectObj, index) => {
|
58
|
+
const name = `inject/${type}/${injectObj.name}`;
|
59
|
+
hexo.theme.setView(name, injectObj.raw);
|
60
|
+
configs[name] = {
|
61
|
+
layout: name,
|
62
|
+
locals: injectObj.args[0],
|
63
|
+
options: injectObj.args[1],
|
64
|
+
order: injectObj.args[2] || index
|
65
|
+
};
|
66
|
+
});
|
67
|
+
hexo.theme.config.injects[type] = Object.values(configs)
|
68
|
+
.sort((x, y) => x.order - y.order);
|
69
|
+
});
|
70
|
+
};
|
package/scripts/tags/links.js
CHANGED
@@ -1,85 +1,62 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
8
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
9
|
+
function linkGrid(args, content) {
|
10
|
+
const theme = hexo.theme.config;
|
11
|
+
if (!args[0] && !content) {
|
12
|
+
return;
|
31
13
|
}
|
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
|
14
|
+
if (args[0]) {
|
15
|
+
const filepath = node_path_1.default.join(hexo.source_dir, args[0]);
|
16
|
+
if (node_fs_1.default.existsSync(filepath)) {
|
17
|
+
content = node_fs_1.default.readFileSync(filepath);
|
18
|
+
}
|
47
19
|
}
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
if (item.url) {
|
52
|
-
urlparam = new URL(item.url, hexo.config.url)
|
20
|
+
if (!content) {
|
21
|
+
return;
|
53
22
|
}
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
23
|
+
const siteHost = new URL(hexo.config.url).hostname || hexo.config.url;
|
24
|
+
const list = js_yaml_1.default.load(content);
|
25
|
+
let result = '';
|
26
|
+
list.forEach((item) => {
|
27
|
+
if (!item.url || !item.site) {
|
28
|
+
return;
|
29
|
+
}
|
30
|
+
let urlparam = {
|
31
|
+
protocol: undefined,
|
32
|
+
hostname: undefined
|
33
|
+
};
|
34
|
+
if (item.url) {
|
35
|
+
urlparam = new URL(item.url, hexo.config.url);
|
36
|
+
}
|
37
|
+
let item_image = item.image || theme.assets + '/404.png';
|
38
|
+
if (!item_image.startsWith('//') && !item_image.startsWith('http')) {
|
39
|
+
item_image = theme.statics + item_image;
|
40
|
+
}
|
41
|
+
item.color = item.color ? ` style="--block-color:${item.color};"` : '';
|
42
|
+
result += `<div class="item" title="${item.owner || item.site}"${item.color}>`;
|
43
|
+
if (urlparam.protocol && urlparam.hostname !== siteHost) {
|
44
|
+
const durl = Buffer.from(item.url).toString('base64');
|
45
|
+
result += `<span class="exturl image" data-url="${durl}" data-background-image="${item_image}"></span>
|
68
46
|
<div class="info">
|
69
47
|
<span class="exturl title" data-url="${durl}">${item.site}</span>
|
70
48
|
<p class="desc">${item.desc || item.url}</p>
|
71
|
-
</div></div
|
72
|
-
|
73
|
-
|
49
|
+
</div></div>`;
|
50
|
+
}
|
51
|
+
else {
|
52
|
+
result += `<a href="${item.url}" class="image" data-background-image="${item_image}"></a>
|
74
53
|
<div class="info">
|
75
54
|
<a href="${item.url}" class="title">${item.site}</a>
|
76
55
|
<p class="desc">${item.desc || item.url}</p>
|
77
|
-
</div></div
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
return `<div class="links">${result}</div>`
|
56
|
+
</div></div>`;
|
57
|
+
}
|
58
|
+
});
|
59
|
+
return `<div class="links">${result}</div>`;
|
82
60
|
}
|
83
|
-
|
84
|
-
hexo.extend.tag.register('
|
85
|
-
hexo.extend.tag.register('linksfile', linkGrid, { ends: false, async: true })
|
61
|
+
hexo.extend.tag.register('links', linkGrid, { ends: true });
|
62
|
+
hexo.extend.tag.register('linksfile', linkGrid, { ends: false, async: true });
|
package/scripts/tags/media.js
CHANGED
@@ -1,19 +1,18 @@
|
|
1
|
-
'use strict'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
'use strict';
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
7
|
+
function postMedia(args, content) {
|
8
|
+
if (!args[0] || !content) {
|
9
|
+
return;
|
10
|
+
}
|
11
|
+
const list = js_yaml_1.default.load(content);
|
12
|
+
switch (args[0]) {
|
13
|
+
case 'video':
|
14
|
+
case 'audio':
|
15
|
+
return `<div class="media-container"><div class="player" data-type="${args[0]}" data-src='${JSON.stringify(list)}'></div></div>`;
|
16
|
+
}
|
15
17
|
}
|
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>`;
|
18
|
+
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
|
}
|
package/source/css/app.styl
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
@import "_variables";
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
if hexo-config('injects.variable')
|
4
|
+
for $inject_variable in hexo-config('injects.variable')
|
5
|
+
@import $inject_variable
|
5
6
|
|
6
7
|
@import "_mixins";
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
if hexo-config('injects.mixin')
|
10
|
+
for $inject_mixin in hexo-config('injects.mixin')
|
11
|
+
@import $inject_mixin;
|
10
12
|
|
11
13
|
if $colors = hexo-config('style.colors')
|
12
14
|
@import $colors;
|
@@ -30,8 +32,9 @@ else
|
|
30
32
|
if $custom = hexo-config('style.custom')
|
31
33
|
@import $custom;
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
+
if hexo-config('injects.style')
|
36
|
+
for $inject_style in hexo-config('injects.style')
|
37
|
+
@import $inject_style;
|
35
38
|
|
36
39
|
if $optimize = hexo-config('experiments.optimizeLongPosts')
|
37
40
|
@import "optimize.styl"
|
@@ -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();
|