hexo-theme-shokax 0.4.12 → 0.4.13
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +2 -1
- 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/toolbox/compiler.mjs +30 -24
@@ -1,89 +1,105 @@
|
|
1
|
-
|
2
|
-
var
|
3
|
-
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __export = (target, all) => {
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
4
10
|
};
|
5
|
-
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
+
}
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25
|
+
mod
|
26
|
+
));
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
+
var injects_exports = {};
|
29
|
+
__export(injects_exports, {
|
30
|
+
default: () => injects_default
|
31
|
+
});
|
32
|
+
module.exports = __toCommonJS(injects_exports);
|
33
|
+
var import_node_fs = __toESM(require("node:fs"));
|
34
|
+
var import_node_path = __toESM(require("node:path"));
|
35
|
+
var import_injects_point = __toESM(require("./injects-point"));
|
6
36
|
/*!
|
7
37
|
inject.js in next-theme/hexo-theme-next by next-theme
|
8
38
|
under GNU AFFERO GENERAL PUBLIC LICENSE v3.0 OR LATER
|
9
39
|
https://github.com/next-theme/hexo-theme-next/blob/master/LICENSE.md
|
10
40
|
*/
|
11
|
-
const
|
12
|
-
const node_path_1 = __importDefault(require("node:path"));
|
13
|
-
const injects_point_1 = __importDefault(require("./injects-point"));
|
14
|
-
const defaultExtname = '.pug';
|
41
|
+
const defaultExtname = ".pug";
|
15
42
|
class StylusInject {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
43
|
+
files;
|
44
|
+
base_dir;
|
45
|
+
constructor(base_dir) {
|
46
|
+
this.base_dir = base_dir;
|
47
|
+
this.files = [];
|
48
|
+
}
|
49
|
+
push(file) {
|
50
|
+
this.files.push(import_node_path.default.resolve(this.base_dir, file));
|
51
|
+
}
|
25
52
|
}
|
26
|
-
// Defining view types
|
27
53
|
class ViewInject {
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
name += defaultExtname;
|
38
|
-
}
|
39
|
-
this.raws.push({ name, raw, args });
|
54
|
+
base_dir;
|
55
|
+
raws;
|
56
|
+
constructor(base_dir) {
|
57
|
+
this.base_dir = base_dir;
|
58
|
+
this.raws = [];
|
59
|
+
}
|
60
|
+
raw(name, raw, ...args) {
|
61
|
+
if (import_node_path.default.extname(name) === "") {
|
62
|
+
name += defaultExtname;
|
40
63
|
}
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
// Get absolute path base on hexo dir
|
47
|
-
this.raw(name, node_fs_1.default.readFileSync(node_path_1.default.resolve(this.base_dir, file), 'utf8'), ...args);
|
64
|
+
this.raws.push({ name, raw, args });
|
65
|
+
}
|
66
|
+
file(name, file, ...args) {
|
67
|
+
if (import_node_path.default.extname(name) === "") {
|
68
|
+
name += import_node_path.default.extname(file);
|
48
69
|
}
|
70
|
+
this.raw(name, import_node_fs.default.readFileSync(import_node_path.default.resolve(this.base_dir, file), "utf8"), ...args);
|
71
|
+
}
|
49
72
|
}
|
50
|
-
// Init injects
|
51
73
|
function initInject(base_dir) {
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
74
|
+
const injects = {};
|
75
|
+
import_injects_point.default.styles.forEach((item) => {
|
76
|
+
injects[item] = new StylusInject(base_dir);
|
77
|
+
});
|
78
|
+
import_injects_point.default.views.forEach((item) => {
|
79
|
+
injects[item] = new ViewInject(base_dir);
|
80
|
+
});
|
81
|
+
return injects;
|
60
82
|
}
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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);
|
83
|
+
var injects_default = (hexo) => {
|
84
|
+
const injects = initInject(hexo.base_dir);
|
85
|
+
hexo.execFilterSync("theme_inject", injects);
|
86
|
+
hexo.theme.config.injects = {};
|
87
|
+
import_injects_point.default.styles.forEach((type) => {
|
88
|
+
hexo.theme.config.injects[type] = injects[type].files;
|
89
|
+
});
|
90
|
+
import_injects_point.default.views.forEach((type) => {
|
91
|
+
const configs = /* @__PURE__ */ Object.create(null);
|
92
|
+
hexo.theme.config.injects[type] = [];
|
93
|
+
injects[type].raws.forEach((injectObj, index) => {
|
94
|
+
const name = `inject/${type}/${injectObj.name}`;
|
95
|
+
hexo.theme.setView(name, injectObj.raw);
|
96
|
+
configs[name] = {
|
97
|
+
layout: name,
|
98
|
+
locals: injectObj.args[0],
|
99
|
+
options: injectObj.args[1],
|
100
|
+
order: injectObj.args[2] || index
|
101
|
+
};
|
88
102
|
});
|
103
|
+
hexo.theme.config.injects[type] = Object.values(configs).sort((x, y) => x.order - y.order);
|
104
|
+
});
|
89
105
|
};
|
package/scripts/tags/links.js
CHANGED
@@ -1,44 +1,61 @@
|
|
1
|
-
|
2
|
-
var
|
3
|
-
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
9
|
+
for (let key of __getOwnPropNames(from))
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
11
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
12
|
+
}
|
13
|
+
return to;
|
4
14
|
};
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
|
+
mod
|
22
|
+
));
|
23
|
+
var import_node_fs = __toESM(require("node:fs"));
|
24
|
+
var import_node_path = __toESM(require("node:path"));
|
25
|
+
var import_js_yaml = __toESM(require("js-yaml"));
|
9
26
|
function linkGrid(args, content) {
|
10
|
-
|
11
|
-
|
12
|
-
|
27
|
+
const theme = hexo.theme.config;
|
28
|
+
if (!args[0] && !content) {
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
if (args[0]) {
|
32
|
+
const filepath = import_node_path.default.join(hexo.source_dir, args[0]);
|
33
|
+
if (import_node_fs.default.existsSync(filepath)) {
|
34
|
+
content = import_node_fs.default.readFileSync(filepath, { encoding: "utf-8" });
|
13
35
|
}
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
36
|
+
}
|
37
|
+
if (!content) {
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
const list = import_js_yaml.default.load(content);
|
41
|
+
let result = "";
|
42
|
+
list.forEach((item) => {
|
43
|
+
if (!item.url || !item.site) {
|
44
|
+
return;
|
19
45
|
}
|
20
|
-
|
21
|
-
|
46
|
+
let item_image = item.image || theme.assets + "/404.png";
|
47
|
+
if (!item_image.startsWith("//") && !item_image.startsWith("http")) {
|
48
|
+
item_image = theme.statics + item_image;
|
22
49
|
}
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
if (!item.url || !item.site) {
|
27
|
-
return;
|
28
|
-
}
|
29
|
-
let item_image = item.image || theme.assets + '/404.png';
|
30
|
-
if (!item_image.startsWith('//') && !item_image.startsWith('http')) {
|
31
|
-
item_image = theme.statics + item_image;
|
32
|
-
}
|
33
|
-
item.color = item.color ? ` style="--block-color:${item.color};"` : '';
|
34
|
-
result += `<div class="item" title="${item.owner || item.site}"${item.color}>`;
|
35
|
-
result += `<a href="${item.url}" class="image" data-background-image="${item_image}"></a>
|
50
|
+
item.color = item.color ? ` style="--block-color:${item.color};"` : "";
|
51
|
+
result += `<div class="item" title="${item.owner || item.site}"${item.color}>`;
|
52
|
+
result += `<a href="${item.url}" class="image" data-background-image="${item_image}"></a>
|
36
53
|
<div class="info">
|
37
54
|
<a href="${item.url}" class="title">${item.site}</a>
|
38
55
|
<p class="desc">${item.desc || item.url}</p>
|
39
56
|
</div></div>`;
|
40
|
-
|
41
|
-
|
57
|
+
});
|
58
|
+
return `<div class="links">${result}</div>`;
|
42
59
|
}
|
43
|
-
hexo.extend.tag.register(
|
44
|
-
hexo.extend.tag.register(
|
60
|
+
hexo.extend.tag.register("links", linkGrid, { ends: true });
|
61
|
+
hexo.extend.tag.register("linksfile", linkGrid, { ends: false, async: true });
|
package/scripts/tags/media.js
CHANGED
@@ -1,19 +1,36 @@
|
|
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
|
-
|
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_js_yaml = __toESM(require("js-yaml"));
|
8
25
|
function postMedia(args, content) {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
26
|
+
if (!args[0] || !content) {
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
const list = import_js_yaml.default.load(content);
|
30
|
+
switch (args[0]) {
|
31
|
+
case "video":
|
32
|
+
case "audio":
|
33
|
+
return `<div class="media-container"><div class="player" data-type="${args[0]}" data-src='${JSON.stringify(list)}'></div></div>`;
|
34
|
+
}
|
18
35
|
}
|
19
|
-
hexo.extend.tag.register(
|
36
|
+
hexo.extend.tag.register("media", postMedia, { ends: true });
|
package/scripts/utils.js
CHANGED
@@ -1,20 +1,42 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
var utils_exports = {};
|
19
|
+
__export(utils_exports, {
|
20
|
+
getVendorLink: () => getVendorLink
|
21
|
+
});
|
22
|
+
module.exports = __toCommonJS(utils_exports);
|
4
23
|
function getVendorLink(hexo, source) {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
}
|
24
|
+
const vendorsCfg = hexo.theme.config.vendors;
|
25
|
+
if (source.source === "local") {
|
26
|
+
return {
|
27
|
+
url: source.url,
|
28
|
+
local: true,
|
29
|
+
sri: ""
|
30
|
+
};
|
31
|
+
} else {
|
32
|
+
return {
|
33
|
+
url: vendorsCfg.cdns[source.source] + "/" + source.url,
|
34
|
+
local: false,
|
35
|
+
sri: source.sri
|
36
|
+
};
|
37
|
+
}
|
20
38
|
}
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
40
|
+
0 && (module.exports = {
|
41
|
+
getVendorLink
|
42
|
+
});
|
package/toolbox/compiler.mjs
CHANGED
@@ -5,35 +5,19 @@ compatibility: ShokaX v0.4.x
|
|
5
5
|
import path from "node:path";
|
6
6
|
import fs from 'fs/promises'
|
7
7
|
import child_process from 'child_process'
|
8
|
+
import { buildSync } from 'esbuild'
|
9
|
+
import { glob } from 'glob'
|
8
10
|
|
9
11
|
const CONFIG = {
|
10
|
-
legacyScript:
|
12
|
+
legacyScript: false,
|
11
13
|
}
|
12
14
|
|
13
|
-
async function deleteFileRecursive(dir) {
|
14
|
-
const files = await fs.readdir(dir)
|
15
|
-
for (const f of files) {
|
16
|
-
const fullPath = path.join(dir, f)
|
17
|
-
const stat = await fs.lstat(fullPath)
|
18
|
-
if (stat.isDirectory()) {
|
19
|
-
await deleteFileRecursive(fullPath)
|
20
|
-
} else {
|
21
|
-
const fileExt = path.extname(f)
|
22
|
-
if (fileExt === '.ts' || fileExt === '.json' || fileExt === '.tsbuildinfo') {
|
23
|
-
await fs.unlink(fullPath)
|
24
|
-
}
|
25
|
-
}
|
26
|
-
}
|
27
|
-
}
|
28
15
|
console.log('ShokaX ToolBox - Compiler')
|
29
16
|
console.log('Start compiling...')
|
30
17
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
} else if (hexoRoot.startsWith('file:\\')) {
|
35
|
-
hexoRoot = hexoRoot.slice(8); // 去除 'file:\'
|
36
|
-
}
|
18
|
+
const entryPoints = await glob('./scripts/**/*.ts');
|
19
|
+
const jsons = await glob('./scripts/**/*.json');
|
20
|
+
|
37
21
|
if (CONFIG.legacyScript) {
|
38
22
|
console.log('Simulating legacy script compiler...')
|
39
23
|
let sPath = path.join(import.meta.url, './../../scripts/').trim()
|
@@ -49,12 +33,34 @@ if (CONFIG.legacyScript) {
|
|
49
33
|
cwd: sPath
|
50
34
|
}, async (code, stdout, stderr) => {
|
51
35
|
console.log('Deleting typescript files...')
|
52
|
-
|
36
|
+
for (const entry of entryPoints) {
|
37
|
+
await fs.unlink(entry)
|
38
|
+
}
|
39
|
+
for (const entry of jsons) {
|
40
|
+
await fs.unlink(entry)
|
41
|
+
}
|
53
42
|
console.log('Finished compiling.')
|
54
43
|
})
|
55
44
|
})
|
56
45
|
} else {
|
57
|
-
|
46
|
+
console.log('RUN THIS SCRIPT IN YOUR SHOKAX THEME ROOT DIRECTORY!')
|
47
|
+
console.log('Using esbuild compiler...')
|
48
|
+
buildSync({
|
49
|
+
entryPoints: entryPoints,
|
50
|
+
outdir: 'scripts',
|
51
|
+
bundle: false,
|
52
|
+
format: 'cjs',
|
53
|
+
target: ['esnext'],
|
54
|
+
platform: 'node',
|
55
|
+
loader: { '.ts': 'ts' },
|
56
|
+
})
|
57
|
+
entryPoints.forEach(async (entry) => {
|
58
|
+
await fs.unlink(entry)
|
59
|
+
})
|
60
|
+
jsons.forEach(async (entry)=>{
|
61
|
+
await fs.unlink(entry)
|
62
|
+
})
|
63
|
+
console.log('Finished compiling.')
|
58
64
|
}
|
59
65
|
|
60
66
|
console.log('Done.')
|