hexo-theme-shokax 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,25 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const fs = require('hexo-fs')
|
5
|
-
|
1
|
+
'use strict';
|
2
|
+
const fs = require('hexo-fs');
|
6
3
|
hexo.extend.generator.register('images', function (locals) {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
})
|
22
|
-
|
23
|
-
|
24
|
-
return result
|
25
|
-
})
|
4
|
+
const theme = hexo.theme.config;
|
5
|
+
const dir = 'source/_data/' + theme.assets + '/';
|
6
|
+
if (!fs.existsSync(dir)) {
|
7
|
+
return;
|
8
|
+
}
|
9
|
+
const result = [];
|
10
|
+
const files = fs.listDirSync(dir);
|
11
|
+
files.forEach((file) => {
|
12
|
+
result.push({
|
13
|
+
path: theme.assets + '/' + file,
|
14
|
+
data: function () {
|
15
|
+
return fs.createReadStream(dir + file);
|
16
|
+
}
|
17
|
+
});
|
18
|
+
});
|
19
|
+
return result;
|
20
|
+
});
|
@@ -1,109 +1,100 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const fs = require('hexo-fs')
|
5
|
-
const pagination = require('hexo-pagination')
|
6
|
-
|
1
|
+
'use strict';
|
2
|
+
const fs = require('hexo-fs');
|
3
|
+
const pagination = require('hexo-pagination');
|
7
4
|
hexo.config.index_generator = Object.assign({
|
8
|
-
|
9
|
-
|
10
|
-
}, hexo.config.index_generator)
|
11
|
-
|
5
|
+
per_page: typeof hexo.config.per_page === 'undefined' ? 10 : hexo.config.per_page,
|
6
|
+
order_by: '-date'
|
7
|
+
}, hexo.config.index_generator);
|
12
8
|
hexo.extend.generator.register('index', function (locals) {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
return getTopcat(pCat)
|
27
|
-
} else {
|
28
|
-
return cat
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
if (categories && categories.length) {
|
33
|
-
categories.forEach((cat) => {
|
34
|
-
const cover = `source/_posts/${cat.slug}`
|
35
|
-
if (fs.existsSync(cover + '/cover.avif')) {
|
36
|
-
covers.push({
|
37
|
-
path: cat.slug + '/cover.avif',
|
38
|
-
data: function () {
|
39
|
-
return fs.createReadStream(cover + '/cover.avif')
|
40
|
-
}
|
41
|
-
})
|
42
|
-
} else if (fs.existsSync(cover + '/cover.webp')) {
|
43
|
-
covers.push({
|
44
|
-
path: cat.slug + '/cover.webp',
|
45
|
-
data: function () {
|
46
|
-
return fs.createReadStream(cover + '/cover.webp')
|
47
|
-
}
|
48
|
-
})
|
49
|
-
} else if (fs.existsSync(cover + '/cover.jpg')) {
|
50
|
-
covers.push({
|
51
|
-
path: cat.slug + '/cover.jpg',
|
52
|
-
data: function () {
|
53
|
-
return fs.createReadStream(cover + '/cover.jpg')
|
54
|
-
}
|
55
|
-
})
|
56
|
-
|
57
|
-
const topcat = getTopcat(cat)
|
58
|
-
|
59
|
-
if (topcat._id !== cat._id) {
|
60
|
-
cat.top = topcat
|
9
|
+
const covers = [];
|
10
|
+
const catlist = [];
|
11
|
+
let pages;
|
12
|
+
const config = hexo.config;
|
13
|
+
const sticky = locals.posts.find({ sticky: true }).sort(config.index_generator.order_by);
|
14
|
+
const posts = locals.posts.find({ sticky: { $exists: false } }).sort(config.index_generator.order_by);
|
15
|
+
const paginationDir = config.pagination_dir || 'page';
|
16
|
+
const path = config.index_generator.path || '';
|
17
|
+
const categories = locals.categories;
|
18
|
+
const getTopcat = function (cat) {
|
19
|
+
if (cat.parent) {
|
20
|
+
const pCat = categories.findOne({ _id: cat.parent });
|
21
|
+
return getTopcat(pCat);
|
61
22
|
}
|
62
|
-
|
63
|
-
|
64
|
-
let pl = 6
|
65
|
-
|
66
|
-
if (child.length !== 0) {
|
67
|
-
cat.child = child.length
|
68
|
-
cat.subs = child.sort({ name: 1 }).limit(6).toArray()
|
69
|
-
pl = Math.max(0, pl - child.length)
|
70
|
-
if (pl > 0) {
|
71
|
-
// TODO 需要测试
|
72
|
-
cat.subs.push.apply(cat.subs, cat.posts.sort({ title: 1 }).filter(function (item, i) {
|
73
|
-
return item.categories.last()._id === cat._id
|
74
|
-
}).limit(pl).toArray())
|
75
|
-
}
|
76
|
-
} else {
|
77
|
-
cat.subs = cat.posts.sort({ title: 1 }).limit(6).toArray()
|
23
|
+
else {
|
24
|
+
return cat;
|
78
25
|
}
|
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
|
-
}
|
26
|
+
};
|
27
|
+
if (categories && categories.length) {
|
28
|
+
categories.forEach((cat) => {
|
29
|
+
const cover = `source/_posts/${cat.slug}`;
|
30
|
+
if (fs.existsSync(cover + '/cover.avif')) {
|
31
|
+
covers.push({
|
32
|
+
path: cat.slug + '/cover.avif',
|
33
|
+
data: function () {
|
34
|
+
return fs.createReadStream(cover + '/cover.avif');
|
35
|
+
}
|
36
|
+
});
|
37
|
+
}
|
38
|
+
else if (fs.existsSync(cover + '/cover.webp')) {
|
39
|
+
covers.push({
|
40
|
+
path: cat.slug + '/cover.webp',
|
41
|
+
data: function () {
|
42
|
+
return fs.createReadStream(cover + '/cover.webp');
|
43
|
+
}
|
44
|
+
});
|
45
|
+
}
|
46
|
+
else if (fs.existsSync(cover + '/cover.jpg')) {
|
47
|
+
covers.push({
|
48
|
+
path: cat.slug + '/cover.jpg',
|
49
|
+
data: function () {
|
50
|
+
return fs.createReadStream(cover + '/cover.jpg');
|
51
|
+
}
|
52
|
+
});
|
53
|
+
const topcat = getTopcat(cat);
|
54
|
+
if (topcat._id !== cat._id) {
|
55
|
+
cat.top = topcat;
|
56
|
+
}
|
57
|
+
const child = categories.find({ parent: cat._id });
|
58
|
+
let pl = 6;
|
59
|
+
if (child.length !== 0) {
|
60
|
+
cat.child = child.length;
|
61
|
+
cat.subs = child.sort({ name: 1 }).limit(6).toArray();
|
62
|
+
pl = Math.max(0, pl - child.length);
|
63
|
+
if (pl > 0) {
|
64
|
+
cat.subs.push(...cat.posts.sort({ title: 1 })
|
65
|
+
.filter(function (item, i) { return item.categories.last()._id === cat._id; })
|
66
|
+
.limit(pl).toArray());
|
67
|
+
}
|
68
|
+
}
|
69
|
+
else {
|
70
|
+
cat.subs = cat.posts.sort({ title: 1 }).limit(6).toArray();
|
71
|
+
}
|
72
|
+
catlist.push(cat);
|
73
|
+
}
|
74
|
+
});
|
75
|
+
}
|
76
|
+
if (posts.length > 0) {
|
77
|
+
pages = pagination(path, posts, {
|
78
|
+
perPage: config.index_generator.per_page,
|
79
|
+
layout: ['index', 'archive'],
|
80
|
+
format: paginationDir + '/%d/',
|
81
|
+
data: {
|
82
|
+
__index: true,
|
83
|
+
catlist,
|
84
|
+
sticky
|
85
|
+
}
|
86
|
+
});
|
87
|
+
}
|
88
|
+
else {
|
89
|
+
pages = [{
|
90
|
+
path,
|
91
|
+
layout: ['index', 'archive'],
|
92
|
+
data: {
|
93
|
+
__index: true,
|
94
|
+
catlist,
|
95
|
+
sticky
|
96
|
+
}
|
97
|
+
}];
|
98
|
+
}
|
99
|
+
return [...covers, ...pages];
|
100
|
+
});
|
@@ -1,19 +1,16 @@
|
|
1
|
-
|
2
|
-
'use strict'
|
3
|
-
|
1
|
+
'use strict';
|
4
2
|
hexo.extend.generator.register('pages', function (locals) {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
})
|
3
|
+
const config = hexo.config;
|
4
|
+
return [
|
5
|
+
{
|
6
|
+
path: config.category_dir + '/index.html',
|
7
|
+
data: { type: 'categories' },
|
8
|
+
layout: ['page']
|
9
|
+
},
|
10
|
+
{
|
11
|
+
path: config.tag_dir + '/index.html',
|
12
|
+
data: { type: 'tags' },
|
13
|
+
layout: ['page']
|
14
|
+
}
|
15
|
+
];
|
16
|
+
});
|
@@ -1,95 +1,91 @@
|
|
1
|
-
|
2
|
-
const fs = require('hexo-fs')
|
3
|
-
|
1
|
+
const fs = require('hexo-fs');
|
4
2
|
hexo.extend.generator.register('script', function (locals) {
|
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
|
-
|
3
|
+
const log = hexo.log || console.log;
|
4
|
+
const config = hexo.config;
|
5
|
+
const theme = hexo.theme.config;
|
6
|
+
const env = require('../../package.json');
|
7
|
+
const siteConfig = {
|
8
|
+
version: env.version,
|
9
|
+
hostname: config.url,
|
10
|
+
root: config.root,
|
11
|
+
statics: theme.statics,
|
12
|
+
favicon: {
|
13
|
+
normal: theme.assets + '/favicon.ico',
|
14
|
+
hidden: theme.assets + '/failure.ico'
|
15
|
+
},
|
16
|
+
darkmode: theme.darkmode,
|
17
|
+
auto_dark: theme.auto_dark,
|
18
|
+
auto_scroll: theme.auto_scroll,
|
19
|
+
js: {
|
20
|
+
chart: theme.vendors.js.chart,
|
21
|
+
copy_tex: theme.vendors.js.copy_tex,
|
22
|
+
fancybox: theme.vendors.js.fancybox
|
23
|
+
},
|
24
|
+
css: {
|
25
|
+
valine: theme.css + '/comment.css',
|
26
|
+
katex: theme.vendors.css.katex,
|
27
|
+
mermaid: theme.css + '/mermaid.css',
|
28
|
+
fancybox: theme.vendors.css.fancybox
|
29
|
+
},
|
30
|
+
loader: theme.loader,
|
31
|
+
search: null,
|
32
|
+
valine: theme.valine,
|
33
|
+
outime: {
|
34
|
+
enable: theme.outime.enable,
|
35
|
+
days: theme.outime.days
|
36
|
+
},
|
37
|
+
quicklink: {
|
38
|
+
timeout: theme.quicklink.timeout,
|
39
|
+
priority: theme.quicklink.priority
|
40
|
+
},
|
41
|
+
playerAPI: theme.playerAPI,
|
42
|
+
disableVL: theme.disableVL,
|
43
|
+
audio: undefined,
|
44
|
+
fireworks: undefined
|
45
|
+
};
|
46
|
+
if (config?.algolia) {
|
47
|
+
siteConfig.search = {
|
48
|
+
appID: config.algolia.appId,
|
49
|
+
apiKey: config.algolia.apiKey,
|
50
|
+
indexName: config.algolia.indexName,
|
51
|
+
hits: theme.search.hits
|
52
|
+
};
|
55
53
|
}
|
56
|
-
|
57
|
-
|
58
|
-
if (theme?.audio) {
|
59
|
-
siteConfig.audio = theme.audio
|
60
|
-
}
|
61
|
-
|
62
|
-
let text = '';
|
63
|
-
|
64
|
-
['library', 'global', 'page', 'vue', 'components'].forEach(function (item) {
|
65
|
-
if (fs.existsSync(`themes/shokaX/source/js/_app/${item}.js`)) {
|
66
|
-
text += fs.readFileSync(`themes/shokaX/source/js/_app/${item}.js`).toString()
|
67
|
-
} else {
|
68
|
-
text += fs.readFileSync(`node_modules/hexo-theme-shokax/source/js/_app/${item}.js`).toString()
|
54
|
+
if (theme?.audio) {
|
55
|
+
siteConfig.audio = theme.audio;
|
69
56
|
}
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
57
|
+
let text = '';
|
58
|
+
['library', 'global', 'page', 'vue', 'components'].forEach(function (item) {
|
59
|
+
if (fs.existsSync(`themes/shokaX/source/js/_app/${item}.js`)) {
|
60
|
+
text += fs.readFileSync(`themes/shokaX/source/js/_app/${item}.js`).toString();
|
61
|
+
}
|
62
|
+
else {
|
63
|
+
text += fs.readFileSync(`node_modules/hexo-theme-shokax/source/js/_app/${item}.js`).toString();
|
64
|
+
}
|
65
|
+
});
|
66
|
+
if (!theme.experiments?.noPlayer) {
|
67
|
+
if (fs.existsSync('themes/shokaX/source/js/_app/player.js')) {
|
68
|
+
text += fs.readFileSync('themes/shokaX/source/js/_app/player.js').toString();
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
text += fs.readFileSync('node_modules/hexo-theme-shokax/source/js/_app/player.js').toString();
|
72
|
+
}
|
76
73
|
}
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
74
|
+
if (theme.fireworks && theme.fireworks.enable) {
|
75
|
+
if (fs.existsSync('themes/shokaX/source/js/_app/fireworks.js')) {
|
76
|
+
text += fs.readFileSync('themes/shokaX/source/js/_app/fireworks.js').toString();
|
77
|
+
}
|
78
|
+
else {
|
79
|
+
text += fs.readFileSync('node_modules/hexo-theme-shokax/source/js/_app/fireworks.js').toString();
|
80
|
+
}
|
81
|
+
siteConfig.fireworks = theme.fireworks.color || ['rgba(255,182,185,.9)', 'rgba(250,227,217,.9)', 'rgba(187,222,214,.9)', 'rgba(138,198,209,.9)'];
|
83
82
|
}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
}
|
94
|
-
}
|
95
|
-
})
|
83
|
+
text = 'const CONFIG = ' + JSON.stringify(siteConfig) + ';' + text;
|
84
|
+
const result = hexo.render.renderSync({ text, engine: 'js' });
|
85
|
+
return {
|
86
|
+
path: theme.js + '/app.js',
|
87
|
+
data: function () {
|
88
|
+
return result;
|
89
|
+
}
|
90
|
+
};
|
91
|
+
});
|