hexo-theme-shokax 0.4.6-dev2 → 0.4.6-dev4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. package/package.json +1 -1
  2. package/toolbox/lib.mjs +39 -24
  3. package/scripts/filters/locals.js +0 -52
  4. package/scripts/filters/post.js +0 -5
  5. package/scripts/generaters/archive.js +0 -133
  6. package/scripts/generaters/config.js +0 -51
  7. package/scripts/generaters/images.js +0 -23
  8. package/scripts/generaters/index.js +0 -107
  9. package/scripts/generaters/pages.js +0 -15
  10. package/scripts/generaters/script.js +0 -156
  11. package/scripts/helpers/asset.js +0 -73
  12. package/scripts/helpers/engine.js +0 -177
  13. package/scripts/helpers/list_categories.js +0 -80
  14. package/scripts/helpers/summary_ai.js +0 -107
  15. package/scripts/helpers/symbols_count_time.js +0 -69
  16. package/scripts/plugin/check.js +0 -32
  17. package/scripts/plugin/index.js +0 -81
  18. package/scripts/plugin/lib/injects-point.js +0 -20
  19. package/scripts/plugin/lib/injects.js +0 -89
  20. package/scripts/tags/links.js +0 -44
  21. package/scripts/tags/media.js +0 -19
  22. package/scripts/utils.js +0 -13
  23. package/source/js/_app/components/comments.js +0 -59
  24. package/source/js/_app/components/sidebar.js +0 -244
  25. package/source/js/_app/components/tcomments.js +0 -47
  26. package/source/js/_app/globals/handles.js +0 -105
  27. package/source/js/_app/library/loadFile.js +0 -43
  28. package/source/js/_app/library/vue.js +0 -52
  29. package/source/js/_app/page/common.js +0 -45
  30. package/source/js/_app/page/fancybox.js +0 -70
  31. package/source/js/_app/page/post.js +0 -253
  32. package/source/js/_app/page/search.js +0 -111
  33. package/source/js/_app/pjax/domInit.js +0 -80
  34. package/source/js/_app/pjax/refresh.js +0 -137
  35. package/source/js/_app/pjax/siteInit.js +0 -115
  36. package/source/js/_app/player.js +0 -777
@@ -1,73 +0,0 @@
1
- "use strict";
2
- /* global hexo */
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const package_json_1 = __importDefault(require("../../package.json"));
8
- const hexo_util_1 = require("hexo-util");
9
- const utils_1 = require("../utils");
10
- hexo.extend.helper.register('_safedump', (source) => {
11
- return JSON.stringify(source);
12
- });
13
- hexo.extend.helper.register('hexo_env', function (type) {
14
- return this.env[type];
15
- });
16
- hexo.extend.helper.register('theme_env', function (type) {
17
- return package_json_1.default[type];
18
- });
19
- hexo.extend.helper.register('_vendor_font', () => {
20
- const config = hexo.theme.config.font;
21
- if (!config || !config.enable)
22
- return '';
23
- const fontDisplay = '&display=swap';
24
- const fontSubset = '&subset=latin,latin-ext';
25
- const fontStyles = ':400,400italic,700,700italic';
26
- const fontHost = 'https://fonts.googleapis.com';
27
- // Get a font list from config
28
- let fontFamilies = ['global', 'logo', 'title', 'headings', 'posts', 'codes'].map(item => {
29
- if (config[item] && config[item].family && config[item].external) {
30
- return config[item].family + fontStyles;
31
- }
32
- return '';
33
- });
34
- fontFamilies = fontFamilies.filter(item => item !== '');
35
- // @ts-ignore
36
- fontFamilies = [...new Set(fontFamilies)];
37
- // @ts-ignore
38
- fontFamilies = fontFamilies.join('|');
39
- // Merge extra parameters to the final processed font string
40
- return fontFamilies
41
- ? (0, hexo_util_1.htmlTag)('link', {
42
- rel: 'stylesheet',
43
- href: `${fontHost}/css?family=${fontFamilies.concat(fontDisplay, fontSubset)}`,
44
- media: 'none',
45
- onload: "this.media='all'"
46
- })
47
- : '';
48
- });
49
- hexo.extend.helper.register('_css', function (...urls) {
50
- const { statics, css } = hexo.theme.config;
51
- return urls.map(url => (0, hexo_util_1.htmlTag)('link', {
52
- rel: 'stylesheet',
53
- href: hexo_util_1.url_for.call(this, `${statics}${css}/${url}?v=${package_json_1.default.version}`)
54
- }), '').join('');
55
- });
56
- hexo.extend.helper.register('_js', function (...urls) {
57
- const { statics, js } = hexo.theme.config;
58
- return urls.map(url => (0, hexo_util_1.htmlTag)('script', { src: hexo_util_1.url_for.call(this, `${statics}${js}/${url}?v=${package_json_1.default.version}`), type: 'module', fetchpriority: 'high', defer: true }, '')).join('');
59
- });
60
- hexo.extend.helper.register('vendor_js', function () {
61
- const vendors = hexo.theme.config.vendors;
62
- let res = '';
63
- for (const jsSync in vendors.js) {
64
- res += (0, hexo_util_1.htmlTag)('script', { src: (0, utils_1.getVendorLink)(hexo, vendors.js[jsSync]), async: true }, '');
65
- }
66
- return res;
67
- });
68
- hexo.extend.helper.register('_striptags', function (data) {
69
- return (0, hexo_util_1.stripHTML)(data);
70
- });
71
- hexo.extend.helper.register('_truncate', function (data, end) {
72
- return data.substring(0, end);
73
- });
@@ -1,177 +0,0 @@
1
- 'use strict';
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- // @ts-ignore
7
- const hexo_util_1 = require("hexo-util");
8
- const node_fs_1 = __importDefault(require("node:fs"));
9
- const randomServer = parseInt(String(Math.random() * 4), 10) + 1;
10
- const randomBG = function (count = 1, image_server = null, image_list = []) {
11
- let i;
12
- if (image_server) {
13
- if (count && count > 1) {
14
- const arr = new Array(count);
15
- for (i = 0; i < arr.length; i++) {
16
- arr[i] = image_server + '?' + Math.floor(Math.random() * 999999);
17
- }
18
- return arr;
19
- }
20
- return image_server + '?' + Math.floor(Math.random() * 999999);
21
- }
22
- const parseImage = function (img, size) {
23
- if (img.startsWith('//') || img.startsWith('http')) {
24
- return img;
25
- }
26
- else if (hexo.theme.config.experiments?.usingRelative) { // support relative url
27
- return img;
28
- }
29
- else {
30
- console.warn("sinaimg blocked all request from outside website,so don't use this format");
31
- return `https://tva${randomServer}.sinaimg.cn/` + size + '/' + img;
32
- }
33
- };
34
- if (count && count > 1) {
35
- let shuffled = image_list.slice(0);
36
- while (shuffled.length <= 6) {
37
- shuffled = shuffled.concat(image_list.slice(0));
38
- }
39
- i = shuffled.length;
40
- const min = i - count;
41
- let temp;
42
- let index;
43
- while (i-- > min) {
44
- index = Math.floor((i + 1) * Math.random());
45
- temp = shuffled[index];
46
- shuffled[index] = shuffled[i];
47
- shuffled[i] = temp;
48
- }
49
- return shuffled.slice(min).map(function (img) {
50
- return parseImage(img, 'large');
51
- });
52
- }
53
- return parseImage(image_list[Math.floor(Math.random() * image_list.length)], 'mw690');
54
- };
55
- hexo.extend.helper.register('preloadjs', function () {
56
- const { statics, js } = hexo.theme.config;
57
- let res = '';
58
- node_fs_1.default.readdirSync('./shokaxTemp').forEach((file) => {
59
- if (file.endsWith('.js')) {
60
- res += (0, hexo_util_1.htmlTag)('link', { rel: 'modulepreload', href: hexo_util_1.url_for.call(this, `${statics}${js}/${file}`) }, '');
61
- }
62
- });
63
- return res;
64
- });
65
- hexo.extend.helper.register('load_async_css', function () {
66
- const { statics, css } = hexo.theme.config;
67
- let res = '';
68
- node_fs_1.default.readdirSync('./shokaxTemp').forEach((file) => {
69
- if (file.endsWith('.css')) {
70
- res += (0, hexo_util_1.htmlTag)('link', { rel: 'stylesheet', href: hexo_util_1.url_for.call(this, `${statics}${css}/${file}`), media: 'none', onload: "this.media='all'" }, '');
71
- }
72
- });
73
- return res;
74
- });
75
- // 注册hexo主题中的URL帮助方法
76
- hexo.extend.helper.register('_url', function (path, text, options = {}) {
77
- // 如果未提供URL路径,则返回
78
- if (!path) {
79
- return;
80
- }
81
- let tag = 'a';
82
- let attrs = { href: hexo_util_1.url_for.call(this, path), class: undefined, external: undefined, rel: undefined, 'data-url': undefined };
83
- for (const key in options) {
84
- attrs[key] = options[key];
85
- }
86
- if (attrs.class && Array.isArray(attrs.class)) {
87
- attrs.class = attrs.class.join(' ');
88
- }
89
- // 返回HTML标记字符串
90
- return (0, hexo_util_1.htmlTag)(tag, attrs, decodeURI(text), false);
91
- });
92
- hexo.extend.helper.register('_image_url', function (img, path = '') {
93
- const { statics } = hexo.theme.config;
94
- const { post_asset_folder } = hexo.config;
95
- if (img.startsWith('//') || img.startsWith('http')) {
96
- return img;
97
- }
98
- else {
99
- return hexo_util_1.url_for.call(this, statics + (post_asset_folder ? path : '') + img);
100
- }
101
- });
102
- hexo.extend.helper.register('_cover', function (item, num) {
103
- const { image_server, image_list } = hexo.theme.config;
104
- if (item.cover) {
105
- return this._image_url(item.cover, item.path);
106
- }
107
- else if (item.photos && item.photos.length > 0) {
108
- return this._image_url(item.photos[0], item.path);
109
- }
110
- else {
111
- return randomBG(num || 1, image_server, image_list);
112
- }
113
- });
114
- hexo.extend.helper.register('_cover_index', function (item) {
115
- const { index_images, image_list, image_server } = hexo.theme.config;
116
- if (item.cover) {
117
- return this._image_url(item.cover, item.path);
118
- }
119
- else if (item.photos && item.photos.length > 0) {
120
- return this._image_url(item.photos[0], item.path);
121
- }
122
- else {
123
- return randomBG(6, image_server, index_images.length === 0 ? image_list : index_images);
124
- }
125
- });
126
- // 注册hexo主题的永久链接帮助方法
127
- hexo.extend.helper.register('_permapath', function (str) {
128
- // 获取hexo的永久链接配置
129
- const { permalink } = hexo.config;
130
- // 将输入字符串中的'index.html'替换为空字符串
131
- let url = str.replace(/index\.html$/, '');
132
- // 如果永久链接不以'.html'结尾,将输入字符串中的'.html'替换为空字符串
133
- if (!permalink.endsWith('.html')) {
134
- url = url.replace(/\.html$/, '');
135
- }
136
- // 返回处理后的URL字符串
137
- return url;
138
- });
139
- hexo.extend.helper.register('canonical', function () {
140
- return `<link rel="canonical" href="${this._permapath(this.url)}">`;
141
- });
142
- /**
143
- * Get page path given a certain language tag
144
- */
145
- // 注册hexo主题的国际化路径帮助方法
146
- hexo.extend.helper.register('i18n_path', function (language) {
147
- // 获取当前页面的path和lang
148
- const { path, lang } = this.page;
149
- // 如果path以lang开头,则截取掉lang部分,作为基础路径
150
- const base = path.startsWith(lang) ? path.slice(lang.length + 1) : path;
151
- // 通过调用url_for方法,生成国际化路径
152
- return hexo_util_1.url_for.call(this, `${this.languages.indexOf(language) === 0 ? '' : '/' + language}/${base}`);
153
- });
154
- /**
155
- * Get the language name
156
- */
157
- // 注册hexo主题的语言名称帮助方法
158
- hexo.extend.helper.register('language_name', function (language) {
159
- // 从主题配置中获取指定语言的名称
160
- // @ts-ignore
161
- const name = hexo.theme.i18n.__(language)('name');
162
- // 如果名称为默认值'name',则返回语言代码,否则返回语言名称
163
- return name === 'name' ? language : name;
164
- });
165
- hexo.extend.helper.register('random_color', function () {
166
- const arr = [];
167
- for (let i = 0; i < 3; i++) {
168
- arr.push(Math.floor(Math.random() * 128 + 128));
169
- }
170
- const [r, g, b] = arr;
171
- 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)}`;
172
- });
173
- hexo.extend.helper.register('shokax_inject', function (point) {
174
- return hexo.theme.config.injects[point]
175
- .map(item => this.partial(item.layout, item.locals, item.options))
176
- .join('');
177
- });
@@ -1,80 +0,0 @@
1
- const prepareQuery = (categories, parent) => {
2
- const query = {
3
- parent: undefined
4
- };
5
- if (parent) {
6
- query.parent = parent;
7
- }
8
- else {
9
- query.parent = { $exists: false };
10
- }
11
- return categories.find(query).sort('name', 1).filter(cat => cat.length);
12
- };
13
- hexo.extend.helper.register('_list_categories', function (depth = 0) {
14
- const categories = this.site.categories;
15
- if (!categories || !categories.length)
16
- return '';
17
- const hierarchicalList = (level, parent) => {
18
- let result = '';
19
- prepareQuery(categories, parent).forEach((cat, i) => {
20
- let child;
21
- if (level + 1 < depth) {
22
- child = hierarchicalList(level + 1, cat._id);
23
- }
24
- const catname = `<a itemprop="url" href="${this.url_for(cat.path)}">${cat.name}</a><small>( ${cat.length} )</small>`;
25
- switch (level) {
26
- case 0:
27
- result += `<div><h2 class="item header">${catname}</h2>`;
28
- break;
29
- case 1:
30
- result += `<h3 class="item section">${catname}</h3>`;
31
- break;
32
- case 2:
33
- result += `<div class="item normal"><div class="title">${catname}</div></div>`;
34
- break;
35
- }
36
- if (child) {
37
- result += `${child}`;
38
- }
39
- if (level === 0) {
40
- result += '</div>';
41
- }
42
- });
43
- return result;
44
- };
45
- return hierarchicalList(0);
46
- });
47
- hexo.extend.helper.register('_category_prev', function (name) {
48
- const categories = this.site.categories;
49
- if (!categories || !categories.length)
50
- return '';
51
- let result = '';
52
- categories.find({ name }).forEach((current) => {
53
- if (current.parent) {
54
- categories.find({ _id: current.parent }).forEach((cat, i) => {
55
- result += `<a href="${this.url_for(cat.path)}">${cat.name}</a>`;
56
- });
57
- }
58
- });
59
- return result;
60
- });
61
- hexo.extend.helper.register('_category_posts', function (page) {
62
- // let hexo = this
63
- const categories = this.site.categories;
64
- if (!categories || !categories.length || !page.categories || !page.categories.length)
65
- return '';
66
- let result = '';
67
- const cat = page.categories.toArray();
68
- categories.find({ _id: cat[cat.length - 1]._id }).forEach((category) => {
69
- if (category.posts) {
70
- category.posts.sort('date', 1).forEach((post) => {
71
- let current = '';
72
- if (post.path === page.path) {
73
- current = ' class="active"';
74
- }
75
- result += `<li ${current}><a href="${this.url_for(post.path)}" rel="bookmark" title="${post.title}">${post.title}</a></li>`;
76
- });
77
- }
78
- });
79
- return result;
80
- });
@@ -1,107 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_fs_1 = __importDefault(require("node:fs"));
7
- function getContent(post) {
8
- return post?.raw ?? post?._content ?? post.content;
9
- }
10
- let db;
11
- 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' }));
15
- }
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] = '';
30
- }
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);
95
- }
96
- }
97
- else {
98
- // custom尚未支持
99
- }
100
- }
101
- }
102
- hexo.extend.helper.register('get_summary', (post) => {
103
- return postMessage(post.path, getContent(post), 'summary', '请为下述文章提供一份200字以内的概括,使用中文回答且尽可能简洁: ');
104
- });
105
- hexo.extend.helper.register('get_introduce', () => {
106
- return hexo.theme.config.summary.introduce;
107
- });
@@ -1,69 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /* global hexo */
4
- /*!
5
- hexo-symbols-count-time by theme-next
6
- under GNU Lesser General Public License v3.0 or later
7
- https://github.com/theme-next/hexo-symbols-count-time/blob/master/LICENSE
8
- */
9
- const hexo_util_1 = require("hexo-util");
10
- 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.'
19
- }, hexo.config.symbols_count_time);
20
- function getSymbols(post) {
21
- return post?._content?.length ?? post?.content?.length ?? post.length;
22
- }
23
- function getSymbolsTotal(site) {
24
- let symbolsResultCount = 0;
25
- site.posts.forEach((post) => {
26
- symbolsResultCount += getSymbols(post);
27
- });
28
- return symbolsResultCount;
29
- }
30
- 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
39
- }
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;
49
- });
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);
53
- });
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
59
- });
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);
63
- });
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;
69
- }, 0);
@@ -1,32 +0,0 @@
1
- /* global hexo */
2
- 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.
11
- 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
- }
25
- });
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,
29
- 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
- }
32
- });
@@ -1,81 +0,0 @@
1
- "use strict";
2
- /*!
3
- index.js in next-theme/hexo-theme-next by next-theme
4
- under GNU AFFERO GENERAL PUBLIC LICENSE v3.0 OR LATER
5
- https://github.com/next-theme/hexo-theme-next/blob/master/LICENSE.md
6
- */
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
- }
47
- });
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
- });
80
- });
81
- });
@@ -1,20 +0,0 @@
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
- ]
20
- };