hexo-theme-shokax 0.4.12 → 0.4.13

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.
@@ -1,107 +1,113 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_fs_1 = __importDefault(require("node:fs"));
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"));
7
24
  function getContent(post) {
8
- return post?.raw ?? post?._content ?? post.content;
25
+ return post?.raw ?? post?._content ?? post.content;
9
26
  }
10
27
  let db;
11
28
  function postMessage(path, content, dbPath, startMessage) {
12
- if (node_fs_1.default.existsSync('summary.json')) {
13
- // @ts-ignore
14
- db = JSON.parse(node_fs_1.default.readFileSync('summary.json', { encoding: 'utf-8' }));
29
+ if (import_node_fs.default.existsSync("summary.json")) {
30
+ db = JSON.parse(import_node_fs.default.readFileSync("summary.json", { encoding: "utf-8" }));
31
+ } else {
32
+ db = {};
33
+ }
34
+ const config = hexo.theme.config.summary;
35
+ if (config.enable) {
36
+ if (typeof db?.[path] !== "undefined" && typeof db?.[path]?.[dbPath] !== "undefined") {
37
+ return db[path][dbPath];
38
+ } else {
39
+ if (typeof db?.[path] === "undefined") {
40
+ db[path] = {};
41
+ } else {
42
+ db[path][dbPath] = "";
43
+ }
15
44
  }
16
- else {
17
- db = {};
18
- }
19
- const config = hexo.theme.config.summary;
20
- if (config.enable) {
21
- if (typeof db?.[path] !== 'undefined' && typeof db?.[path]?.[dbPath] !== 'undefined') {
22
- return db[path][dbPath];
23
- }
24
- else {
25
- if (typeof db?.[path] === 'undefined') {
26
- db[path] = {};
27
- }
28
- else {
29
- db[path][dbPath] = '';
45
+ if (config.mode === "openai") {
46
+ const request = () => {
47
+ fetch(`${config.openai.remote}/v1/chat/completions`, {
48
+ method: "POST",
49
+ headers: requestHeaders,
50
+ body: JSON.stringify(requestBody)
51
+ }).then((response) => {
52
+ if (!response.ok) {
53
+ throw Error("ERROR: Failed to get summary from Openai API");
54
+ }
55
+ response.json().then((data) => {
56
+ const summary = data.choices[0].message.content;
57
+ try {
58
+ db[path][dbPath] = summary;
59
+ } catch (e) {
60
+ db ??= {};
61
+ db[path] ??= {};
62
+ db[path][dbPath] ??= "";
63
+ db[path][dbPath] = summary;
30
64
  }
31
- }
32
- if (config.mode === 'openai') {
33
- const request = () => {
34
- fetch(`${config.openai.remote}/v1/chat/completions`, {
35
- method: 'POST',
36
- headers: requestHeaders,
37
- body: JSON.stringify(requestBody)
38
- }).then((response) => {
39
- if (!response.ok) {
40
- throw Error('ERROR: Failed to get summary from Openai API');
41
- }
42
- response.json().then((data) => {
43
- // @ts-ignore
44
- const summary = data.choices[0].message.content;
45
- try {
46
- db[path][dbPath] = summary;
47
- }
48
- catch (e) {
49
- db ??= {};
50
- db[path] ??= {};
51
- db[path][dbPath] ??= '';
52
- db[path][dbPath] = summary;
53
- }
54
- node_fs_1.default.writeFileSync('summary.json', JSON.stringify(db));
55
- if (node_fs_1.default.existsSync('requested.lock')) {
56
- node_fs_1.default.unlinkSync('requested.lock');
57
- }
58
- return summary;
59
- });
60
- });
61
- };
62
- const checkTime = (waitTime) => {
63
- if (node_fs_1.default.existsSync('request.lock')) {
64
- if (node_fs_1.default.existsSync('requested.lock')) {
65
- setTimeout(checkTime, 1000 * waitTime);
66
- return;
67
- }
68
- // Openai API 针对个人用户免费试用限制 3 RPM,这里是25s后发送请求
69
- node_fs_1.default.writeFileSync('requested.lock', '');
70
- setTimeout(request, 1000 * 2.5 * waitTime);
71
- node_fs_1.default.unlinkSync('request.lock');
72
- }
73
- else {
74
- node_fs_1.default.writeFileSync('request.lock', '');
75
- request();
76
- }
77
- };
78
- const requestHeaders = {
79
- 'Content-Type': 'application/json',
80
- Authorization: `Bearer ${config.openai.apikey}`
81
- };
82
- const requestBody = {
83
- model: 'gpt-3.5-turbo',
84
- messages: [{ role: 'user', content: `${startMessage} ${content}` }],
85
- temperature: 0.7
86
- };
87
- if (config.pricing === 'trial') {
88
- hexo.log.info('Requesting OpenAI API... (3 RPM mode)');
89
- hexo.log.info('It may take 20 minutes or more (depending on the number of articles, each one takes 25 seconds)');
90
- checkTime(10);
91
- }
92
- else {
93
- hexo.log.info('Requesting OpenAI API... (60 RPM mode)');
94
- checkTime(0.5);
65
+ import_node_fs.default.writeFileSync("summary.json", JSON.stringify(db));
66
+ if (import_node_fs.default.existsSync("requested.lock")) {
67
+ import_node_fs.default.unlinkSync("requested.lock");
95
68
  }
69
+ return summary;
70
+ });
71
+ });
72
+ };
73
+ const checkTime = (waitTime) => {
74
+ if (import_node_fs.default.existsSync("request.lock")) {
75
+ if (import_node_fs.default.existsSync("requested.lock")) {
76
+ setTimeout(checkTime, 1e3 * waitTime);
77
+ return;
78
+ }
79
+ import_node_fs.default.writeFileSync("requested.lock", "");
80
+ setTimeout(request, 1e3 * 2.5 * waitTime);
81
+ import_node_fs.default.unlinkSync("request.lock");
82
+ } else {
83
+ import_node_fs.default.writeFileSync("request.lock", "");
84
+ request();
96
85
  }
97
- else {
98
- // custom尚未支持
99
- }
86
+ };
87
+ const requestHeaders = {
88
+ "Content-Type": "application/json",
89
+ Authorization: `Bearer ${config.openai.apikey}`
90
+ };
91
+ const requestBody = {
92
+ model: "gpt-3.5-turbo",
93
+ messages: [{ role: "user", content: `${startMessage} ${content}` }],
94
+ temperature: 0.7
95
+ };
96
+ if (config.pricing === "trial") {
97
+ hexo.log.info("Requesting OpenAI API... (3 RPM mode)");
98
+ hexo.log.info("It may take 20 minutes or more (depending on the number of articles, each one takes 25 seconds)");
99
+ checkTime(10);
100
+ } else {
101
+ hexo.log.info("Requesting OpenAI API... (60 RPM mode)");
102
+ checkTime(0.5);
103
+ }
104
+ } else {
100
105
  }
106
+ }
101
107
  }
102
- hexo.extend.helper.register('get_summary', (post) => {
103
- return postMessage(post.path, getContent(post), 'summary', '请为下述文章提供一份200字以内的概括,使用中文回答且尽可能简洁: ');
108
+ hexo.extend.helper.register("get_summary", (post) => {
109
+ return postMessage(post.path, getContent(post), "summary", "\u8BF7\u4E3A\u4E0B\u8FF0\u6587\u7AE0\u63D0\u4F9B\u4E00\u4EFD200\u5B57\u4EE5\u5185\u7684\u6982\u62EC\uFF0C\u4F7F\u7528\u4E2D\u6587\u56DE\u7B54\u4E14\u5C3D\u53EF\u80FD\u7B80\u6D01: ");
104
110
  });
105
- hexo.extend.helper.register('get_introduce', () => {
106
- return hexo.theme.config.summary.introduce;
111
+ hexo.extend.helper.register("get_introduce", () => {
112
+ return hexo.theme.config.summary.introduce;
107
113
  });
@@ -1,69 +1,61 @@
1
- 'use strict';
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /* global hexo */
1
+ "use strict";
2
+ var import_hexo_util = require("hexo-util");
4
3
  /*!
5
4
  hexo-symbols-count-time by theme-next
6
5
  under GNU Lesser General Public License v3.0 or later
7
6
  https://github.com/theme-next/hexo-symbols-count-time/blob/master/LICENSE
8
7
  */
9
- const hexo_util_1 = require("hexo-util");
10
8
  const config = hexo.config.symbols_count_time = Object.assign({
11
- symbols: true,
12
- time: true,
13
- total_symbols: true,
14
- total_time: true,
15
- exclude_codeblock: false,
16
- awl: 4,
17
- wpm: 275,
18
- suffix: 'mins.'
9
+ symbols: true,
10
+ time: true,
11
+ total_symbols: true,
12
+ total_time: true,
13
+ exclude_codeblock: false,
14
+ awl: 4,
15
+ wpm: 275,
16
+ suffix: "mins."
19
17
  }, hexo.config.symbols_count_time);
20
18
  function getSymbols(post) {
21
- return post?._content?.length ?? post?.content?.length ?? post.length;
19
+ return post?._content?.length ?? post?.content?.length ?? post.length;
22
20
  }
23
21
  function getSymbolsTotal(site) {
24
- let symbolsResultCount = 0;
25
- site.posts.forEach((post) => {
26
- symbolsResultCount += getSymbols(post);
27
- });
28
- return symbolsResultCount;
22
+ let symbolsResultCount = 0;
23
+ site.posts.forEach((post) => {
24
+ symbolsResultCount += getSymbols(post);
25
+ });
26
+ return symbolsResultCount;
29
27
  }
30
28
  function getFormatTime(minutes, suffix) {
31
- const fHours = Math.floor(minutes / 60);
32
- let fMinutes = Math.floor(minutes - (fHours * 60));
33
- if (fMinutes < 1) {
34
- fMinutes = 1; // 0 => 1
35
- }
36
- return fHours < 1
37
- ? fMinutes + ' ' + suffix // < 59 => 59 mins.
38
- : fHours + ':' + ('00' + fMinutes).slice(-2); // = 61 => 1:01
29
+ const fHours = Math.floor(minutes / 60);
30
+ let fMinutes = Math.floor(minutes - fHours * 60);
31
+ if (fMinutes < 1) {
32
+ fMinutes = 1;
33
+ }
34
+ return fHours < 1 ? fMinutes + " " + suffix : fHours + ":" + ("00" + fMinutes).slice(-2);
39
35
  }
40
- hexo.extend.helper.register('symbolsCount', function (post) {
41
- let symbolsResult = getSymbols(post);
42
- if (symbolsResult > 9999) {
43
- symbolsResult = Math.round(symbolsResult / 1000) + 'k'; // > 9999 => 11k
44
- }
45
- else if (symbolsResult > 999) {
46
- symbolsResult = Math.round(symbolsResult / 100) / 10 + 'k'; // > 999 => 1.1k
47
- } // < 999 => 111
48
- return symbolsResult;
36
+ hexo.extend.helper.register("symbolsCount", function(post) {
37
+ let symbolsResult = getSymbols(post);
38
+ if (symbolsResult > 9999) {
39
+ symbolsResult = Math.round(symbolsResult / 1e3) + "k";
40
+ } else if (symbolsResult > 999) {
41
+ symbolsResult = Math.round(symbolsResult / 100) / 10 + "k";
42
+ }
43
+ return symbolsResult;
49
44
  });
50
- hexo.extend.helper.register('symbolsTime', function (post, awl = config.awl, wpm = config.wpm, suffix = config.suffix) {
51
- const minutes = Math.round(getSymbols(post) / (awl * wpm));
52
- return getFormatTime(minutes, suffix);
45
+ hexo.extend.helper.register("symbolsTime", function(post, awl = config.awl, wpm = config.wpm, suffix = config.suffix) {
46
+ const minutes = Math.round(getSymbols(post) / (awl * wpm));
47
+ return getFormatTime(minutes, suffix);
53
48
  });
54
- hexo.extend.helper.register('symbolsCountTotal', function (site) {
55
- const symbolsResultTotal = getSymbolsTotal(site);
56
- return symbolsResultTotal < 1000000
57
- ? Math.round(symbolsResultTotal / 1000) + 'k' // < 999k => 111k
58
- : Math.round(symbolsResultTotal / 100000) / 10 + 'm'; // > 999k => 1.1m
49
+ hexo.extend.helper.register("symbolsCountTotal", function(site) {
50
+ const symbolsResultTotal = getSymbolsTotal(site);
51
+ return symbolsResultTotal < 1e6 ? Math.round(symbolsResultTotal / 1e3) + "k" : Math.round(symbolsResultTotal / 1e5) / 10 + "m";
59
52
  });
60
- hexo.extend.helper.register('symbolsTimeTotal', function (site, awl = config.awl, wpm = config.wpm, suffix = config.suffix) {
61
- const minutes = Math.round(getSymbolsTotal(site) / (awl * wpm));
62
- return getFormatTime(minutes, suffix);
53
+ hexo.extend.helper.register("symbolsTimeTotal", function(site, awl = config.awl, wpm = config.wpm, suffix = config.suffix) {
54
+ const minutes = Math.round(getSymbolsTotal(site) / (awl * wpm));
55
+ return getFormatTime(minutes, suffix);
63
56
  });
64
- hexo.extend.filter.register('after_post_render', (data) => {
65
- let { content } = data;
66
- if (config.exclude_codeblock)
67
- content = content.replace(/<pre>.*?<\/pre>/g, '');
68
- data.length = (0, hexo_util_1.stripHTML)(content).replace(/\r?\n|\r/g, '').replace(/\s+/g, '').length;
57
+ hexo.extend.filter.register("after_post_render", (data) => {
58
+ let { content } = data;
59
+ if (config.exclude_codeblock) content = content.replace(/<pre>.*?<\/pre>/g, "");
60
+ data.length = (0, import_hexo_util.stripHTML)(content).replace(/\r?\n|\r/g, "").replace(/\s+/g, "").length;
69
61
  }, 0);
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var libtypes_d_exports = {};
15
+ module.exports = __toCommonJS(libtypes_d_exports);
@@ -1,32 +1,31 @@
1
- /* global hexo */
2
1
  let findProblem = false;
3
- hexo.on('generateBefore', function () {
4
- if (hexo.config.syntax_highlighter) {
5
- findProblem = true;
6
- hexo.log.error('[SXEC 101] Highlight.js or Prismjs enabled. The code block will render incomplete');
7
- }
8
- if (!hexo.config.markdown) {
9
- findProblem = true;
10
- hexo.log.error(`[SXEC 102] Critical rendering plugins are missing or incorrectly configured.
2
+ hexo.on("generateBefore", function() {
3
+ if (hexo.config.syntax_highlighter) {
4
+ findProblem = true;
5
+ hexo.log.error("[SXEC 101] Highlight.js or Prismjs enabled. The code block will render incomplete");
6
+ }
7
+ if (!hexo.config.markdown) {
8
+ findProblem = true;
9
+ hexo.log.error(`[SXEC 102] Critical rendering plugins are missing or incorrectly configured.
11
10
  Some features will be disabled or render incorrectly`);
12
- }
13
- if (parseInt(process.version.match(/\d{2,3}/)[0]) < 18) {
14
- findProblem = true;
15
- hexo.log.error('[SXEC 103] Too old Node.js version, install the latest LTS version');
16
- }
17
- if (!hexo.config.title || !hexo.config.description || !hexo.config.language || !hexo.config.timezone || !hexo.config.url) {
18
- findProblem = true;
19
- hexo.log.warn('[SXEC 201] Essential information(title, desc, lang, etc) config incorrectly, Page will render incorrectly');
20
- }
21
- if (hexo.theme.config.gitalk?.clientID || hexo.theme.config.giscus?.repo) {
22
- findProblem = true;
23
- hexo.log.warn('[SXEC 202] You are using an deprecated feature and it was removed in the v0.3.10');
24
- }
11
+ }
12
+ if (parseInt(process.version.match(/\d{2,3}/)[0]) < 18) {
13
+ findProblem = true;
14
+ hexo.log.error("[SXEC 103] Too old Node.js version, install the latest LTS version");
15
+ }
16
+ if (!hexo.config.title || !hexo.config.description || !hexo.config.language || !hexo.config.timezone || !hexo.config.url) {
17
+ findProblem = true;
18
+ hexo.log.warn("[SXEC 201] Essential information(title, desc, lang, etc) config incorrectly, Page will render incorrectly");
19
+ }
20
+ if (hexo.theme.config.gitalk?.clientID || hexo.theme.config.giscus?.repo) {
21
+ findProblem = true;
22
+ hexo.log.warn("[SXEC 202] You are using an deprecated feature and it was removed in the v0.3.10");
23
+ }
25
24
  });
26
- hexo.on('generateAfter', function () {
27
- if (findProblem) {
28
- hexo.log.warn(`The environment check found some problems that can lead to rendering errors, effect errors,
25
+ hexo.on("generateAfter", function() {
26
+ if (findProblem) {
27
+ hexo.log.warn(`The environment check found some problems that can lead to rendering errors, effect errors,
29
28
  performance degradation, not working correctly, etc`);
30
- hexo.log.warn('ShokaX has output them into console, read them to get more information. You can search error code in docs(For example, SXEC 101)');
31
- }
29
+ hexo.log.warn("ShokaX has output them into console, read them to get more information. You can search error code in docs(For example, SXEC 101)");
30
+ }
32
31
  });
@@ -1,81 +1,72 @@
1
- "use strict";
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;
14
+ };
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_injects = __toESM(require("./lib/injects"));
24
+ var import_package = require("../../package.json");
25
+ var fs = __toESM(require("node:fs"));
2
26
  /*!
3
27
  index.js in next-theme/hexo-theme-next by next-theme
4
28
  under GNU AFFERO GENERAL PUBLIC LICENSE v3.0 OR LATER
5
29
  https://github.com/next-theme/hexo-theme-next/blob/master/LICENSE.md
6
30
  */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
- Object.defineProperty(o, "default", { enumerable: true, value: v });
20
- }) : function(o, v) {
21
- o["default"] = v;
22
- });
23
- var __importStar = (this && this.__importStar) || function (mod) {
24
- if (mod && mod.__esModule) return mod;
25
- var result = {};
26
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27
- __setModuleDefault(result, mod);
28
- return result;
29
- };
30
- var __importDefault = (this && this.__importDefault) || function (mod) {
31
- return (mod && mod.__esModule) ? mod : { "default": mod };
32
- };
33
- Object.defineProperty(exports, "__esModule", { value: true });
34
- const injects_1 = __importDefault(require("./lib/injects"));
35
- const package_json_1 = require("../../package.json");
36
- const fs = __importStar(require("node:fs"));
37
- hexo.on('generateBefore', () => {
38
- // 加载`theme_injects`过滤器
39
- (0, injects_1.default)(hexo);
40
- fs.rmSync('./shokaxTemp', { force: true, recursive: true });
41
- if (fs.existsSync('request.lock')) {
42
- fs.unlinkSync('request.lock');
43
- }
44
- if (fs.existsSync('requested.lock')) {
45
- fs.unlinkSync('requested.lock');
46
- }
31
+ hexo.on("generateBefore", () => {
32
+ (0, import_injects.default)(hexo);
33
+ fs.rmSync("./shokaxTemp", { force: true, recursive: true });
34
+ if (fs.existsSync("request.lock")) {
35
+ fs.unlinkSync("request.lock");
36
+ }
37
+ if (fs.existsSync("requested.lock")) {
38
+ fs.unlinkSync("requested.lock");
39
+ }
47
40
  });
48
- hexo.on('generateAfter', () => {
49
- // 检查版本更新
50
- fetch('https://api.shokax.top/version/hexo', { headers: {
51
- "User-Agent": "Mozilla/5.0 ShokaX Client (hexo-theme-shokax)"
52
- } }).then((res) => {
53
- res.json().then((resp) => {
54
- try {
55
- const latest = resp['version'];
56
- const current = package_json_1.version.split('.');
57
- let isOutdated = false;
58
- for (let i = 0; i < Math.max(latest.length, current.length); i++) {
59
- if (!current[i] || latest[i] > current[i]) {
60
- isOutdated = true;
61
- break;
62
- }
63
- if (latest[i] < current[i]) {
64
- break;
65
- }
66
- }
67
- if (isOutdated) {
68
- hexo.log.warn(`Your theme ShokaX is outdated. Current version: v${current.join('.')}, latest version: v${latest.join('.')}`);
69
- hexo.log.warn('Visit https://github.com/theme-shoka-x/hexo-theme-shokaX/releases for more information.');
70
- }
71
- }
72
- catch (e) {
73
- hexo.log.warn('Failed to detect version info. Error message:');
74
- hexo.log.warn(e);
75
- }
76
- }).catch((e) => {
77
- hexo.log.warn('Failed to detect version info. Error message:');
78
- hexo.log.warn(e);
79
- });
41
+ hexo.on("generateAfter", () => {
42
+ fetch("https://api.shokax.top/version/hexo", { headers: {
43
+ "User-Agent": "Mozilla/5.0 ShokaX Client (hexo-theme-shokax)"
44
+ } }).then((res) => {
45
+ res.json().then((resp) => {
46
+ try {
47
+ const latest = resp["version"];
48
+ const current = import_package.version.split(".");
49
+ let isOutdated = false;
50
+ for (let i = 0; i < Math.max(latest.length, current.length); i++) {
51
+ if (!current[i] || latest[i] > current[i]) {
52
+ isOutdated = true;
53
+ break;
54
+ }
55
+ if (latest[i] < current[i]) {
56
+ break;
57
+ }
58
+ }
59
+ if (isOutdated) {
60
+ hexo.log.warn(`Your theme ShokaX is outdated. Current version: v${current.join(".")}, latest version: v${latest.join(".")}`);
61
+ hexo.log.warn("Visit https://github.com/theme-shoka-x/hexo-theme-shokaX/releases for more information.");
62
+ }
63
+ } catch (e) {
64
+ hexo.log.warn("Failed to detect version info. Error message:");
65
+ hexo.log.warn(e);
66
+ }
67
+ }).catch((e) => {
68
+ hexo.log.warn("Failed to detect version info. Error message:");
69
+ hexo.log.warn(e);
80
70
  });
71
+ });
81
72
  });
@@ -1,20 +1,41 @@
1
- 'use strict';
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {
4
- views: [
5
- 'head',
6
- 'sidebar',
7
- 'rightNav',
8
- 'postMeta',
9
- 'postBodyEnd',
10
- 'footer',
11
- 'bodyEnd',
12
- 'comment',
13
- 'status'
14
- ],
15
- styles: [
16
- 'variable',
17
- 'mixin',
18
- 'style'
19
- ]
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var injects_point_exports = {};
20
+ __export(injects_point_exports, {
21
+ default: () => injects_point_default
22
+ });
23
+ module.exports = __toCommonJS(injects_point_exports);
24
+ var injects_point_default = {
25
+ views: [
26
+ "head",
27
+ "sidebar",
28
+ "rightNav",
29
+ "postMeta",
30
+ "postBodyEnd",
31
+ "footer",
32
+ "bodyEnd",
33
+ "comment",
34
+ "status"
35
+ ],
36
+ styles: [
37
+ "variable",
38
+ "mixin",
39
+ "style"
40
+ ]
20
41
  };