hexo-theme-shokax 0.3.11 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- package/_config.yml +21 -52
- package/layout/_mixin/comment.pug +1 -1
- package/layout/_partials/head/head.pug +2 -7
- package/layout/_partials/layout.pug +5 -5
- package/package.json +13 -19
- package/scripts/generaters/script.js +13 -12
- package/scripts/helpers/asset.js +19 -82
- package/scripts/plugin/index.js +11 -22
- package/scripts/utils.js +14 -0
- package/source/js/_app/library/loadFile.js +3 -3
- package/source/js/_app/page/fancybox.js +1 -0
- package/source/js/_app/pjax/refresh.js +0 -1
package/_config.yml
CHANGED
@@ -348,58 +348,27 @@ quicklink:
|
|
348
348
|
#! DO NOT EDIT THE FOLLOWING `vendors` SETTINGS
|
349
349
|
#! UNLESS YOU KNOW WHAT YOU ARE DOING
|
350
350
|
#! ---------------------------------------------------------------
|
351
|
-
advVendors:
|
352
|
-
enable: true
|
353
|
-
github: "https://cdn.jsdelivr.net/gh/"
|
354
|
-
combine: "https://cdn.jsdelivr.net/"
|
355
|
-
npm: "https://unpkg.com/"
|
356
|
-
js:
|
357
|
-
pace:
|
358
|
-
src: bytedance:pace/1.0.2/pace.min.js
|
359
|
-
fetch:
|
360
|
-
src: npm:whatwg-fetch@3.4.0/dist/fetch.umd.js
|
361
|
-
algolia:
|
362
|
-
src: bytedance:algoliasearch/4.12.1/algoliasearch-lite.umd.min.js
|
363
|
-
instantsearch:
|
364
|
-
src: bytedance:instantsearch.js/4.39.0/instantsearch.production.min.js
|
365
|
-
quicklink:
|
366
|
-
src: bytedance:quicklink/2.2.0/quicklink.umd.min.js
|
367
|
-
fancybox:
|
368
|
-
src: bytedance:??jquery/3.5.1/jquery.min.js,fancybox/3.5.7/jquery.fancybox.min.js,justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js
|
369
|
-
async: true
|
370
|
-
copy_tex:
|
371
|
-
src: bytedance:KaTeX/0.15.2/contrib/copy-tex.min.js
|
372
|
-
async: true
|
373
|
-
css:
|
374
|
-
katex:
|
375
|
-
src: npm:katex@0.16.7/dist/katex.min.css
|
376
|
-
comment:
|
377
|
-
src: css/comment.css
|
378
|
-
fancybox:
|
379
|
-
src: combine:npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css,npm/justifiedGallery@3.8.1/dist/css/justifiedGallery.min.css
|
380
|
-
vendorsList:
|
381
|
-
js:
|
382
|
-
- pace
|
383
|
-
- algolia
|
384
|
-
- instantsearch
|
385
|
-
- quicklink
|
386
|
-
- fancybox
|
387
|
-
- copy_tex
|
388
|
-
|
389
351
|
vendors:
|
352
|
+
cdns:
|
353
|
+
npm_webcache: https://npm.webcache.cn
|
354
|
+
bytedance: https://lf9-cdn-tos.bytecdntp.com/cdn/expire-6-M
|
355
|
+
cdnjs_webcache: https://cdnjs.webstatic.cn/ajax/libs
|
356
|
+
cdnjs: https://cdnjs.cloudflare.com/ajax/libs
|
357
|
+
unpkg: https://unpkg.com
|
358
|
+
js:
|
359
|
+
pace: bytedance|pace/1.2.4/pace.min.js
|
360
|
+
# pjax: npm_webcache|theme-shokax-pjax@0.0.3/pjax.shokax.min.js
|
361
|
+
# anime: npm_webcache|theme-shokax-anime@0.0.6/anime.shokax.min.js
|
362
|
+
# lozad: npm_webcache|lozad@1.16.0/dist/lozad.min.js
|
363
|
+
algolia: bytedance|algoliasearch/4.12.1/algoliasearch-lite.umd.min.js
|
364
|
+
instantsearch: bytedance|instantsearch.js/4.39.0/instantsearch.production.min.js
|
365
|
+
quicklink: npm_webcache|quicklink@2.3.0/dist/quicklink.umd.js
|
366
|
+
# mouse_firework: npm_webcache|mouse-firework@0.0.4/dist/index.umd.js
|
367
|
+
async_js:
|
368
|
+
fancybox: bytedance|??jquery/3.5.1/jquery.min.js,fancybox/3.5.7/jquery.fancybox.min.js,justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js
|
369
|
+
copy_tex: npm_webcache|katex@0.16.7/contrib/copy-tex.min.js
|
390
370
|
css:
|
391
|
-
katex:
|
371
|
+
katex: npm_webcache|katex@0.16.7/dist/katex.min.css
|
392
372
|
comment: css/comment.css
|
393
|
-
fancybox:
|
394
|
-
|
395
|
-
js:
|
396
|
-
pace: npm/pace-js@1.0.2/pace.min.js # ok
|
397
|
-
fetch: npm/whatwg-fetch@3.4.0/dist/fetch.umd.min.js # ok
|
398
|
-
algolia: npm/algoliasearch@4/dist/algoliasearch-lite.umd.js # ok
|
399
|
-
instantsearch: npm/instantsearch.js@4/dist/instantsearch.production.min.js # ok
|
400
|
-
quicklink: npm/quicklink@2/dist/quicklink.umd.js # ok
|
401
|
-
fancybox: combine/npm/jquery@3.5.1/dist/jquery.min.js,npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js,npm/justifiedGallery@3.8.1/dist/js/jquery.justifiedGallery.min.js # notok
|
402
|
-
# valine: gh/amehime/MiniValine@4.2.2-beta10/dist/MiniValine.min.js # TODO 弃用
|
403
|
-
copy_tex: npm/katex@0.16.7/dist/contrib/copy-tex.min.js # ok
|
404
|
-
chart: npm/frappe-charts@1.5.0/dist/frappe-charts.min.iife.min.js # ok
|
405
|
-
|
373
|
+
fancybox: npm_webcache|@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css
|
374
|
+
justifiedGallery: npm_webcache|justifiedGallery@3.8.1/dist/css/justifiedGallery.min.css
|
@@ -19,7 +19,7 @@ mixin CommentRender()
|
|
19
19
|
- var meta = JSON.stringify(theme.waline.meta)
|
20
20
|
- var requiredMeta = JSON.stringify(theme.waline.requiredMeta)
|
21
21
|
script(type="module" data-pjax).
|
22
|
-
import { init } from 'https://
|
22
|
+
import { init } from 'https://npm.webcache.cn/@waline/client@v2/dist/waline.mjs';
|
23
23
|
|
24
24
|
setTimeout(function () {
|
25
25
|
init({
|
@@ -43,17 +43,12 @@ if fontConfig
|
|
43
43
|
!= _vendor_font()
|
44
44
|
!= _css('app.css')
|
45
45
|
|
46
|
-
- var debugVue = theme?.experiments?.debug
|
47
|
-
if debugVue
|
48
|
-
script(src="https://cdn.staticfile.org/vue/3.2.45/vue.global.js")
|
49
|
-
else
|
50
|
-
script(src="https://cdn.staticfile.org/vue/3.2.45/vue.global.prod.js")
|
51
46
|
include pwa.pug
|
52
47
|
if tk
|
53
48
|
!= _css("twikoo.css")
|
54
|
-
script(src=theme.twikoo.link)
|
49
|
+
script(src=theme.twikoo.link )
|
55
50
|
else if wl
|
56
|
-
link(rel="stylesheet" href="https://
|
51
|
+
link(rel="stylesheet" href="https://npm.webcache.cn/@waline/client@v2/dist/waline.css" media="none" onload="this.media='all'")
|
57
52
|
|
58
53
|
- var qw = theme?.qweather?.enable
|
59
54
|
if qw
|
@@ -92,7 +92,6 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
92
92
|
empty: "!{__('search.empty')}",
|
93
93
|
stats: "!{__('search.stats')}"
|
94
94
|
},
|
95
|
-
chart: #{!!page.chart},
|
96
95
|
copy_tex: #{!!page.math},
|
97
96
|
katex: #{!!page.math},
|
98
97
|
mermaid: #{!!page.mermaid},
|
@@ -119,11 +118,12 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
119
118
|
if theme.polyfill.enable
|
120
119
|
script(src=`https://polyfill.io/v3/polyfill.min.js?features=${theme.polyfill.features}`)
|
121
120
|
|
122
|
-
|
123
|
-
|
124
|
-
|
121
|
+
- debugVue = theme?.experiments?.debug
|
122
|
+
if debugVue
|
123
|
+
script(src="https://cdn.bootcdn.net/ajax/libs/vue/3.3.4/vue.global.min.js")
|
125
124
|
else
|
126
|
-
|
125
|
+
script(src="https://cdn.bootcdn.net/ajax/libs/vue/3.3.4/vue.global.prod.min.js")
|
126
|
+
!= vendor_js()
|
127
127
|
!= _js('app.js')
|
128
128
|
!= partial('_partials/third-party/baidu-analytics.pug', {}, {cache: true})
|
129
129
|
!= partial('_partials/third-party/clarity.pug', {}, {cache: true})
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hexo-theme-shokax",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.12",
|
4
4
|
"description": "a hexo theme based on shoka",
|
5
5
|
"main": "index.js",
|
6
6
|
"repository": "https://github.com/theme-shoka-x/hexo-theme-shokaX",
|
@@ -11,38 +11,32 @@
|
|
11
11
|
"build": "cd ./source && tsc --build --verbose && cd ../scripts && tsc --build --verbose"
|
12
12
|
},
|
13
13
|
"devDependencies": {
|
14
|
-
"@types/chai": "^4.3.11",
|
15
14
|
"@types/fancybox": "^3.5.6",
|
16
|
-
"@types/hexo": "^3.8.12",
|
17
15
|
"@types/jquery": "^3.5.29",
|
18
16
|
"@types/js-yaml": "^4.0.9",
|
19
17
|
"@types/lozad": "^1.16.4",
|
20
|
-
"@types/
|
21
|
-
"@
|
22
|
-
"@typescript-eslint/
|
23
|
-
"@typescript-eslint/parser": "^6.18.0",
|
24
|
-
"chai": "^5.0.0",
|
18
|
+
"@types/node": "^20.11.5",
|
19
|
+
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
20
|
+
"@typescript-eslint/parser": "^6.19.0",
|
25
21
|
"eslint": "^8.56.0",
|
26
22
|
"eslint-config-standard": "~17",
|
27
|
-
"eslint-plugin-chai-friendly": "^0.7.2",
|
28
23
|
"eslint-plugin-import": "^2.29.1",
|
29
|
-
"eslint-plugin-n": "^16.6.
|
24
|
+
"eslint-plugin-n": "^16.6.2",
|
30
25
|
"eslint-plugin-promise": "^6.1.1",
|
31
|
-
"eslint-plugin-vue": "^9.
|
32
|
-
"
|
33
|
-
"hexo-util": "^3.1.0",
|
34
|
-
"instantsearch.js": "^4.63.0",
|
35
|
-
"jsdom": "^23.1.0",
|
36
|
-
"mocha": "^10.2.0",
|
26
|
+
"eslint-plugin-vue": "^9.20.1",
|
27
|
+
"instantsearch.js": "^4.64.0",
|
37
28
|
"typescript": "^5.3.3",
|
38
|
-
"vue": "^3.4.
|
29
|
+
"vue": "^3.4.15"
|
39
30
|
},
|
40
31
|
"dependencies": {
|
41
32
|
"esbuild": "^0.19.11",
|
42
|
-
"hexo": "
|
33
|
+
"hexo": "7.0.0",
|
34
|
+
"hexo-fs": "^4.1.1",
|
35
|
+
"hexo-pagination": "^3.0.0",
|
36
|
+
"hexo-util": "^3.2.0",
|
43
37
|
"js-yaml": "^4.1.0",
|
44
38
|
"lozad": "^1.16.0",
|
45
|
-
"mouse-firework": "^0.0.
|
39
|
+
"mouse-firework": "^0.0.4",
|
46
40
|
"theme-shokax-anime": "^0.0.6",
|
47
41
|
"theme-shokax-pjax": "^0.0.3"
|
48
42
|
},
|
@@ -22,19 +22,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
22
|
__setModuleDefault(result, mod);
|
23
23
|
return result;
|
24
24
|
};
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
+
};
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
29
|
/* global hexo */
|
27
|
-
|
30
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
28
31
|
const fs = __importStar(require("hexo-fs"));
|
29
32
|
const esbuild_1 = require("esbuild");
|
30
|
-
const
|
31
|
-
version: '0.3.10'
|
32
|
-
};
|
33
|
+
const utils_1 = require("../utils");
|
33
34
|
hexo.extend.generator.register('script', function (locals) {
|
34
35
|
const config = hexo.config;
|
35
36
|
const theme = hexo.theme.config;
|
36
37
|
const siteConfig = {
|
37
|
-
version:
|
38
|
+
version: package_json_1.default.version,
|
38
39
|
hostname: config.url,
|
39
40
|
root: config.root,
|
40
41
|
statics: theme.statics,
|
@@ -46,15 +47,14 @@ hexo.extend.generator.register('script', function (locals) {
|
|
46
47
|
auto_dark: theme.auto_dark,
|
47
48
|
auto_scroll: theme.auto_scroll,
|
48
49
|
js: {
|
49
|
-
|
50
|
-
|
51
|
-
fancybox: theme.vendors.js.fancybox
|
50
|
+
copy_tex: (0, utils_1.getVendorLink)(hexo, theme.vendors.async_js.copy_tex),
|
51
|
+
fancybox: (0, utils_1.getVendorLink)(hexo, theme.vendors.async_js.fancybox)
|
52
52
|
},
|
53
53
|
css: {
|
54
|
-
|
55
|
-
katex: theme.vendors.css.katex,
|
54
|
+
katex: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.katex),
|
56
55
|
mermaid: theme.css + '/mermaid.css',
|
57
|
-
fancybox: theme.vendors.css.fancybox
|
56
|
+
fancybox: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.fancybox),
|
57
|
+
justifiedGallery: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.justifiedGallery)
|
58
58
|
},
|
59
59
|
loader: theme.loader,
|
60
60
|
search: null,
|
@@ -99,7 +99,8 @@ hexo.extend.generator.register('script', function (locals) {
|
|
99
99
|
bundle: true,
|
100
100
|
outfile: 'shokax_temp.js',
|
101
101
|
platform: 'browser',
|
102
|
-
|
102
|
+
format: 'iife',
|
103
|
+
target: ['es2022'],
|
103
104
|
minify: true
|
104
105
|
});
|
105
106
|
text += fs.readFileSync('shokax_temp.js');
|
package/scripts/helpers/asset.js
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
/* global hexo */
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
5
|
+
};
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
|
7
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
5
8
|
const hexo_util_1 = require("hexo-util");
|
6
|
-
const
|
7
|
-
version: '0.3.10'
|
8
|
-
};
|
9
|
+
const utils_1 = require("../utils");
|
9
10
|
hexo.extend.helper.register('_new_comments', function (mode) {
|
10
11
|
const root = this.config.url.replace(/^(https?:\/\/)?[^\/]*/, '');
|
11
12
|
if (mode === 'twikoo') {
|
@@ -45,14 +46,14 @@ hexo.extend.helper.register('_new_comments', function (mode) {
|
|
45
46
|
return `
|
46
47
|
<script type="module" data-pjax>
|
47
48
|
let items = []
|
48
|
-
import { RecentComments } from 'https://
|
49
|
+
import { RecentComments } from 'https://npm.webcache.cn/@waline/client@v2/dist/waline.mjs'
|
49
50
|
RecentComments({
|
50
51
|
serverURL: '${hexo.theme.config.waline.serverURL.replace(/\/+$/, '')}',
|
51
52
|
count: 10,
|
52
53
|
}).then(({ comments }) => {
|
53
54
|
comments.forEach(function (item) {
|
54
55
|
let cText = (item.orig.length > 50) ? item.orig.substring(0,50)+'...' : item.orig
|
55
|
-
item.url = item.url
|
56
|
+
item.url = item.url.startsWith('/') ? item.url : '/' + item.url;
|
56
57
|
const siteLink = item.url + "#" + item.objectId
|
57
58
|
items.push({
|
58
59
|
href: siteLink,
|
@@ -86,7 +87,7 @@ hexo.extend.helper.register('hexo_env', function (type) {
|
|
86
87
|
return this.env[type];
|
87
88
|
});
|
88
89
|
hexo.extend.helper.register('theme_env', function (type) {
|
89
|
-
return
|
90
|
+
return package_json_1.default[type];
|
90
91
|
});
|
91
92
|
hexo.extend.helper.register('_vendor_font', () => {
|
92
93
|
const config = hexo.theme.config.font;
|
@@ -116,91 +117,27 @@ hexo.extend.helper.register('_vendor_font', () => {
|
|
116
117
|
})
|
117
118
|
: '';
|
118
119
|
});
|
119
|
-
// TODO 废弃方法
|
120
|
-
hexo.extend.helper.register('_vendor_js', () => {
|
121
|
-
const config = hexo.theme.config.vendors.js;
|
122
|
-
if (!config)
|
123
|
-
return '';
|
124
|
-
// Get a font list from config
|
125
|
-
let vendorJs = ['pace', 'pjax', 'fetch', 'anime', 'algolia', 'instantsearch', 'lazyload', 'quicklink'].map(item => {
|
126
|
-
if (config[item]) {
|
127
|
-
return config[item];
|
128
|
-
}
|
129
|
-
return '';
|
130
|
-
});
|
131
|
-
vendorJs = vendorJs.filter(item => item !== '');
|
132
|
-
// @ts-ignore
|
133
|
-
vendorJs = [...new Set(vendorJs)];
|
134
|
-
// @ts-ignore
|
135
|
-
vendorJs = vendorJs.join(',');
|
136
|
-
return vendorJs ? (0, hexo_util_1.htmlTag)('script', { src: `https://cdn.jsdelivr.net/combine/${vendorJs}` }, '') : '';
|
137
|
-
});
|
138
120
|
hexo.extend.helper.register('_css', function (...urls) {
|
139
121
|
const { statics, css } = hexo.theme.config;
|
140
122
|
return urls.map(url => (0, hexo_util_1.htmlTag)('link', {
|
141
123
|
rel: 'stylesheet',
|
142
|
-
href: hexo_util_1.url_for.call(this, `${statics}${css}/${url}?v=${
|
124
|
+
href: hexo_util_1.url_for.call(this, `${statics}${css}/${url}?v=${package_json_1.default.version}`)
|
143
125
|
})).join('');
|
144
126
|
});
|
145
127
|
hexo.extend.helper.register('_js', function (...urls) {
|
146
128
|
const { statics, js } = hexo.theme.config;
|
147
|
-
return urls.map(url => (0, hexo_util_1.htmlTag)('script', { src: hexo_util_1.url_for.call(this, `${statics}${js}/${url}?v=${
|
129
|
+
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}`) }, '')).join('');
|
148
130
|
});
|
149
|
-
hexo.extend.helper.register('
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
const config = hexo.theme.config.advVendors.js[js_name];
|
155
|
-
const themeConfig = hexo.theme.config;
|
156
|
-
const src = config.src;
|
157
|
-
const publicCdns = {
|
158
|
-
npm: srcHelpers(themeConfig.advVendors.npm),
|
159
|
-
gh: srcHelpers(themeConfig.advVendors.github),
|
160
|
-
combine: srcHelpers(themeConfig.advVendors.combine),
|
161
|
-
bytedance: 'https://lf9-cdn-tos.bytecdntp.com/cdn/expire-6-M/',
|
162
|
-
baomitu: 'https://lib.baomitu.com/'
|
163
|
-
};
|
164
|
-
let result;
|
165
|
-
if (src.startsWith('http')) {
|
166
|
-
result = src;
|
167
|
-
}
|
168
|
-
else if (src.startsWith('combine:')) {
|
169
|
-
hexo.log.info('The combine feature is not recommended!');
|
170
|
-
result = publicCdns.combine + src;
|
171
|
-
}
|
172
|
-
else if (src.startsWith('npm:')) {
|
173
|
-
result = publicCdns.npm + src.substring(4);
|
174
|
-
}
|
175
|
-
else if (src.startsWith('gh:')) {
|
176
|
-
result = publicCdns.gh + src.substring(3);
|
177
|
-
}
|
178
|
-
else if (src.startsWith('bytedance:')) {
|
179
|
-
result = publicCdns.bytedance + src.substring(10);
|
180
|
-
}
|
181
|
-
else if (src.startsWith('baomitu:')) {
|
182
|
-
result = publicCdns.baomitu + src.substring(8);
|
183
|
-
}
|
184
|
-
else {
|
185
|
-
result = '/' + src;
|
186
|
-
}
|
187
|
-
const attr = {
|
188
|
-
src: result,
|
189
|
-
integrity: undefined,
|
190
|
-
async: undefined
|
191
|
-
};
|
192
|
-
if (config.async)
|
193
|
-
attr.async = 'async';
|
194
|
-
if (config['data-pjax'])
|
195
|
-
attr['data-pjax'] = 'data-pjax';
|
196
|
-
if (config['hash-value'])
|
197
|
-
attr.integrity = config['hash-value'];
|
198
|
-
if (config.deferLoad) {
|
199
|
-
return (0, hexo_util_1.htmlTag)('script', { 'data-pjax': true }, `
|
200
|
-
const script=document.createElement("script");script.src="${result}",script.async=true,document.body.appendChild(script)
|
201
|
-
`);
|
131
|
+
hexo.extend.helper.register('vendor_js', function () {
|
132
|
+
const vendors = hexo.theme.config.vendors;
|
133
|
+
let res = '';
|
134
|
+
for (const jsSync in vendors.js) {
|
135
|
+
res += (0, hexo_util_1.htmlTag)('script', { src: (0, utils_1.getVendorLink)(hexo, vendors.js[jsSync]) }, '');
|
202
136
|
}
|
203
|
-
|
137
|
+
// for (const jsAsync in vendors.async_js) {
|
138
|
+
// res += htmlTag('script', { src: getVendorLink(hexo, vendors.async_js[jsAsync]), async: true }, '')
|
139
|
+
// }
|
140
|
+
return res;
|
204
141
|
});
|
205
142
|
hexo.extend.helper.register('_striptags', function (data) {
|
206
143
|
return (0, hexo_util_1.stripHTML)(data);
|
package/scripts/plugin/index.js
CHANGED
@@ -32,11 +32,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
32
|
};
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
34
34
|
const injects_1 = __importDefault(require("./lib/injects"));
|
35
|
-
const
|
36
|
-
// @ts-ignore
|
37
|
-
// import { version } from '../../package.json'
|
35
|
+
const package_json_1 = require("../../package.json");
|
38
36
|
const fs = __importStar(require("node:fs"));
|
39
|
-
const version = '0.3.10';
|
40
37
|
hexo.on('generateBefore', () => {
|
41
38
|
// 加载`theme_injects`过滤器
|
42
39
|
(0, injects_1.default)(hexo);
|
@@ -49,19 +46,11 @@ hexo.on('generateBefore', () => {
|
|
49
46
|
});
|
50
47
|
hexo.on('generateAfter', () => {
|
51
48
|
// 检查版本更新
|
52
|
-
(
|
53
|
-
|
54
|
-
'User-Agent': 'Theme ShokaX Client'
|
55
|
-
}
|
56
|
-
}, (res) => {
|
57
|
-
let result = '';
|
58
|
-
res.on('data', (data) => {
|
59
|
-
result += data;
|
60
|
-
});
|
61
|
-
res.on('end', () => {
|
49
|
+
fetch('https://api.github.com/repos/theme-shoka-x/hexo-theme-shokaX/releases/latest').then((res) => {
|
50
|
+
res.json().then((resp) => {
|
62
51
|
try {
|
63
|
-
const latest =
|
64
|
-
const current = version.split('.');
|
52
|
+
const latest = resp.tag_name.replace('v', '').split('.');
|
53
|
+
const current = package_json_1.version.split('.');
|
65
54
|
let isOutdated = false;
|
66
55
|
for (let i = 0; i < Math.max(latest.length, current.length); i++) {
|
67
56
|
if (!current[i] || latest[i] > current[i]) {
|
@@ -77,13 +66,13 @@ hexo.on('generateAfter', () => {
|
|
77
66
|
hexo.log.warn('Visit https://github.com/theme-shoka-x/hexo-theme-shokaX/releases for more information.');
|
78
67
|
}
|
79
68
|
}
|
80
|
-
catch (
|
81
|
-
hexo.log.
|
82
|
-
hexo.log.
|
69
|
+
catch (e) {
|
70
|
+
hexo.log.warn('Failed to detect version info. Error message:');
|
71
|
+
hexo.log.warn(e);
|
83
72
|
}
|
73
|
+
}).catch((e) => {
|
74
|
+
hexo.log.warn('Failed to detect version info. Error message:');
|
75
|
+
hexo.log.warn(e);
|
84
76
|
});
|
85
|
-
}).on('error', err => {
|
86
|
-
hexo.log.error('Failed to detect version info. Error message:');
|
87
|
-
hexo.log.error(err);
|
88
77
|
});
|
89
78
|
});
|
package/scripts/utils.js
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getVendorLink = void 0;
|
4
|
+
function getVendorLink(hexo, source) {
|
5
|
+
const VendorsCfg = hexo.theme.config.vendors;
|
6
|
+
const tagIdx = source.indexOf('|');
|
7
|
+
if (tagIdx !== -1) {
|
8
|
+
return `${VendorsCfg.cdns[source.substring(0, tagIdx)]}/${source.substring(tagIdx + 1)}`;
|
9
|
+
}
|
10
|
+
else {
|
11
|
+
return source;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
exports.getVendorLink = getVendorLink;
|
@@ -4,15 +4,15 @@ import { getScript } from './scriptPjax';
|
|
4
4
|
*/
|
5
5
|
const assetUrl = (asset, type) => {
|
6
6
|
const str = CONFIG[asset][type];
|
7
|
+
if (str.includes('http')) {
|
8
|
+
return str;
|
9
|
+
}
|
7
10
|
if (str.includes('gh') || str.includes('combine')) {
|
8
11
|
return `https://cdn.jsdelivr.net/${str}`;
|
9
12
|
}
|
10
13
|
if (str.includes('npm')) {
|
11
14
|
return `https://cdn.jsdelivr.net/${str}`;
|
12
15
|
}
|
13
|
-
if (str.includes('http')) {
|
14
|
-
return str;
|
15
|
-
}
|
16
16
|
return `/${str}`;
|
17
17
|
};
|
18
18
|
export const vendorJs = (type, callback, condition) => {
|
@@ -3,6 +3,7 @@ import { vendorCss, vendorJs } from '../library/loadFile';
|
|
3
3
|
export const postFancybox = (p) => {
|
4
4
|
if ($dom(p + ' .md img')) {
|
5
5
|
vendorCss('fancybox');
|
6
|
+
vendorCss('justifiedGallery');
|
6
7
|
vendorJs('fancybox', () => {
|
7
8
|
const q = jQuery.noConflict();
|
8
9
|
$dom.each(p + ' p.gallery', (element) => {
|