hexo-theme-shokax 0.4.11 → 0.4.13
Sign up to get free protection for your applications and to get access to all the features.
- package/_config.yml +0 -1
- package/package.json +15 -14
- package/scripts/filters/locals.js +41 -48
- package/scripts/filters/post.js +2 -4
- package/scripts/generaters/archive.js +121 -125
- package/scripts/generaters/config.js +61 -49
- package/scripts/generaters/images.js +17 -20
- package/scripts/generaters/index.js +111 -100
- package/scripts/generaters/pages.js +14 -14
- package/scripts/generaters/script.js +164 -153
- package/scripts/helpers/asset.js +68 -59
- package/scripts/helpers/engine.js +145 -159
- package/scripts/helpers/list_categories.js +68 -73
- package/scripts/helpers/summary_ai.js +100 -94
- package/scripts/helpers/symbols_count_time.js +43 -51
- package/scripts/libtypes.d.js +15 -0
- package/scripts/plugin/check.js +26 -27
- package/scripts/plugin/index.js +64 -73
- package/scripts/plugin/lib/injects-point.js +40 -19
- package/scripts/plugin/lib/injects.js +89 -73
- package/scripts/tags/links.js +51 -34
- package/scripts/tags/media.js +33 -16
- package/scripts/utils.js +40 -18
- package/source/js/_app/components/sidebar.ts +3 -3
- package/source/js/_app/player.ts +1 -1
- package/toolbox/compiler.mjs +30 -24
package/_config.yml
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hexo-theme-shokax",
|
3
|
-
"version": "0.4.
|
3
|
+
"version": "0.4.13",
|
4
4
|
"description": "a hexo theme based on shoka",
|
5
5
|
"main": "index.js",
|
6
6
|
"repository": "https://github.com/theme-shoka-x/hexo-theme-shokaX",
|
@@ -16,20 +16,21 @@
|
|
16
16
|
"@types/jquery": "^3.5.30",
|
17
17
|
"@types/js-yaml": "^4.0.9",
|
18
18
|
"@types/katex": "^0.16.7",
|
19
|
-
"@types/node": "^
|
19
|
+
"@types/node": "^22.5.5",
|
20
20
|
"@types/quicklink": "^2.3.4",
|
21
|
-
"@typescript-eslint/eslint-plugin": "^
|
22
|
-
"@typescript-eslint/parser": "^
|
23
|
-
"eslint": "^9.
|
21
|
+
"@typescript-eslint/eslint-plugin": "^8.6.0",
|
22
|
+
"@typescript-eslint/parser": "^8.6.0",
|
23
|
+
"eslint": "^9.11.0",
|
24
24
|
"eslint-config-standard": "~17",
|
25
|
-
"eslint-plugin-vue": "^9.
|
26
|
-
"
|
25
|
+
"eslint-plugin-vue": "^9.28.0",
|
26
|
+
"glob": "^11.0.0",
|
27
|
+
"typescript": "^5.6.2"
|
27
28
|
},
|
28
29
|
"dependencies": {
|
29
|
-
"@algolia/client-search": "^
|
30
|
-
"@waline/client": "^3.3.
|
31
|
-
"algoliasearch": "
|
32
|
-
"esbuild": "^0.23.
|
30
|
+
"@algolia/client-search": "^5.5.3",
|
31
|
+
"@waline/client": "^3.3.2",
|
32
|
+
"algoliasearch": "5.5.3",
|
33
|
+
"esbuild": "^0.23.1",
|
33
34
|
"hexo": "^7.3.0",
|
34
35
|
"hexo-algoliasearch": "^2.0.1",
|
35
36
|
"hexo-feed": "^1.1.2",
|
@@ -37,16 +38,16 @@
|
|
37
38
|
"hexo-pagination": "^4.0.0",
|
38
39
|
"hexo-renderer-pug": "^3.0.0",
|
39
40
|
"hexo-util": "^3.3.0",
|
40
|
-
"instantsearch.js": "^4.
|
41
|
+
"instantsearch.js": "^4.74.1",
|
41
42
|
"js-yaml": "^4.1.0",
|
42
43
|
"katex": "^0.16.11",
|
43
44
|
"mouse-firework": "^0.0.6",
|
44
45
|
"quicklink": "^2.3.0",
|
45
46
|
"theme-shokax-anime": "^0.0.7",
|
46
47
|
"theme-shokax-pjax": "^0.0.3",
|
47
|
-
"twikoo": "^1.6.
|
48
|
+
"twikoo": "^1.6.39",
|
48
49
|
"unlazy": "^0.11.3",
|
49
|
-
"vue": "^3.
|
50
|
+
"vue": "^3.5.7"
|
50
51
|
},
|
51
52
|
"engines": {
|
52
53
|
"node": ">=18.0.0"
|
@@ -1,52 +1,45 @@
|
|
1
|
-
// @ts-ignore
|
2
1
|
const fmtNum = (num) => {
|
3
|
-
|
2
|
+
return num < 10 ? "0" + num : num;
|
4
3
|
};
|
5
|
-
hexo.extend.filter.register(
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
return data;
|
13
|
-
}
|
14
|
-
};
|
15
|
-
// Language & Config
|
16
|
-
// 根据主题配置的 Creative Commons 许可证生成链接
|
17
|
-
locals.alternate = theme.alternate;
|
18
|
-
locals.title = pangu.spacing(__('title') !== 'title' ? __('title') : config.title);
|
19
|
-
locals.subtitle = pangu.spacing(__('subtitle') !== 'subtitle' ? __('subtitle') : config.subtitle);
|
20
|
-
locals.author = __('author') !== 'author' ? __('author') : config.author;
|
21
|
-
locals.description = pangu.spacing(__('description') !== 'description' ? __('description') : config.description);
|
22
|
-
locals.languages = [...i18n.languages];
|
23
|
-
locals.languages.splice(locals.languages.indexOf('default'), 1);
|
24
|
-
locals.page.lang = locals.page.lang || locals.page.language;
|
25
|
-
locals.hostname = new URL(config.url).hostname || config.url;
|
26
|
-
// Creative Commons
|
27
|
-
// 根据主题配置的 Creative Commons 许可证生成链接
|
28
|
-
if (theme.creative_commons.license === 'zero') {
|
29
|
-
locals.ccURL = 'https://creativecommons.org/' + 'publicdomain/zero/1.0/' + (theme.creative_commons.language || '');
|
30
|
-
}
|
31
|
-
else {
|
32
|
-
locals.ccURL = 'https://creativecommons.org/' + 'licenses/' + theme.creative_commons.license + '/4.0/' + (theme.creative_commons.language || '');
|
33
|
-
}
|
34
|
-
if (locals.page.title) {
|
35
|
-
locals.page.title = pangu.spacing(locals.page.title);
|
36
|
-
}
|
37
|
-
locals.page.lastcat = '';
|
38
|
-
if (locals.page.categories) {
|
39
|
-
locals.page.categories.map((cat) => {
|
40
|
-
if (cat.name) {
|
41
|
-
cat.name = locals.page.lastcat = pangu.spacing(cat.name);
|
42
|
-
}
|
43
|
-
return cat;
|
44
|
-
});
|
45
|
-
}
|
46
|
-
if (locals.page.category) {
|
47
|
-
locals.page.title = pangu.spacing(locals.page.category);
|
48
|
-
}
|
49
|
-
if (locals.page.month) {
|
50
|
-
locals.page.month = fmtNum(locals.page.month);
|
4
|
+
hexo.extend.filter.register("template_locals", (locals) => {
|
5
|
+
const { config } = hexo;
|
6
|
+
const { __, theme } = locals;
|
7
|
+
const { i18n } = hexo.theme;
|
8
|
+
const pangu = {
|
9
|
+
spacing: (data) => {
|
10
|
+
return data;
|
51
11
|
}
|
12
|
+
};
|
13
|
+
locals.alternate = theme.alternate;
|
14
|
+
locals.title = pangu.spacing(__("title") !== "title" ? __("title") : config.title);
|
15
|
+
locals.subtitle = pangu.spacing(__("subtitle") !== "subtitle" ? __("subtitle") : config.subtitle);
|
16
|
+
locals.author = __("author") !== "author" ? __("author") : config.author;
|
17
|
+
locals.description = pangu.spacing(__("description") !== "description" ? __("description") : config.description);
|
18
|
+
locals.languages = [...i18n.languages];
|
19
|
+
locals.languages.splice(locals.languages.indexOf("default"), 1);
|
20
|
+
locals.page.lang = locals.page.lang || locals.page.language;
|
21
|
+
locals.hostname = new URL(config.url).hostname || config.url;
|
22
|
+
if (theme.creative_commons.license === "zero") {
|
23
|
+
locals.ccURL = "https://creativecommons.org/publicdomain/zero/1.0/" + (theme.creative_commons.language || "");
|
24
|
+
} else {
|
25
|
+
locals.ccURL = "https://creativecommons.org/licenses/" + theme.creative_commons.license + "/4.0/" + (theme.creative_commons.language || "");
|
26
|
+
}
|
27
|
+
if (locals.page.title) {
|
28
|
+
locals.page.title = pangu.spacing(locals.page.title);
|
29
|
+
}
|
30
|
+
locals.page.lastcat = "";
|
31
|
+
if (locals.page.categories) {
|
32
|
+
locals.page.categories.map((cat) => {
|
33
|
+
if (cat.name) {
|
34
|
+
cat.name = locals.page.lastcat = pangu.spacing(cat.name);
|
35
|
+
}
|
36
|
+
return cat;
|
37
|
+
});
|
38
|
+
}
|
39
|
+
if (locals.page.category) {
|
40
|
+
locals.page.title = pangu.spacing(locals.page.category);
|
41
|
+
}
|
42
|
+
if (locals.page.month) {
|
43
|
+
locals.page.month = fmtNum(locals.page.month);
|
44
|
+
}
|
52
45
|
});
|
package/scripts/filters/post.js
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
// 使用正则表达式将<img>标签的src属性替换为data-src属性
|
4
|
-
data.content = data.content.replace(/(<img[^>]*) src=/img, '$1 loading="lazy" data-src=');
|
1
|
+
hexo.extend.filter.register("after_post_render", (data) => {
|
2
|
+
data.content = data.content.replace(/(<img[^>]*) src=/img, '$1 loading="lazy" data-src=');
|
5
3
|
}, 0);
|
@@ -1,133 +1,129 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
var
|
4
|
-
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
10
|
+
for (let key of __getOwnPropNames(from))
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
13
|
+
}
|
14
|
+
return to;
|
5
15
|
};
|
6
|
-
|
7
|
-
//
|
8
|
-
|
9
|
-
//
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
+
mod
|
23
|
+
));
|
24
|
+
var import_hexo_pagination = __toESM(require("hexo-pagination"));
|
10
25
|
const fmtNum = (num) => {
|
11
|
-
|
26
|
+
return num < 10 ? "0" + num : num;
|
12
27
|
};
|
13
28
|
if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
29
|
+
let per_page;
|
30
|
+
if (hexo.config.archive === 1) {
|
31
|
+
per_page = 0;
|
32
|
+
} else if (typeof hexo.config.per_page === "undefined") {
|
33
|
+
per_page = 10;
|
34
|
+
} else {
|
35
|
+
per_page = hexo.config.per_page;
|
36
|
+
}
|
37
|
+
hexo.config.archive_generator = Object.assign({
|
38
|
+
per_page,
|
39
|
+
yearly: true,
|
40
|
+
monthly: true,
|
41
|
+
daily: false
|
42
|
+
}, hexo.config.archive_generator);
|
43
|
+
hexo.extend.generator.register("archive", function(locals) {
|
44
|
+
const config = hexo.config;
|
45
|
+
let archiveDir = config.archive_dir;
|
46
|
+
const paginationDir = config.pagination_dir || "page";
|
47
|
+
const allPosts = locals.posts.sort(config.archive_generator.order_by || "-date");
|
48
|
+
const perPage = config.archive_generator.per_page;
|
49
|
+
let result = [];
|
50
|
+
if (!allPosts.length) return;
|
51
|
+
if (archiveDir[archiveDir.length - 1] !== "/") archiveDir += "/";
|
52
|
+
function generate(path, posts2, options) {
|
53
|
+
options = options || {};
|
54
|
+
options.archive = true;
|
55
|
+
result = result.concat((0, import_hexo_pagination.default)(path, posts2, {
|
56
|
+
perPage: path === archiveDir ? 0 : perPage,
|
57
|
+
layout: ["archive", "index"],
|
58
|
+
format: paginationDir + "/%d/",
|
59
|
+
data: options
|
60
|
+
}));
|
18
61
|
}
|
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
|
-
format: paginationDir + '/%d/',
|
50
|
-
data: options
|
51
|
-
}));
|
52
|
-
}
|
53
|
-
generate(archiveDir, allPosts);
|
54
|
-
if (!config.archive_generator.yearly)
|
55
|
-
return result;
|
56
|
-
const posts = {};
|
57
|
-
// 按日期对文章进行分类
|
58
|
-
allPosts.forEach(post => {
|
59
|
-
const date = post.date;
|
60
|
-
const year = date.year();
|
61
|
-
const month = date.month() + 1; // month is started from 0
|
62
|
-
if (!Object.prototype.hasOwnProperty.call(posts, year)) {
|
63
|
-
// 13个数组. 第一个数组是给这一年的文章准备的
|
64
|
-
// 其他则是各个月份的文章
|
65
|
-
posts[year] = [
|
66
|
-
[],
|
67
|
-
[],
|
68
|
-
[],
|
69
|
-
[],
|
70
|
-
[],
|
71
|
-
[],
|
72
|
-
[],
|
73
|
-
[],
|
74
|
-
[],
|
75
|
-
[],
|
76
|
-
[],
|
77
|
-
[],
|
78
|
-
[]
|
79
|
-
];
|
80
|
-
}
|
81
|
-
posts[year][0].push(post);
|
82
|
-
posts[year][month].push(post);
|
83
|
-
// Daily
|
84
|
-
if (config.archive_generator.daily) {
|
85
|
-
const day = date.date();
|
86
|
-
if (!Object.prototype.hasOwnProperty.call(posts[year][month], 'day')) {
|
87
|
-
posts[year][month].day = {};
|
88
|
-
}
|
89
|
-
(posts[year][month].day[day] || (posts[year][month].day[day] = [])).push(post);
|
90
|
-
}
|
91
|
-
});
|
92
|
-
const Query = this.model('Post').Query;
|
93
|
-
const years = Object.keys(posts);
|
94
|
-
let year, data, month, monthData, url;
|
95
|
-
// Yearly
|
96
|
-
for (let i = 0, len = years.length; i < len; i++) {
|
97
|
-
year = +years[i];
|
98
|
-
data = posts[year];
|
99
|
-
url = archiveDir + year + '/';
|
100
|
-
if (!data[0].length)
|
101
|
-
continue;
|
102
|
-
generate(url, new Query(data[0]), { year });
|
103
|
-
if (!config.archive_generator.monthly && !config.archive_generator.daily)
|
104
|
-
continue;
|
105
|
-
// Monthly
|
106
|
-
for (month = 1; month <= 12; month++) {
|
107
|
-
monthData = data[month];
|
108
|
-
if (!monthData.length)
|
109
|
-
continue;
|
110
|
-
if (config.archive_generator.monthly) {
|
111
|
-
generate(url + fmtNum(month) + '/', new Query(monthData), {
|
112
|
-
year,
|
113
|
-
month
|
114
|
-
});
|
115
|
-
}
|
116
|
-
if (!config.archive_generator.daily)
|
117
|
-
continue;
|
118
|
-
// Daily
|
119
|
-
for (let day = 1; day <= 31; day++) {
|
120
|
-
const dayData = monthData.day[day];
|
121
|
-
if (!dayData || !dayData.length)
|
122
|
-
continue;
|
123
|
-
generate(url + fmtNum(month) + '/' + fmtNum(day) + '/', new Query(dayData), {
|
124
|
-
year,
|
125
|
-
month,
|
126
|
-
day
|
127
|
-
});
|
128
|
-
}
|
129
|
-
}
|
62
|
+
generate(archiveDir, allPosts);
|
63
|
+
if (!config.archive_generator.yearly) return result;
|
64
|
+
const posts = {};
|
65
|
+
allPosts.forEach((post) => {
|
66
|
+
const date = post.date;
|
67
|
+
const year2 = date.year();
|
68
|
+
const month2 = date.month() + 1;
|
69
|
+
if (!Object.prototype.hasOwnProperty.call(posts, year2)) {
|
70
|
+
posts[year2] = [
|
71
|
+
[],
|
72
|
+
[],
|
73
|
+
[],
|
74
|
+
[],
|
75
|
+
[],
|
76
|
+
[],
|
77
|
+
[],
|
78
|
+
[],
|
79
|
+
[],
|
80
|
+
[],
|
81
|
+
[],
|
82
|
+
[],
|
83
|
+
[]
|
84
|
+
];
|
85
|
+
}
|
86
|
+
posts[year2][0].push(post);
|
87
|
+
posts[year2][month2].push(post);
|
88
|
+
if (config.archive_generator.daily) {
|
89
|
+
const day = date.date();
|
90
|
+
if (!Object.prototype.hasOwnProperty.call(posts[year2][month2], "day")) {
|
91
|
+
posts[year2][month2].day = {};
|
130
92
|
}
|
131
|
-
|
93
|
+
(posts[year2][month2].day[day] || (posts[year2][month2].day[day] = [])).push(post);
|
94
|
+
}
|
132
95
|
});
|
96
|
+
const Query = this.model("Post").Query;
|
97
|
+
const years = Object.keys(posts);
|
98
|
+
let year, data, month, monthData, url;
|
99
|
+
for (let i = 0, len = years.length; i < len; i++) {
|
100
|
+
year = +years[i];
|
101
|
+
data = posts[year];
|
102
|
+
url = archiveDir + year + "/";
|
103
|
+
if (!data[0].length) continue;
|
104
|
+
generate(url, new Query(data[0]), { year });
|
105
|
+
if (!config.archive_generator.monthly && !config.archive_generator.daily) continue;
|
106
|
+
for (month = 1; month <= 12; month++) {
|
107
|
+
monthData = data[month];
|
108
|
+
if (!monthData.length) continue;
|
109
|
+
if (config.archive_generator.monthly) {
|
110
|
+
generate(url + fmtNum(month) + "/", new Query(monthData), {
|
111
|
+
year,
|
112
|
+
month
|
113
|
+
});
|
114
|
+
}
|
115
|
+
if (!config.archive_generator.daily) continue;
|
116
|
+
for (let day = 1; day <= 31; day++) {
|
117
|
+
const dayData = monthData.day[day];
|
118
|
+
if (!dayData || !dayData.length) continue;
|
119
|
+
generate(url + fmtNum(month) + "/" + fmtNum(day) + "/", new Query(dayData), {
|
120
|
+
year,
|
121
|
+
month,
|
122
|
+
day
|
123
|
+
});
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
return result;
|
128
|
+
});
|
133
129
|
}
|
@@ -1,51 +1,63 @@
|
|
1
|
-
|
2
|
-
var
|
3
|
-
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
10
|
+
for (let key of __getOwnPropNames(from))
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
13
|
+
}
|
14
|
+
return to;
|
4
15
|
};
|
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
|
-
if (
|
37
|
-
|
38
|
-
}
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
+
mod
|
23
|
+
));
|
24
|
+
var import_hexo_util = require("hexo-util");
|
25
|
+
var import_node_fs = __toESM(require("node:fs"));
|
26
|
+
var import_path = __toESM(require("path"));
|
27
|
+
var import_js_yaml = __toESM(require("js-yaml"));
|
28
|
+
hexo.extend.filter.register("before_generate", () => {
|
29
|
+
if (hexo.config.theme_config) {
|
30
|
+
hexo.theme.config = (0, import_hexo_util.deepMerge)(hexo.theme.config, hexo.config.theme_config);
|
31
|
+
}
|
32
|
+
const data = hexo.locals.get("data");
|
33
|
+
if (data.languages) {
|
34
|
+
const { i18n } = hexo.theme;
|
35
|
+
const mergeLang = (lang) => {
|
36
|
+
if (data.languages[lang]) {
|
37
|
+
i18n.set(lang, (0, import_hexo_util.deepMerge)(i18n.get([lang]), data.languages[lang]));
|
38
|
+
}
|
39
|
+
};
|
40
|
+
for (const lang of ["en", "ja", "zh-CN", "zh-HK", "zh-TW"]) {
|
41
|
+
mergeLang(lang);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
hexo.theme.config.style = {};
|
45
|
+
for (const style of ["iconfont", "colors", "custom"]) {
|
46
|
+
const custom_file = "source/_data/" + style + ".styl";
|
47
|
+
if (import_node_fs.default.existsSync(custom_file)) {
|
48
|
+
hexo.theme.config.style[style] = import_path.default.resolve(hexo.base_dir, custom_file);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
if (data.images && data.images.length > 0) {
|
52
|
+
hexo.theme.config.image_list = data.images;
|
53
|
+
} else {
|
54
|
+
hexo.theme.config.image_list = import_js_yaml.default.load(import_node_fs.default.readFileSync(import_path.default.join(__dirname, "../../_images.yml"), { encoding: "utf-8" }));
|
55
|
+
}
|
56
|
+
if (data.images_index && data.images_index.length > 0) {
|
57
|
+
hexo.theme.config.index_images = data.images_index;
|
58
|
+
} else if (import_node_fs.default.existsSync(import_path.default.join(__dirname, "../../_images_index.yml"))) {
|
59
|
+
hexo.theme.config.index_images = import_js_yaml.default.load(import_node_fs.default.readFileSync(import_path.default.join(__dirname, "../../_images_index.yml"), { encoding: "utf-8" }));
|
60
|
+
} else {
|
61
|
+
hexo.theme.config.index_images = data.index_images || [];
|
62
|
+
}
|
51
63
|
});
|
@@ -1,23 +1,20 @@
|
|
1
|
-
|
2
|
-
'use strict';
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
// @ts-ignore
|
1
|
+
"use strict";
|
5
2
|
const fs = require("hexo-fs");
|
6
|
-
hexo.extend.generator.register(
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
});
|
3
|
+
hexo.extend.generator.register("images", function(locals) {
|
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
|
+
}
|
21
17
|
});
|
22
|
-
|
18
|
+
});
|
19
|
+
return result;
|
23
20
|
});
|