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,42 +1,39 @@
|
|
1
|
-
'use strict'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
const
|
7
|
-
const
|
8
|
-
|
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_util_1 = __importDefault(require("hexo-util"));
|
7
|
+
const hexo_fs_1 = __importDefault(require("hexo-fs"));
|
8
|
+
const path_1 = __importDefault(require("path"));
|
9
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
9
10
|
hexo.extend.filter.register('before_generate', () => {
|
10
|
-
|
11
|
-
|
12
|
-
}
|
13
|
-
|
14
|
-
const data = hexo.locals.get('data')
|
15
|
-
|
16
|
-
if (data.languages) {
|
17
|
-
const { i18n } = hexo.theme
|
18
|
-
|
19
|
-
const mergeLang = lang => {
|
20
|
-
if (data.languages[lang]) { i18n.set(lang, merge(i18n.get([lang]), data.languages[lang])) }
|
11
|
+
if (hexo.config.theme_config) {
|
12
|
+
hexo.theme.config = hexo_util_1.default.deepMerge(hexo.theme.config, hexo.config.theme_config);
|
21
13
|
}
|
22
|
-
|
23
|
-
|
24
|
-
|
14
|
+
const data = hexo.locals.get('data');
|
15
|
+
if (data.languages) {
|
16
|
+
const { i18n } = hexo.theme;
|
17
|
+
const mergeLang = lang => {
|
18
|
+
if (data.languages[lang]) {
|
19
|
+
i18n.set(lang, hexo_util_1.default.deepMerge(i18n.get([lang]), data.languages[lang]));
|
20
|
+
}
|
21
|
+
};
|
22
|
+
for (const lang of ['en', 'ja', 'zh-CN', 'zh-HK', 'zh-TW']) {
|
23
|
+
mergeLang(lang);
|
24
|
+
}
|
25
25
|
}
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
if (fs.existsSync(custom_file)) {
|
33
|
-
hexo.theme.config.style[style] = path.resolve(hexo.base_dir, custom_file)
|
26
|
+
hexo.theme.config.style = {};
|
27
|
+
for (const style of ['iconfont', 'colors', 'custom']) {
|
28
|
+
const custom_file = 'source/_data/' + style + '.styl';
|
29
|
+
if (hexo_fs_1.default.existsSync(custom_file)) {
|
30
|
+
hexo.theme.config.style[style] = path_1.default.resolve(hexo.base_dir, custom_file);
|
31
|
+
}
|
34
32
|
}
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
})
|
33
|
+
if (data.images && data.images.length >= 6) {
|
34
|
+
hexo.theme.config.image_list = data.images;
|
35
|
+
}
|
36
|
+
else {
|
37
|
+
hexo.theme.config.image_list = js_yaml_1.default.load(hexo_fs_1.default.readFileSync(path_1.default.join(__dirname, '../../_images.yml')));
|
38
|
+
}
|
39
|
+
});
|
@@ -1,25 +1,24 @@
|
|
1
|
-
|
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
|
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
|
-
})
|
8
|
+
const theme = hexo.theme.config;
|
9
|
+
const dir = 'source/_data/' + theme.assets + '/';
|
10
|
+
if (!hexo_fs_1.default.existsSync(dir)) {
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
const result = [];
|
14
|
+
const files = hexo_fs_1.default.listDirSync(dir);
|
15
|
+
files.forEach((file) => {
|
16
|
+
result.push({
|
17
|
+
path: theme.assets + '/' + file,
|
18
|
+
data: function () {
|
19
|
+
return hexo_fs_1.default.createReadStream(dir + file);
|
20
|
+
}
|
21
|
+
});
|
22
|
+
});
|
23
|
+
return result;
|
24
|
+
});
|
@@ -1,109 +1,104 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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"));
|
7
|
+
const hexo_pagination_1 = __importDefault(require("hexo-pagination"));
|
7
8
|
hexo.config.index_generator = Object.assign({
|
8
|
-
|
9
|
-
|
10
|
-
}, hexo.config.index_generator)
|
11
|
-
|
9
|
+
per_page: typeof hexo.config.per_page === 'undefined' ? 10 : hexo.config.per_page,
|
10
|
+
order_by: '-date'
|
11
|
+
}, hexo.config.index_generator);
|
12
12
|
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
|
13
|
+
const covers = [];
|
14
|
+
const catlist = [];
|
15
|
+
let pages;
|
16
|
+
const config = hexo.config;
|
17
|
+
const sticky = locals.posts.find({ sticky: true }).sort(config.index_generator.order_by);
|
18
|
+
const posts = locals.posts.find({ sticky: { $exists: false } }).sort(config.index_generator.order_by);
|
19
|
+
const paginationDir = config.pagination_dir || 'page';
|
20
|
+
const path = config.index_generator.path || '';
|
21
|
+
const categories = locals.categories;
|
22
|
+
const getTopcat = function (cat) {
|
23
|
+
if (cat.parent) {
|
24
|
+
const pCat = categories.findOne({ _id: cat.parent });
|
25
|
+
return getTopcat(pCat);
|
61
26
|
}
|
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()
|
27
|
+
else {
|
28
|
+
return cat;
|
78
29
|
}
|
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
|
-
}
|
30
|
+
};
|
31
|
+
if (categories && categories.length) {
|
32
|
+
categories.forEach((cat) => {
|
33
|
+
const cover = `source/_posts/${cat.slug}`;
|
34
|
+
if (hexo_fs_1.default.existsSync(cover + '/cover.avif')) {
|
35
|
+
covers.push({
|
36
|
+
path: cat.slug + '/cover.avif',
|
37
|
+
data: function () {
|
38
|
+
return hexo_fs_1.default.createReadStream(cover + '/cover.avif');
|
39
|
+
}
|
40
|
+
});
|
41
|
+
}
|
42
|
+
else if (hexo_fs_1.default.existsSync(cover + '/cover.webp')) {
|
43
|
+
covers.push({
|
44
|
+
path: cat.slug + '/cover.webp',
|
45
|
+
data: function () {
|
46
|
+
return hexo_fs_1.default.createReadStream(cover + '/cover.webp');
|
47
|
+
}
|
48
|
+
});
|
49
|
+
}
|
50
|
+
else if (hexo_fs_1.default.existsSync(cover + '/cover.jpg')) {
|
51
|
+
covers.push({
|
52
|
+
path: cat.slug + '/cover.jpg',
|
53
|
+
data: function () {
|
54
|
+
return hexo_fs_1.default.createReadStream(cover + '/cover.jpg');
|
55
|
+
}
|
56
|
+
});
|
57
|
+
const topcat = getTopcat(cat);
|
58
|
+
if (topcat._id !== cat._id) {
|
59
|
+
cat.top = topcat;
|
60
|
+
}
|
61
|
+
const child = categories.find({ parent: cat._id });
|
62
|
+
let pl = 6;
|
63
|
+
if (child.length !== 0) {
|
64
|
+
cat.child = child.length;
|
65
|
+
cat.subs = child.sort({ name: 1 }).limit(6).toArray();
|
66
|
+
pl = Math.max(0, pl - child.length);
|
67
|
+
if (pl > 0) {
|
68
|
+
cat.subs.push(...cat.posts.sort({ title: 1 })
|
69
|
+
.filter(function (item, i) { return item.categories.last()._id === cat._id; })
|
70
|
+
.limit(pl).toArray());
|
71
|
+
}
|
72
|
+
}
|
73
|
+
else {
|
74
|
+
cat.subs = cat.posts.sort({ title: 1 }).limit(6).toArray();
|
75
|
+
}
|
76
|
+
catlist.push(cat);
|
77
|
+
}
|
78
|
+
});
|
79
|
+
}
|
80
|
+
if (posts.length > 0) {
|
81
|
+
pages = (0, hexo_pagination_1.default)(path, posts, {
|
82
|
+
perPage: config.index_generator.per_page,
|
83
|
+
layout: ['index', 'archive'],
|
84
|
+
format: paginationDir + '/%d/',
|
85
|
+
data: {
|
86
|
+
__index: true,
|
87
|
+
catlist,
|
88
|
+
sticky
|
89
|
+
}
|
90
|
+
});
|
91
|
+
}
|
92
|
+
else {
|
93
|
+
pages = [{
|
94
|
+
path,
|
95
|
+
layout: ['index', 'archive'],
|
96
|
+
data: {
|
97
|
+
__index: true,
|
98
|
+
catlist,
|
99
|
+
sticky
|
100
|
+
}
|
101
|
+
}];
|
102
|
+
}
|
103
|
+
return [...covers, ...pages];
|
104
|
+
});
|
@@ -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,96 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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 package_json_1 = __importDefault(require("../../package.json"));
|
7
|
+
const hexo_fs_1 = __importDefault(require("hexo-fs"));
|
4
8
|
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
|
-
hits: theme.search.hits
|
9
|
+
const log = hexo.log || console.log;
|
10
|
+
const config = hexo.config;
|
11
|
+
const theme = hexo.theme.config;
|
12
|
+
const siteConfig = {
|
13
|
+
version: package_json_1.default.version,
|
14
|
+
hostname: config.url,
|
15
|
+
root: config.root,
|
16
|
+
statics: theme.statics,
|
17
|
+
favicon: {
|
18
|
+
normal: theme.assets + '/favicon.ico',
|
19
|
+
hidden: theme.assets + '/failure.ico'
|
20
|
+
},
|
21
|
+
darkmode: theme.darkmode,
|
22
|
+
auto_dark: theme.auto_dark,
|
23
|
+
auto_scroll: theme.auto_scroll,
|
24
|
+
js: {
|
25
|
+
chart: theme.vendors.js.chart,
|
26
|
+
copy_tex: theme.vendors.js.copy_tex,
|
27
|
+
fancybox: theme.vendors.js.fancybox
|
28
|
+
},
|
29
|
+
css: {
|
30
|
+
valine: theme.css + '/comment.css',
|
31
|
+
katex: theme.vendors.css.katex,
|
32
|
+
mermaid: theme.css + '/mermaid.css',
|
33
|
+
fancybox: theme.vendors.css.fancybox
|
34
|
+
},
|
35
|
+
loader: theme.loader,
|
36
|
+
search: null,
|
37
|
+
valine: theme.valine,
|
38
|
+
outime: {
|
39
|
+
enable: theme.outime.enable,
|
40
|
+
days: theme.outime.days
|
41
|
+
},
|
42
|
+
quicklink: {
|
43
|
+
timeout: theme.quicklink.timeout,
|
44
|
+
priority: theme.quicklink.priority
|
45
|
+
},
|
46
|
+
playerAPI: theme.playerAPI,
|
47
|
+
disableVL: theme.disableVL,
|
48
|
+
audio: undefined,
|
49
|
+
fireworks: undefined
|
50
|
+
};
|
51
|
+
if (config?.algolia) {
|
52
|
+
siteConfig.search = {
|
53
|
+
appID: config.algolia.appId,
|
54
|
+
apiKey: config.algolia.apiKey,
|
55
|
+
indexName: config.algolia.indexName,
|
56
|
+
hits: theme.search.hits
|
57
|
+
};
|
55
58
|
}
|
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()
|
59
|
+
if (theme?.audio) {
|
60
|
+
siteConfig.audio = theme.audio;
|
69
61
|
}
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
62
|
+
let text = '';
|
63
|
+
['library', 'global', 'page', 'vue', 'components'].forEach(function (item) {
|
64
|
+
if (hexo_fs_1.default.existsSync(`themes/shokaX/source/js/_app/${item}.js`)) {
|
65
|
+
text += hexo_fs_1.default.readFileSync(`themes/shokaX/source/js/_app/${item}.js`).toString();
|
66
|
+
}
|
67
|
+
else {
|
68
|
+
text += hexo_fs_1.default.readFileSync(`node_modules/hexo-theme-shokax/source/js/_app/${item}.js`).toString();
|
69
|
+
}
|
70
|
+
});
|
71
|
+
if (!theme.experiments?.noPlayer) {
|
72
|
+
if (hexo_fs_1.default.existsSync('themes/shokaX/source/js/_app/player.js')) {
|
73
|
+
text += hexo_fs_1.default.readFileSync('themes/shokaX/source/js/_app/player.js').toString();
|
74
|
+
}
|
75
|
+
else {
|
76
|
+
text += hexo_fs_1.default.readFileSync('node_modules/hexo-theme-shokax/source/js/_app/player.js').toString();
|
77
|
+
}
|
76
78
|
}
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
if (theme.fireworks && theme.fireworks.enable) {
|
80
|
+
if (hexo_fs_1.default.existsSync('themes/shokaX/source/js/_app/fireworks.js')) {
|
81
|
+
text += hexo_fs_1.default.readFileSync('themes/shokaX/source/js/_app/fireworks.js').toString();
|
82
|
+
}
|
83
|
+
else {
|
84
|
+
text += hexo_fs_1.default.readFileSync('node_modules/hexo-theme-shokax/source/js/_app/fireworks.js').toString();
|
85
|
+
}
|
86
|
+
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
87
|
}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
}
|
94
|
-
}
|
95
|
-
})
|
88
|
+
text = 'const CONFIG = ' + JSON.stringify(siteConfig) + ';' + text;
|
89
|
+
const result = hexo.render.renderSync({ text, engine: 'js' });
|
90
|
+
return {
|
91
|
+
path: theme.js + '/app.js',
|
92
|
+
data: function () {
|
93
|
+
return result;
|
94
|
+
}
|
95
|
+
};
|
96
|
+
});
|