hexo-theme-shokax 0.4.25 → 0.5.0-beta2-dev-9b68cc1
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/README.md +18 -31
- package/UsageRestrictions.md +2 -2
- package/_config.yml +11 -33
- package/_images.yml +0 -7
- package/eslint.config.mjs +4 -5
- package/layout/_mixin/card.pug +1 -2
- package/layout/_mixin/segment.pug +1 -1
- package/layout/_partials/footer.pug +1 -1
- package/layout/_partials/head/head.pug +0 -8
- package/layout/_partials/head/pwa.pug +1 -1
- package/layout/_partials/layout.pug +4 -12
- package/layout/_partials/post/footer.pug +1 -1
- package/layout/_partials/post/post.pug +2 -1
- package/layout/_partials/post/reward.pug +1 -1
- package/layout/_partials/third-party/baidu-analytics.pug +1 -1
- package/layout/_partials/third-party/google-analytics.pug +1 -1
- package/layout/archive.pug +3 -0
- package/layout/category.pug +3 -0
- package/layout/index.pug +3 -0
- package/layout/page.pug +7 -0
- package/layout/post.pug +8 -0
- package/layout/tag.pug +3 -0
- package/package.json +19 -20
- package/scripts/filters/post.js +1 -1
- package/scripts/generaters/config.js +12 -7
- package/scripts/generaters/images.js +9 -8
- package/scripts/generaters/index.js +57 -44
- package/scripts/generaters/script.js +21 -35
- package/scripts/generaters/summary_ai.js +1 -0
- package/scripts/helpers/engine.js +5 -7
- package/scripts/plugin/index.js +33 -46
- package/scripts/plugin/lib/injects-point.js +0 -1
- package/scripts/tags/media.js +1 -1
- package/source/css/app.styl +0 -13
- package/source/css/page.styl +3 -0
- package/source/css/post.styl +5 -0
- package/source/css/scaffolding.styl +5 -0
- package/source/js/_app/components/comments.ts +2 -3
- package/source/js/_app/components/sidebar.ts +35 -35
- package/source/js/_app/components/tcomments.ts +0 -1
- package/source/js/_app/globals/globalVars.ts +0 -15
- package/source/js/_app/globals/handles.ts +9 -9
- package/source/js/_app/globals/themeColor.ts +5 -6
- package/source/js/_app/globals/thirdparty.ts +2 -2
- package/source/js/_app/globals/tools.ts +4 -6
- package/source/js/_app/library/anime.ts +30 -19
- package/source/js/_app/library/declare.d.ts +0 -5
- package/source/js/_app/library/proto.ts +0 -67
- package/source/js/_app/library/vue.ts +7 -7
- package/source/js/_app/page/common.ts +8 -10
- package/source/js/_app/page/fancybox.ts +6 -8
- package/source/js/_app/page/post.ts +42 -54
- package/source/js/_app/page/search.ts +1 -6
- package/source/js/_app/page/tab.ts +8 -9
- package/source/js/_app/pjax/domInit.ts +19 -14
- package/source/js/_app/pjax/refresh.ts +8 -36
- package/source/js/_app/pjax/siteInit.ts +13 -42
- package/source/js/_app/player.ts +14 -798
- package/toolbox/compiler.mjs +20 -48
- package/toolbox/dev-version.mjs +14 -0
- package/README_en.MD +0 -71
- package/source/js/_app/library/dom.ts +0 -28
- package/source/js/_app/library/loadFile.ts +0 -47
- package/source/js/_app/library/scriptPjax.ts +0 -56
- package/source/js/_app/library/storage.ts +0 -12
@@ -21,13 +21,31 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
21
21
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
22
|
mod
|
23
23
|
));
|
24
|
+
var import_promises = require("node:fs/promises");
|
24
25
|
var import_hexo_pagination = __toESM(require("hexo-pagination"));
|
25
|
-
|
26
|
+
function getFileExtension(path) {
|
27
|
+
const filename = path.split(/[\\/]/).pop() || "";
|
28
|
+
const lastDotIndex = filename.lastIndexOf(".");
|
29
|
+
return lastDotIndex > 0 ? filename.slice(lastDotIndex + 1) : "";
|
30
|
+
}
|
26
31
|
hexo.config.index_generator = Object.assign({
|
27
32
|
per_page: typeof hexo.config.per_page === "undefined" ? 10 : hexo.config.per_page,
|
28
33
|
order_by: "-date"
|
29
34
|
}, hexo.config.index_generator);
|
30
|
-
hexo.extend.
|
35
|
+
hexo.extend.helper.register("getCoverExt", function(path) {
|
36
|
+
const theme = hexo.theme.config;
|
37
|
+
if (theme.homeConfig.cateCards.length > 0) {
|
38
|
+
const cardMap = /* @__PURE__ */ new Map();
|
39
|
+
theme.homeConfig.cateCards.forEach((card) => {
|
40
|
+
cardMap.set(card.slug, card.cover);
|
41
|
+
});
|
42
|
+
if (cardMap.has(path)) {
|
43
|
+
const cover = cardMap.get(path);
|
44
|
+
return getFileExtension(cover);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
});
|
48
|
+
hexo.extend.generator.register("index", async function(locals) {
|
31
49
|
const covers = [];
|
32
50
|
const catlist = [];
|
33
51
|
let pages;
|
@@ -37,6 +55,7 @@ hexo.extend.generator.register("index", function(locals) {
|
|
37
55
|
const paginationDir = config.pagination_dir || "page";
|
38
56
|
const path = config.index_generator.path || "";
|
39
57
|
const categories = locals.categories;
|
58
|
+
const theme = hexo.theme.config;
|
40
59
|
const getTopcat = function(cat) {
|
41
60
|
if (cat.parent) {
|
42
61
|
const pCat = categories.findOne({ _id: cat.parent });
|
@@ -46,50 +65,44 @@ hexo.extend.generator.register("index", function(locals) {
|
|
46
65
|
}
|
47
66
|
};
|
48
67
|
if (categories && categories.length) {
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
}
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
68
|
+
await Promise.all(
|
69
|
+
categories.map(async (cat) => {
|
70
|
+
const cover = `source/_posts/${cat.slug}`;
|
71
|
+
if (theme.homeConfig.cateCards.length > 0) {
|
72
|
+
const cardMap = /* @__PURE__ */ new Map();
|
73
|
+
theme.homeConfig.cateCards.forEach((card) => {
|
74
|
+
cardMap.set(card.slug, card.cover);
|
75
|
+
});
|
76
|
+
if (cardMap.has(cat.slug)) {
|
77
|
+
const cover2 = cardMap.get(cat.slug);
|
78
|
+
const coverData = await (0, import_promises.readFile)(`source/_posts/${cover2}`);
|
79
|
+
covers.push({
|
80
|
+
path: `${cat.slug}/cover.${getFileExtension(cover2)}`,
|
81
|
+
data: coverData
|
82
|
+
});
|
83
|
+
const topcat = getTopcat(cat);
|
84
|
+
if (topcat._id !== cat._id) {
|
85
|
+
cat.top = topcat;
|
86
|
+
}
|
87
|
+
const child = categories.find({ parent: cat._id });
|
88
|
+
let pl = 6;
|
89
|
+
if (child.length !== 0) {
|
90
|
+
cat.child = child.length;
|
91
|
+
cat.subs = child.sort({ name: 1 }).limit(6).toArray();
|
92
|
+
pl = Math.max(0, pl - child.length);
|
93
|
+
if (pl > 0) {
|
94
|
+
cat.subs.push(...cat.posts.sort({ title: 1 }).filter(function(item, i) {
|
95
|
+
return item.categories.last()._id === cat._id;
|
96
|
+
}).limit(pl).toArray());
|
97
|
+
}
|
98
|
+
} else {
|
99
|
+
cat.subs = cat.posts.sort({ title: 1 }).limit(6).toArray();
|
100
|
+
}
|
101
|
+
catlist.push(cat);
|
63
102
|
}
|
64
|
-
});
|
65
|
-
} else if (fs.existsSync(cover + "/cover.jpg")) {
|
66
|
-
covers.push({
|
67
|
-
path: cat.slug + "/cover.jpg",
|
68
|
-
data: function() {
|
69
|
-
return fs.createReadStream(cover + "/cover.jpg");
|
70
|
-
}
|
71
|
-
});
|
72
|
-
const topcat = getTopcat(cat);
|
73
|
-
if (topcat._id !== cat._id) {
|
74
|
-
cat.top = topcat;
|
75
|
-
}
|
76
|
-
const child = categories.find({ parent: cat._id });
|
77
|
-
let pl = 6;
|
78
|
-
if (child.length !== 0) {
|
79
|
-
cat.child = child.length;
|
80
|
-
cat.subs = child.sort({ name: 1 }).limit(6).toArray();
|
81
|
-
pl = Math.max(0, pl - child.length);
|
82
|
-
if (pl > 0) {
|
83
|
-
cat.subs.push(...cat.posts.sort({ title: 1 }).filter(function(item, i) {
|
84
|
-
return item.categories.last()._id === cat._id;
|
85
|
-
}).limit(pl).toArray());
|
86
|
-
}
|
87
|
-
} else {
|
88
|
-
cat.subs = cat.posts.sort({ title: 1 }).limit(6).toArray();
|
89
103
|
}
|
90
|
-
|
91
|
-
|
92
|
-
});
|
104
|
+
})
|
105
|
+
);
|
93
106
|
}
|
94
107
|
if (posts.length > 0) {
|
95
108
|
pages = (0, import_hexo_pagination.default)(path, posts, {
|
@@ -21,10 +21,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
21
21
|
mod
|
22
22
|
));
|
23
23
|
var import_package = __toESM(require("../../package.json"));
|
24
|
-
var
|
24
|
+
var import_promises = __toESM(require("node:fs/promises"));
|
25
25
|
var import_esbuild = require("esbuild");
|
26
26
|
var import_utils = require("../utils");
|
27
|
-
hexo.extend.generator.register("script", function(locals) {
|
27
|
+
hexo.extend.generator.register("script", async function(locals) {
|
28
28
|
const config = hexo.config;
|
29
29
|
const theme = hexo.theme.config;
|
30
30
|
const siteConfig = {
|
@@ -55,10 +55,6 @@ hexo.extend.generator.register("script", function(locals) {
|
|
55
55
|
enable: theme.outime.enable,
|
56
56
|
days: theme.outime.days
|
57
57
|
},
|
58
|
-
quicklink: {
|
59
|
-
timeout: theme.quicklink.timeout,
|
60
|
-
priority: theme.quicklink.priority
|
61
|
-
},
|
62
58
|
playerAPI: theme.playerAPI,
|
63
59
|
experiments: {
|
64
60
|
copyrightLength: theme.experiments.copyrightLength
|
@@ -93,14 +89,16 @@ hexo.extend.generator.register("script", function(locals) {
|
|
93
89
|
siteConfig.audio = theme.audio;
|
94
90
|
}
|
95
91
|
let enterPoint, patchDir;
|
96
|
-
|
97
|
-
|
92
|
+
try {
|
93
|
+
await import_promises.default.readFile("themes/shokaX/source/js/_app/pjax/siteInit.ts", "utf-8");
|
98
94
|
enterPoint = "themes/shokaX/source/js/_app/pjax/siteInit.ts";
|
99
|
-
|
100
|
-
|
95
|
+
patchDir = "themes/shokaX/source/js/_app/components/cloudflare.ts";
|
96
|
+
} catch (e) {
|
101
97
|
enterPoint = "node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.ts";
|
98
|
+
patchDir = "node_modules/hexo-theme-shokax/source/js/_app/components/cloudflare.ts";
|
102
99
|
}
|
103
|
-
(0, import_esbuild.
|
100
|
+
const resultApp = await (0, import_esbuild.build)({
|
101
|
+
write: false,
|
104
102
|
entryPoints: [enterPoint],
|
105
103
|
bundle: true,
|
106
104
|
outdir: "shokaxTemp",
|
@@ -121,8 +119,6 @@ hexo.extend.generator.register("script", function(locals) {
|
|
121
119
|
mainFields: ["module", "browser", "main"],
|
122
120
|
splitting: true,
|
123
121
|
define: {
|
124
|
-
__UNLAZY_LOGGING__: "false",
|
125
|
-
__UNLAZY_HASH_DECODING__: theme.modules.unlazyHash ? "true" : "false",
|
126
122
|
__shokax_player__: theme.modules.player ? "true" : "false",
|
127
123
|
__shokax_VL__: theme.modules.visibilityListener ? "true" : "false",
|
128
124
|
__shokax_fireworks__: theme.fireworks && theme.fireworks.enable && theme.fireworks.options && theme.modules.fireworks ? "true" : "false",
|
@@ -139,35 +135,27 @@ hexo.extend.generator.register("script", function(locals) {
|
|
139
135
|
}
|
140
136
|
});
|
141
137
|
const res = [];
|
142
|
-
|
143
|
-
|
144
|
-
if (file.endsWith("js")) {
|
145
|
-
const result = hexo.render.renderSync({ text: fileText, engine: "js" });
|
138
|
+
resultApp.outputFiles.forEach((file) => {
|
139
|
+
if (file.path.endsWith(".js")) {
|
146
140
|
res.push({
|
147
|
-
path: theme.js + "/" + file,
|
148
|
-
data:
|
149
|
-
return result;
|
150
|
-
}
|
141
|
+
path: theme.js + "/" + file.path.split("/").pop(),
|
142
|
+
data: file.contents
|
151
143
|
});
|
152
|
-
} else if (file.endsWith("css")) {
|
153
|
-
const result = hexo.render.renderSync({ text: fileText, engine: "css" });
|
144
|
+
} else if (file.path.endsWith(".css")) {
|
154
145
|
res.push({
|
155
|
-
path: theme.css + "/" + file,
|
156
|
-
data:
|
157
|
-
return result;
|
158
|
-
}
|
146
|
+
path: theme.css + "/" + file.path.split("/").pop(),
|
147
|
+
data: file.contents
|
159
148
|
});
|
160
149
|
} else {
|
161
150
|
res.push({
|
162
|
-
path: theme.
|
163
|
-
data:
|
164
|
-
return fileText;
|
165
|
-
}
|
151
|
+
path: theme.statics + "/" + file.path.split("/").pop(),
|
152
|
+
data: file.contents
|
166
153
|
});
|
167
154
|
}
|
168
155
|
});
|
169
156
|
if (theme.experiments.cloudflarePatch) {
|
170
|
-
const
|
157
|
+
const resultCF = await (0, import_esbuild.build)({
|
158
|
+
write: false,
|
171
159
|
entryPoints: [patchDir],
|
172
160
|
bundle: true,
|
173
161
|
platform: "browser",
|
@@ -187,9 +175,7 @@ hexo.extend.generator.register("script", function(locals) {
|
|
187
175
|
});
|
188
176
|
res.push({
|
189
177
|
path: theme.js + "/cf-patch.js",
|
190
|
-
data:
|
191
|
-
return import_node_fs.default.readFileSync("./cf-patch.js", { encoding: "utf-8" });
|
192
|
-
}
|
178
|
+
data: resultCF.outputFiles[0].contents
|
193
179
|
});
|
194
180
|
}
|
195
181
|
return res;
|
@@ -90,6 +90,7 @@ class SummaryDatabase {
|
|
90
90
|
if (this.data.summaries[pathHash]?.sha256 === contentHash) {
|
91
91
|
return this.data.summaries[pathHash].summary;
|
92
92
|
} else {
|
93
|
+
hexo.log.info(`[ShokaX Summary AI] \u6B63\u5728\u5411 API \u8BF7\u6C42 ${path} \u7684\u6458\u8981`);
|
93
94
|
const summaryContent = await getSummaryByAPI(content);
|
94
95
|
this.data.summaries[pathHash] = {
|
95
96
|
summary: summaryContent,
|
@@ -23,7 +23,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
23
23
|
));
|
24
24
|
var import_hexo_util = require("hexo-util");
|
25
25
|
var import_node_fs = __toESM(require("node:fs"));
|
26
|
-
const randomServer = parseInt(String(Math.random() * 4), 10) + 1;
|
27
26
|
const randomBG = function(count = 1, image_server = null, image_list = []) {
|
28
27
|
let i;
|
29
28
|
if (image_server) {
|
@@ -37,13 +36,12 @@ const randomBG = function(count = 1, image_server = null, image_list = []) {
|
|
37
36
|
return image_server + "?" + Math.floor(Math.random() * 999999);
|
38
37
|
}
|
39
38
|
const parseImage = function(img, size) {
|
40
|
-
if (img.startsWith("//") || img.startsWith("
|
39
|
+
if (img.startsWith("//") || img.startsWith("https")) {
|
41
40
|
return img;
|
42
41
|
} else if (hexo.theme.config.experiments?.usingRelative) {
|
43
42
|
return img;
|
44
43
|
} else {
|
45
|
-
|
46
|
-
return `https://tva${randomServer}.sinaimg.cn/` + size + "/" + img;
|
44
|
+
throw new Error("Image URL is not valid: " + img);
|
47
45
|
}
|
48
46
|
};
|
49
47
|
if (count && count > 1) {
|
@@ -67,6 +65,9 @@ const randomBG = function(count = 1, image_server = null, image_list = []) {
|
|
67
65
|
}
|
68
66
|
return parseImage(image_list[Math.floor(Math.random() * image_list.length)], "mw690");
|
69
67
|
};
|
68
|
+
hexo.extend.helper.register("shokax_inject", function(point) {
|
69
|
+
return hexo.theme.config.injects[point].map((item) => this.partial(item.layout, item.locals, item.options)).join("");
|
70
|
+
});
|
70
71
|
hexo.extend.helper.register("preloadjs", function() {
|
71
72
|
const { statics, js } = hexo.theme.config;
|
72
73
|
let res = "";
|
@@ -158,6 +159,3 @@ hexo.extend.helper.register("random_color", function() {
|
|
158
159
|
const [r, g, b] = arr;
|
159
160
|
return `#${r.toString(16).length > 1 ? r.toString(16) : "0" + r.toString(16)}${g.toString(16).length > 1 ? g.toString(16) : "0" + g.toString(16)}${b.toString(16).length > 1 ? b.toString(16) : "0" + b.toString(16)}`;
|
160
161
|
});
|
161
|
-
hexo.extend.helper.register("shokax_inject", function(point) {
|
162
|
-
return hexo.theme.config.injects[point].map((item) => this.partial(item.layout, item.locals, item.options)).join("");
|
163
|
-
});
|
package/scripts/plugin/index.js
CHANGED
@@ -20,56 +20,43 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
20
20
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
21
|
mod
|
22
22
|
));
|
23
|
-
var import_injects = __toESM(require("./lib/injects"));
|
24
23
|
var import_package = require("../../package.json");
|
25
|
-
var
|
26
|
-
|
27
|
-
|
28
|
-
under GNU AFFERO GENERAL PUBLIC LICENSE v3.0 OR LATER
|
29
|
-
https://github.com/next-theme/hexo-theme-next/blob/master/LICENSE.md
|
30
|
-
*/
|
31
|
-
hexo.on("generateBefore", () => {
|
24
|
+
var import_promises = require("node:fs/promises");
|
25
|
+
var import_injects = __toESM(require("./lib/injects"));
|
26
|
+
hexo.on("generateBefore", async () => {
|
32
27
|
(0, import_injects.default)(hexo);
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
}
|
37
|
-
if (fs.existsSync("request.lock")) {
|
38
|
-
fs.unlinkSync("request.lock");
|
39
|
-
}
|
40
|
-
if (fs.existsSync("requested.lock")) {
|
41
|
-
fs.unlinkSync("requested.lock");
|
28
|
+
await (0, import_promises.rm)("./shokaxTemp", { force: true, recursive: true });
|
29
|
+
try {
|
30
|
+
await (0, import_promises.unlink)("cf-patch.js");
|
31
|
+
} catch (e) {
|
42
32
|
}
|
43
33
|
});
|
44
|
-
hexo.on("generateAfter", () => {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
try {
|
50
|
-
const latest = resp["version"];
|
51
|
-
const current = import_package.version.split(".");
|
52
|
-
let isOutdated = false;
|
53
|
-
for (let i = 0; i < Math.max(latest.length, current.length); i++) {
|
54
|
-
if (!current[i] || latest[i] > current[i]) {
|
55
|
-
isOutdated = true;
|
56
|
-
break;
|
57
|
-
}
|
58
|
-
if (latest[i] < current[i]) {
|
59
|
-
break;
|
60
|
-
}
|
61
|
-
}
|
62
|
-
if (isOutdated) {
|
63
|
-
hexo.log.warn(`Your theme ShokaX is outdated. Current version: v${current.join(".")}, latest version: v${latest.join(".")}`);
|
64
|
-
hexo.log.warn("Visit https://github.com/theme-shoka-x/hexo-theme-shokaX/releases for more information.");
|
65
|
-
}
|
66
|
-
} catch (e) {
|
67
|
-
hexo.log.warn("Failed to detect version info. Error message:");
|
68
|
-
hexo.log.warn(e);
|
34
|
+
hexo.on("generateAfter", async () => {
|
35
|
+
try {
|
36
|
+
const res = await fetch("https://registry.npmmirror.com/hexo-theme-shokax/latest", {
|
37
|
+
headers: {
|
38
|
+
"User-Agent": "ShokaX Client (hexo-theme-shokax)"
|
69
39
|
}
|
70
|
-
}).catch((e) => {
|
71
|
-
hexo.log.warn("Failed to detect version info. Error message:");
|
72
|
-
hexo.log.warn(e);
|
73
40
|
});
|
74
|
-
|
41
|
+
const resp = await res.json();
|
42
|
+
const latest = resp.version;
|
43
|
+
const current = import_package.version.split(".");
|
44
|
+
let isOutdated = false;
|
45
|
+
for (let i = 0; i < Math.max(latest.length, current.length); i++) {
|
46
|
+
if (!current[i] || latest[i] > current[i]) {
|
47
|
+
isOutdated = true;
|
48
|
+
break;
|
49
|
+
}
|
50
|
+
if (latest[i] < current[i]) {
|
51
|
+
break;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
if (isOutdated) {
|
55
|
+
hexo.log.warn(`Your theme ShokaX is outdated. Current version: v${current.join(".")}, latest version: v${latest.join(".")}`);
|
56
|
+
hexo.log.warn("Visit https://github.com/theme-shoka-x/hexo-theme-shokaX/releases for more information.");
|
57
|
+
}
|
58
|
+
} catch (e) {
|
59
|
+
hexo.log.warn("Failed to detect version info. Error message:");
|
60
|
+
hexo.log.warn(e);
|
61
|
+
}
|
75
62
|
});
|
package/scripts/tags/media.js
CHANGED
@@ -30,7 +30,7 @@ function postMedia(args, content) {
|
|
30
30
|
switch (args[0]) {
|
31
31
|
case "video":
|
32
32
|
case "audio":
|
33
|
-
return `<div class="media-container"><div class="player" data-type="${args[0]}"
|
33
|
+
return `<div class="media-container"><div class="player" data-type="${args[0]}" src='${JSON.stringify(list)}'></div></div>`;
|
34
34
|
}
|
35
35
|
}
|
36
36
|
hexo.extend.tag.register("media", postMedia, { ends: true });
|
package/source/css/app.styl
CHANGED
@@ -20,22 +20,9 @@ if $_iconfont = hexo-config('style.iconfont')
|
|
20
20
|
else
|
21
21
|
@import "_iconfont";
|
22
22
|
|
23
|
-
// Scaffolding
|
24
|
-
@import "_common/scaffolding";
|
25
|
-
|
26
|
-
// Layout
|
27
|
-
@import "_common/outline";
|
28
|
-
|
29
|
-
// Components
|
30
|
-
@import "_common/components";
|
31
|
-
|
32
23
|
if $custom = hexo-config('style.custom')
|
33
24
|
@import $custom;
|
34
25
|
|
35
|
-
if hexo-config('injects.style')
|
36
|
-
for $inject_style in hexo-config('injects.style')
|
37
|
-
@import $inject_style;
|
38
|
-
|
39
26
|
if $optimize = hexo-config('experiments.optimizeLongPosts')
|
40
27
|
@import "optimize.styl"
|
41
28
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { CONFIG } from '../globals/globalVars'
|
2
2
|
import { init, RecentComments } from '@waline/client'
|
3
|
+
// @ts-ignore
|
3
4
|
import { pageviewCount } from '@waline/client/pageview'
|
5
|
+
// @ts-ignore
|
4
6
|
await import('@waline/client/style')
|
5
7
|
|
6
8
|
export const walineComment = function () {
|
@@ -21,7 +23,6 @@ export const walineComment = function () {
|
|
21
23
|
}
|
22
24
|
|
23
25
|
export const walinePageview = function () {
|
24
|
-
// TODO waline 上游此模块存在问题
|
25
26
|
pageviewCount({
|
26
27
|
serverURL: CONFIG.waline.serverURL,
|
27
28
|
path: window.location.pathname
|
@@ -35,7 +36,6 @@ export const walineRecentComments = async function () {
|
|
35
36
|
serverURL: CONFIG.waline.serverURL.replace(/\/+$/, ''),
|
36
37
|
count: 10
|
37
38
|
})
|
38
|
-
// TODO 疑似 waline API 返回格式与文档不一致,需要确认是否为上游问题
|
39
39
|
// @ts-ignore
|
40
40
|
comments.data.forEach(function (item) {
|
41
41
|
let cText = (item.orig.length > 50) ? item.orig.substring(0, 50) + '...' : item.orig
|
@@ -74,7 +74,6 @@ export const walineRecentComments = async function () {
|
|
74
74
|
commentTime.className = 'breadcrumb'
|
75
75
|
commentTime.innerText = `${item.nick} @ ${item.time}`
|
76
76
|
commentLink.href = root + item.href
|
77
|
-
commentLink['data-pjax-state'] = 'data-pjax-state'
|
78
77
|
commentEl.className = 'item'
|
79
78
|
|
80
79
|
commentText.appendChild(document.createElement('br'))
|
@@ -3,14 +3,12 @@
|
|
3
3
|
import { CONFIG, Container, diffY, menuToggle, showContents, sideBar } from '../globals/globalVars'
|
4
4
|
import { clipBoard } from '../globals/tools'
|
5
5
|
import { pageScroll, transition } from '../library/anime'
|
6
|
-
import {
|
7
|
-
import initProto, { getHeight, setDisplay } from '../library/proto'
|
6
|
+
import { getHeight, setDisplay } from '../library/proto'
|
8
7
|
|
9
|
-
initProto()
|
10
8
|
export const sideBarToggleHandle = (event:Event, force?:number) => {
|
11
|
-
if (sideBar.
|
12
|
-
sideBar.
|
13
|
-
menuToggle.
|
9
|
+
if (sideBar.classList.contains('on')) {
|
10
|
+
sideBar.classList.remove('on')
|
11
|
+
menuToggle.classList.remove('close')
|
14
12
|
if (force) {
|
15
13
|
// @ts-ignore
|
16
14
|
// noinspection JSConstantReassignment
|
@@ -25,8 +23,8 @@ export const sideBarToggleHandle = (event:Event, force?:number) => {
|
|
25
23
|
sideBar.style = ''
|
26
24
|
} else {
|
27
25
|
transition(sideBar, 'slideRightIn', () => {
|
28
|
-
sideBar.
|
29
|
-
menuToggle.
|
26
|
+
sideBar.classList.add('on')
|
27
|
+
menuToggle.classList.add('close')
|
30
28
|
})
|
31
29
|
}
|
32
30
|
}
|
@@ -61,29 +59,30 @@ export const sideBarTab = () => {
|
|
61
59
|
const text = document.createTextNode(element.getAttribute('data-title'))
|
62
60
|
span.appendChild(text)
|
63
61
|
tab.appendChild(span)
|
64
|
-
tab.
|
62
|
+
tab.classList.add(item)
|
63
|
+
tab.classList.add('item')
|
65
64
|
|
66
65
|
if (active) {
|
67
|
-
element.
|
68
|
-
tab.
|
66
|
+
element.classList.add(active)
|
67
|
+
tab.classList.add(active)
|
69
68
|
} else {
|
70
|
-
element.
|
69
|
+
element.classList.remove('active')
|
71
70
|
}
|
72
71
|
tab.addEventListener('click', (event) => {
|
73
72
|
const target = event.currentTarget as HTMLElement
|
74
|
-
if (target.
|
73
|
+
if (target.classList.contains('active')) return
|
75
74
|
|
76
|
-
sideBar.
|
77
|
-
element.
|
75
|
+
sideBar.querySelectorAll('.tab .item').forEach((element) => {
|
76
|
+
element.classList.remove('active')
|
78
77
|
})
|
79
78
|
|
80
|
-
sideBar.
|
81
|
-
element.
|
79
|
+
sideBar.querySelectorAll('.panel').forEach((element) => {
|
80
|
+
element.classList.remove('active')
|
82
81
|
})
|
83
82
|
|
84
|
-
sideBar.querySelector('.panel.' + target.className.replace(' item', '')).
|
83
|
+
sideBar.querySelector('.panel.' + target.className.replace(' item', '')).classList.add('active')
|
85
84
|
|
86
|
-
target.
|
85
|
+
target.classList.add('active')
|
87
86
|
})
|
88
87
|
|
89
88
|
list.appendChild(tab)
|
@@ -104,39 +103,39 @@ export const sidebarTOC = () => {
|
|
104
103
|
|
105
104
|
if (!target) return
|
106
105
|
|
107
|
-
if (target.
|
106
|
+
if (target.classList.contains('current')) {
|
108
107
|
return
|
109
108
|
}
|
110
109
|
|
111
|
-
|
112
|
-
element && element.
|
110
|
+
document.querySelectorAll('.toc .active').forEach((element) => {
|
111
|
+
element && element.classList.remove('active current')
|
113
112
|
})
|
114
113
|
|
115
114
|
sections.forEach((element) => {
|
116
|
-
element && element.
|
115
|
+
element && element.classList.remove('active')
|
117
116
|
})
|
118
117
|
|
119
|
-
target.
|
120
|
-
sections[index] && sections[index].
|
118
|
+
target.classList.add('active current')
|
119
|
+
sections[index] && sections[index].classList.add('active')
|
121
120
|
|
122
121
|
let parent = <Element> target.parentNode
|
123
122
|
|
124
123
|
while (!parent.matches('.contents')) {
|
125
124
|
if (parent.matches('li')) {
|
126
|
-
parent.
|
125
|
+
parent.classList.add('active')
|
127
126
|
const t = document.getElementById(decodeURIComponent(parent.querySelector('a.toc-link').getAttribute('href').replace('#', '')))
|
128
127
|
if (t) {
|
129
|
-
t.
|
128
|
+
t.classList.add('active')
|
130
129
|
}
|
131
130
|
}
|
132
131
|
parent = <Element> parent.parentNode
|
133
132
|
}
|
134
133
|
// Scrolling to center active TOC element if TOC content is taller than viewport.
|
135
|
-
if (getComputedStyle(sideBar).display !== 'none' && tocElement.
|
134
|
+
if (getComputedStyle(sideBar).display !== 'none' && tocElement.classList.contains('active')) {
|
136
135
|
pageScroll((tocElement as HTMLElement), target.offsetTop - ((tocElement as HTMLElement).offsetHeight / 4))
|
137
136
|
}
|
138
137
|
}
|
139
|
-
const navItems =
|
138
|
+
const navItems = document.querySelectorAll<HTMLElement>('.contents li')
|
140
139
|
|
141
140
|
if (navItems.length < 1) {
|
142
141
|
return
|
@@ -224,18 +223,19 @@ export const goToCommentHandle = () => {
|
|
224
223
|
}
|
225
224
|
|
226
225
|
export const menuActive = () => {
|
227
|
-
|
226
|
+
document.querySelectorAll('.menu .item:not(.title)').forEach((element) => {
|
228
227
|
const target = <HTMLAnchorElement> element.querySelector('a[href]')
|
229
|
-
const parentItem = element.parentNode.parentNode
|
228
|
+
const parentItem = element.parentNode.parentNode as HTMLElement
|
230
229
|
if (!target) return
|
231
230
|
const isSamePath = target.pathname === location.pathname || target.pathname === location.pathname.replace('index.html', '')
|
232
231
|
const isSubPath = !CONFIG.root.startsWith(target.pathname) && location.pathname.startsWith(target.pathname)
|
233
232
|
const active = !target.onclick && target.hostname === location.hostname && (isSamePath || isSubPath)
|
234
|
-
element.
|
235
|
-
if (element.parentNode.querySelector('.active') && parentItem.
|
236
|
-
parentItem.
|
233
|
+
element.classList.toggle('active', active)
|
234
|
+
if (element.parentNode.querySelector('.active') && parentItem.classList.contains('dropdown')) {
|
235
|
+
parentItem.classList.remove('active')
|
236
|
+
parentItem.classList.add('expand')
|
237
237
|
} else {
|
238
|
-
parentItem.
|
238
|
+
parentItem.classList.remove('expand')
|
239
239
|
}
|
240
240
|
})
|
241
241
|
}
|
@@ -40,7 +40,6 @@ export const twikooRecentComments = async function () {
|
|
40
40
|
commentTime.className = 'breadcrumb'
|
41
41
|
commentTime.innerText = `${item.nick} @ ${item.time}`
|
42
42
|
commentLink.href = root + item.href
|
43
|
-
commentLink['data-pjax-state'] = 'data-pjax-state'
|
44
43
|
commentEl.className = 'item'
|
45
44
|
|
46
45
|
commentText.appendChild(document.createElement('br'))
|