hexo-theme-shokax 0.2.1 → 0.2.3
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/.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,140 +1,111 @@
|
|
1
|
-
'use strict'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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 hexo_fs_1 = __importDefault(require("hexo-fs"));
|
6
7
|
const prepareQuery = (categories, parent) => {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
const query = {
|
9
|
+
parent: undefined
|
10
|
+
};
|
11
|
+
if (parent) {
|
12
|
+
query.parent = parent;
|
13
|
+
}
|
14
|
+
else {
|
15
|
+
query.parent = { $exists: false };
|
16
|
+
}
|
17
|
+
return categories.find(query).sort('name', 1).filter(cat => cat.length);
|
18
|
+
};
|
18
19
|
hexo.extend.helper.register('_list_categories', function (depth = 0) {
|
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
|
-
if (level === 0) {
|
55
|
-
result += '</div>'
|
56
|
-
}
|
57
|
-
})
|
58
|
-
|
59
|
-
return result
|
60
|
-
}
|
61
|
-
|
62
|
-
return hierarchicalList(0)
|
63
|
-
})
|
64
|
-
|
20
|
+
const categories = this.site.categories;
|
21
|
+
if (!categories || !categories.length)
|
22
|
+
return '';
|
23
|
+
const hierarchicalList = (level, parent) => {
|
24
|
+
let result = '';
|
25
|
+
prepareQuery(categories, parent).forEach((cat, i) => {
|
26
|
+
let child;
|
27
|
+
if (level + 1 < depth) {
|
28
|
+
child = hierarchicalList(level + 1, cat._id);
|
29
|
+
}
|
30
|
+
const catname = `<a itemprop="url" href="${this.url_for(cat.path)}">${cat.name}</a><small>( ${cat.length} )</small>`;
|
31
|
+
switch (level) {
|
32
|
+
case 0:
|
33
|
+
result += `<div><h2 class="item header">${catname}</h2>`;
|
34
|
+
break;
|
35
|
+
case 1:
|
36
|
+
result += `<h3 class="item section">${catname}</h3>`;
|
37
|
+
break;
|
38
|
+
case 2:
|
39
|
+
result += `<div class="item normal"><div class="title">${catname}</div></div>`;
|
40
|
+
break;
|
41
|
+
}
|
42
|
+
if (child) {
|
43
|
+
result += `${child}`;
|
44
|
+
}
|
45
|
+
if (level === 0) {
|
46
|
+
result += '</div>';
|
47
|
+
}
|
48
|
+
});
|
49
|
+
return result;
|
50
|
+
};
|
51
|
+
return hierarchicalList(0);
|
52
|
+
});
|
65
53
|
hexo.extend.helper.register('_categories', function () {
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
const pangu = this.theme.pangu
|
71
|
-
? require('pangu')
|
72
|
-
: {
|
54
|
+
const categories = this.site.categories;
|
55
|
+
if (!categories || !categories.length)
|
56
|
+
return '';
|
57
|
+
const pangu = {
|
73
58
|
spacing: data => {
|
74
|
-
|
59
|
+
return data;
|
75
60
|
}
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
result[cat._id] = cat
|
95
|
-
}
|
96
|
-
})
|
97
|
-
|
98
|
-
return result
|
99
|
-
})
|
100
|
-
|
61
|
+
};
|
62
|
+
const result = {};
|
63
|
+
categories.forEach((cat, i) => {
|
64
|
+
const child = prepareQuery(categories, cat._id);
|
65
|
+
const cover = 'source/_posts' + cat.path.replace(this.config.category_dir, '') + 'cover.jpg';
|
66
|
+
if (hexo_fs_1.default.existsSync(cover)) {
|
67
|
+
const className = cat.slug.split('/');
|
68
|
+
className.pop();
|
69
|
+
cat.class = className.join(' ');
|
70
|
+
cat.name = pangu.spacing(cat.name);
|
71
|
+
if (child.length !== 0) {
|
72
|
+
cat.child = child;
|
73
|
+
}
|
74
|
+
result[cat._id] = cat;
|
75
|
+
}
|
76
|
+
});
|
77
|
+
return result;
|
78
|
+
});
|
101
79
|
hexo.extend.helper.register('_category_prev', function (name) {
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
return result
|
117
|
-
})
|
118
|
-
|
80
|
+
const categories = this.site.categories;
|
81
|
+
if (!categories || !categories.length)
|
82
|
+
return '';
|
83
|
+
let result = '';
|
84
|
+
categories.find({ name }).forEach((current) => {
|
85
|
+
if (current.parent) {
|
86
|
+
categories.find({ _id: current.parent }).forEach((cat, i) => {
|
87
|
+
result += `<a href="${this.url_for(cat.path)}">${cat.name}</a>`;
|
88
|
+
});
|
89
|
+
}
|
90
|
+
});
|
91
|
+
return result;
|
92
|
+
});
|
119
93
|
hexo.extend.helper.register('_category_posts', function (page) {
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
94
|
+
const categories = this.site.categories;
|
95
|
+
if (!categories || !categories.length || !page.categories || !page.categories.length)
|
96
|
+
return '';
|
97
|
+
let result = '';
|
98
|
+
const cat = page.categories.toArray();
|
99
|
+
categories.find({ _id: cat[cat.length - 1]._id }).forEach((category) => {
|
100
|
+
if (category.posts) {
|
101
|
+
category.posts.sort('date', 1).forEach((post) => {
|
102
|
+
let current = '';
|
103
|
+
if (post.path === page.path) {
|
104
|
+
current = ' class="active"';
|
105
|
+
}
|
106
|
+
result += `<li ${current}><a href="${this.url_for(post.path)}" rel="bookmark" title="${post.title}">${post.title}</a></li>`;
|
107
|
+
});
|
133
108
|
}
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
})
|
138
|
-
|
139
|
-
return result
|
140
|
-
})
|
109
|
+
});
|
110
|
+
return result;
|
111
|
+
});
|
@@ -1,76 +1,63 @@
|
|
1
|
-
'use strict'
|
2
|
-
|
3
|
-
|
4
|
-
hexo-symbols-count-time by theme-next
|
5
|
-
under GNU Lesser General Public License v3.0
|
6
|
-
https://github.com/theme-next/hexo-symbols-count-time/blob/master/LICENSE
|
7
|
-
*/
|
8
|
-
|
9
|
-
const { stripHTML } = require('hexo-util')
|
10
|
-
|
1
|
+
'use strict';
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const hexo_util_1 = require("hexo-util");
|
11
4
|
const config = hexo.config.symbols_count_time = Object.assign({
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}, hexo.config.symbols_count_time)
|
21
|
-
|
22
|
-
|
23
|
-
return post?._content?.length ?? post?.content?.length ?? post.length
|
5
|
+
symbols: true,
|
6
|
+
time: true,
|
7
|
+
total_symbols: true,
|
8
|
+
total_time: true,
|
9
|
+
exclude_codeblock: false,
|
10
|
+
awl: 4,
|
11
|
+
wpm: 275,
|
12
|
+
suffix: 'mins.'
|
13
|
+
}, hexo.config.symbols_count_time);
|
14
|
+
function getSymbols(post) {
|
15
|
+
return post?._content?.length ?? post?.content?.length ?? post.length;
|
24
16
|
}
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
return symbolsResultCount
|
17
|
+
function getSymbolsTotal(site) {
|
18
|
+
let symbolsResultCount = 0;
|
19
|
+
site.posts.forEach((post) => {
|
20
|
+
symbolsResultCount += getSymbols(post);
|
21
|
+
});
|
22
|
+
return symbolsResultCount;
|
32
23
|
}
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
: fHours + ':' + ('00' + fMinutes).slice(-2) // = 61 => 1:01
|
24
|
+
function getFormatTime(minutes, suffix) {
|
25
|
+
const fHours = Math.floor(minutes / 60);
|
26
|
+
let fMinutes = Math.floor(minutes - (fHours * 60));
|
27
|
+
if (fMinutes < 1) {
|
28
|
+
fMinutes = 1;
|
29
|
+
}
|
30
|
+
return fHours < 1
|
31
|
+
? fMinutes + ' ' + suffix
|
32
|
+
: fHours + ':' + ('00' + fMinutes).slice(-2);
|
43
33
|
}
|
44
|
-
|
45
34
|
hexo.extend.helper.register('symbolsCount', function (post) {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
35
|
+
let symbolsResult = getSymbols(post);
|
36
|
+
if (symbolsResult > 9999) {
|
37
|
+
symbolsResult = Math.round(symbolsResult / 1000) + 'k';
|
38
|
+
}
|
39
|
+
else if (symbolsResult > 999) {
|
40
|
+
symbolsResult = Math.round(symbolsResult / 100) / 10 + 'k';
|
41
|
+
}
|
42
|
+
return symbolsResult;
|
43
|
+
});
|
55
44
|
hexo.extend.helper.register('symbolsTime', function (post, awl = config.awl, wpm = config.wpm, suffix = config.suffix) {
|
56
|
-
|
57
|
-
|
58
|
-
})
|
59
|
-
|
45
|
+
const minutes = Math.round(getSymbols(post) / (awl * wpm));
|
46
|
+
return getFormatTime(minutes, suffix);
|
47
|
+
});
|
60
48
|
hexo.extend.helper.register('symbolsCountTotal', function (site) {
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
})
|
66
|
-
|
49
|
+
const symbolsResultTotal = getSymbolsTotal(site);
|
50
|
+
return symbolsResultTotal < 1000000
|
51
|
+
? Math.round(symbolsResultTotal / 1000) + 'k'
|
52
|
+
: Math.round(symbolsResultTotal / 100000) / 10 + 'm';
|
53
|
+
});
|
67
54
|
hexo.extend.helper.register('symbolsTimeTotal', function (site, awl = config.awl, wpm = config.wpm, suffix = config.suffix) {
|
68
|
-
|
69
|
-
|
70
|
-
})
|
71
|
-
|
55
|
+
const minutes = Math.round(getSymbolsTotal(site) / (awl * wpm));
|
56
|
+
return getFormatTime(minutes, suffix);
|
57
|
+
});
|
72
58
|
hexo.extend.filter.register('after_post_render', (data) => {
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
59
|
+
let { content } = data;
|
60
|
+
if (config.exclude_codeblock)
|
61
|
+
content = content.replace(/<pre>.*?<\/pre>/g, '');
|
62
|
+
data.length = (0, hexo_util_1.stripHTML)(content).replace(/\r?\n|\r/g, '').replace(/\s+/g, '').length;
|
63
|
+
}, 0);
|
package/scripts/plugin/index.js
CHANGED
@@ -1,49 +1,50 @@
|
|
1
|
-
|
2
|
-
|
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 injects_1 = __importDefault(require("./lib/injects"));
|
7
|
+
const node_https_1 = __importDefault(require("node:https"));
|
8
|
+
const package_json_1 = require("../../package.json");
|
3
9
|
hexo.on('generateBefore', () => {
|
4
|
-
|
5
|
-
|
6
|
-
})
|
7
|
-
|
10
|
+
(0, injects_1.default)(hexo);
|
11
|
+
});
|
8
12
|
hexo.on('generateAfter', () => {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
const { version } = require(path.normalize('../../package.json'))
|
13
|
-
https.get('https://api.github.com/repos/zkz098/hexo-theme-shokaX/releases/latest', {
|
14
|
-
headers: {
|
15
|
-
'User-Agent': 'Theme ShokaX Client'
|
16
|
-
}
|
17
|
-
}, (res) => {
|
18
|
-
let result = ''
|
19
|
-
res.on('data', (data) => {
|
20
|
-
result += data
|
21
|
-
})
|
22
|
-
res.on('end', () => {
|
23
|
-
try {
|
24
|
-
const latest = JSON.parse(result).tag_name.replace('v', '').split('.')
|
25
|
-
const current = version.split('.')
|
26
|
-
let isOutdated = false
|
27
|
-
for (let i = 0; i < Math.max(latest.length, current.length); i++) {
|
28
|
-
if (!current[i] || latest[i] > current[i]) {
|
29
|
-
isOutdated = true
|
30
|
-
break
|
31
|
-
}
|
32
|
-
if (latest[i] < current[i]) {
|
33
|
-
break
|
34
|
-
}
|
13
|
+
node_https_1.default.get('https://api.github.com/repos/theme-shoka-x/hexo-theme-shokaX/releases/latest', {
|
14
|
+
headers: {
|
15
|
+
'User-Agent': 'Theme ShokaX Client'
|
35
16
|
}
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
17
|
+
}, (res) => {
|
18
|
+
let result = '';
|
19
|
+
res.on('data', (data) => {
|
20
|
+
result += data;
|
21
|
+
});
|
22
|
+
res.on('end', () => {
|
23
|
+
try {
|
24
|
+
const latest = JSON.parse(result).tag_name.replace('v', '').split('.');
|
25
|
+
const current = package_json_1.version.split('.');
|
26
|
+
let isOutdated = false;
|
27
|
+
for (let i = 0; i < Math.max(latest.length, current.length); i++) {
|
28
|
+
if (!current[i] || latest[i] > current[i]) {
|
29
|
+
isOutdated = true;
|
30
|
+
break;
|
31
|
+
}
|
32
|
+
if (latest[i] < current[i]) {
|
33
|
+
break;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
if (isOutdated) {
|
37
|
+
hexo.log.warn(`Your theme ShokaX is outdated. Current version: v${current.join('.')}, latest version: v${latest.join('.')}`);
|
38
|
+
hexo.log.warn('Visit https://github.com/theme-shoka-x/hexo-theme-shokaX/releases for more information.');
|
39
|
+
}
|
40
|
+
}
|
41
|
+
catch (err) {
|
42
|
+
hexo.log.error('Failed to detect version info. Error message:');
|
43
|
+
hexo.log.error(err);
|
44
|
+
}
|
45
|
+
});
|
46
|
+
}).on('error', err => {
|
47
|
+
hexo.log.error('Failed to detect version info. Error message:');
|
48
|
+
hexo.log.error(err);
|
49
|
+
});
|
50
|
+
});
|
@@ -1,20 +1,20 @@
|
|
1
|
-
'use strict'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}
|
1
|
+
'use strict';
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = {
|
4
|
+
views: [
|
5
|
+
'head',
|
6
|
+
'sidebar',
|
7
|
+
'rightNav',
|
8
|
+
'postMeta',
|
9
|
+
'postBodyEnd',
|
10
|
+
'footer',
|
11
|
+
'bodyEnd',
|
12
|
+
'comment',
|
13
|
+
'status'
|
14
|
+
],
|
15
|
+
styles: [
|
16
|
+
'variable',
|
17
|
+
'mixin',
|
18
|
+
'style'
|
19
|
+
]
|
20
|
+
};
|