hexo-theme-shokax 0.5.0-beta2-dev-9b68cc1 → 0.5.0-beta2-dev-86064c8
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/package.json
CHANGED
@@ -24,6 +24,7 @@ var import_package = __toESM(require("../../package.json"));
|
|
24
24
|
var import_promises = __toESM(require("node:fs/promises"));
|
25
25
|
var import_esbuild = require("esbuild");
|
26
26
|
var import_utils = require("../utils");
|
27
|
+
var import_hexo_util = require("hexo-util");
|
27
28
|
hexo.extend.generator.register("script", async function(locals) {
|
28
29
|
const config = hexo.config;
|
29
30
|
const theme = hexo.theme.config;
|
@@ -136,23 +137,47 @@ hexo.extend.generator.register("script", async function(locals) {
|
|
136
137
|
});
|
137
138
|
const res = [];
|
138
139
|
resultApp.outputFiles.forEach((file) => {
|
140
|
+
let fileName = "";
|
141
|
+
if (file.path.split("\\").length > 1) {
|
142
|
+
fileName = file.path.split("\\").pop();
|
143
|
+
} else {
|
144
|
+
fileName = file.path.split("/").pop();
|
145
|
+
}
|
139
146
|
if (file.path.endsWith(".js")) {
|
140
147
|
res.push({
|
141
|
-
path: theme.js + "/" +
|
142
|
-
data: file.
|
148
|
+
path: theme.js + "/" + fileName,
|
149
|
+
data: file.text
|
143
150
|
});
|
144
151
|
} else if (file.path.endsWith(".css")) {
|
145
152
|
res.push({
|
146
|
-
path: theme.css + "/" +
|
147
|
-
data: file.
|
153
|
+
path: theme.css + "/" + fileName,
|
154
|
+
data: file.text
|
148
155
|
});
|
149
156
|
} else {
|
150
157
|
res.push({
|
151
|
-
path: theme.statics + "/" +
|
152
|
-
data: file.
|
158
|
+
path: theme.statics + "/" + fileName,
|
159
|
+
data: file.text
|
153
160
|
});
|
154
161
|
}
|
155
162
|
});
|
163
|
+
hexo.extend.helper.register("preloadjs", function() {
|
164
|
+
let resultHtml = "";
|
165
|
+
res.forEach((file) => {
|
166
|
+
if (file.path.endsWith(".js")) {
|
167
|
+
resultHtml += (0, import_hexo_util.htmlTag)("link", { rel: "modulepreload", href: import_hexo_util.url_for.call(this, file.path) }, "");
|
168
|
+
}
|
169
|
+
});
|
170
|
+
return resultHtml;
|
171
|
+
});
|
172
|
+
hexo.extend.helper.register("load_async_css", function() {
|
173
|
+
let resultHtml = "";
|
174
|
+
res.forEach((file) => {
|
175
|
+
if (file.path.endsWith(".css")) {
|
176
|
+
resultHtml += (0, import_hexo_util.htmlTag)("link", { rel: "stylesheet", href: import_hexo_util.url_for.call(this, file.path), media: "none", onload: "this.media='all'" }, "");
|
177
|
+
}
|
178
|
+
});
|
179
|
+
return resultHtml;
|
180
|
+
});
|
156
181
|
if (theme.experiments.cloudflarePatch) {
|
157
182
|
const resultCF = await (0, import_esbuild.build)({
|
158
183
|
write: false,
|
@@ -175,7 +200,7 @@ hexo.extend.generator.register("script", async function(locals) {
|
|
175
200
|
});
|
176
201
|
res.push({
|
177
202
|
path: theme.js + "/cf-patch.js",
|
178
|
-
data: resultCF.outputFiles[0].
|
203
|
+
data: resultCF.outputFiles[0].text
|
179
204
|
});
|
180
205
|
}
|
181
206
|
return res;
|
@@ -1,28 +1,5 @@
|
|
1
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;
|
15
|
-
};
|
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
2
|
var import_hexo_util = require("hexo-util");
|
25
|
-
var import_node_fs = __toESM(require("node:fs"));
|
26
3
|
const randomBG = function(count = 1, image_server = null, image_list = []) {
|
27
4
|
let i;
|
28
5
|
if (image_server) {
|
@@ -68,26 +45,6 @@ const randomBG = function(count = 1, image_server = null, image_list = []) {
|
|
68
45
|
hexo.extend.helper.register("shokax_inject", function(point) {
|
69
46
|
return hexo.theme.config.injects[point].map((item) => this.partial(item.layout, item.locals, item.options)).join("");
|
70
47
|
});
|
71
|
-
hexo.extend.helper.register("preloadjs", function() {
|
72
|
-
const { statics, js } = hexo.theme.config;
|
73
|
-
let res = "";
|
74
|
-
import_node_fs.default.readdirSync("./shokaxTemp").forEach((file) => {
|
75
|
-
if (file.endsWith(".js")) {
|
76
|
-
res += (0, import_hexo_util.htmlTag)("link", { rel: "modulepreload", href: import_hexo_util.url_for.call(this, `${statics}${js}/${file}`) }, "");
|
77
|
-
}
|
78
|
-
});
|
79
|
-
return res;
|
80
|
-
});
|
81
|
-
hexo.extend.helper.register("load_async_css", function() {
|
82
|
-
const { statics, css } = hexo.theme.config;
|
83
|
-
let res = "";
|
84
|
-
import_node_fs.default.readdirSync("./shokaxTemp").forEach((file) => {
|
85
|
-
if (file.endsWith(".css")) {
|
86
|
-
res += (0, import_hexo_util.htmlTag)("link", { rel: "stylesheet", href: import_hexo_util.url_for.call(this, `${statics}${css}/${file}`), media: "none", onload: "this.media='all'" }, "");
|
87
|
-
}
|
88
|
-
});
|
89
|
-
return res;
|
90
|
-
});
|
91
48
|
hexo.extend.helper.register("_url", function(path, text, options = {}) {
|
92
49
|
if (!path) {
|
93
50
|
return;
|
package/scripts/plugin/index.js
CHANGED
@@ -25,7 +25,6 @@ var import_promises = require("node:fs/promises");
|
|
25
25
|
var import_injects = __toESM(require("./lib/injects"));
|
26
26
|
hexo.on("generateBefore", async () => {
|
27
27
|
(0, import_injects.default)(hexo);
|
28
|
-
await (0, import_promises.rm)("./shokaxTemp", { force: true, recursive: true });
|
29
28
|
try {
|
30
29
|
await (0, import_promises.unlink)("cf-patch.js");
|
31
30
|
} catch (e) {
|