hexo-theme-shokax 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- package/_config.yml +38 -18
- package/layout/_partials/layout.pug +1 -1
- package/package.json +1 -1
- package/scripts/generaters/script.js +5 -1
- package/scripts/helpers/asset.js +3 -7
- package/scripts/utils.js +12 -5
- package/source/js/_app/library/declare.d.ts +12 -9
- package/source/js/_app/library/loadFile.ts +15 -15
- package/source/js/_app/library/scriptPjax.ts +4 -2
package/_config.yml
CHANGED
@@ -44,16 +44,11 @@ modules:
|
|
44
44
|
quiz: true # 启用文章内问题扩展支持
|
45
45
|
fancybox: true # 启用 fancybox 支持(不建议禁用)
|
46
46
|
|
47
|
-
styles:
|
48
|
-
postprocess: true # 启用后处理器
|
49
|
-
modules:
|
50
|
-
mermaid: false
|
51
|
-
|
52
47
|
# 优化性能区
|
53
48
|
performance:
|
54
49
|
# 使用preconnect预加载的网址(不建议超过三个)
|
55
50
|
preConnect:
|
56
|
-
- "https://
|
51
|
+
- "https://s4.zstatic.net"
|
57
52
|
- "https://at.alicdn.com"
|
58
53
|
# 使用dns-prefetch预解析的网址
|
59
54
|
dnsPrefetch:
|
@@ -364,18 +359,43 @@ quicklink:
|
|
364
359
|
#! ---------------------------------------------------------------
|
365
360
|
vendors:
|
366
361
|
cdns:
|
367
|
-
|
368
|
-
bytedance: https://lf9-cdn-tos.bytecdntp.com/cdn/expire-6-M
|
369
|
-
cdnjs_webcache: https://cdnjs.webstatic.cn/ajax/libs
|
370
|
-
cdnjs: https://cdnjs.cloudflare.com/ajax/libs
|
371
|
-
unpkg: https://unpkg.com
|
362
|
+
cdnjs: https://s4.zstatic.net/ajax/libs
|
372
363
|
js:
|
373
|
-
pace:
|
364
|
+
pace:
|
365
|
+
source: cdnjs
|
366
|
+
url: pace/1.2.4/pace.min.js
|
367
|
+
sri: "sha384-k6YtvFUEIuEFBdrLKJ3YAUbBki333tj1CSUisai5Cswsg9wcLNaPzsTHDswp4Az8"
|
374
368
|
async_js:
|
375
|
-
|
376
|
-
|
369
|
+
jquery:
|
370
|
+
source: cdnjs
|
371
|
+
url: jquery/3.5.1/jquery.min.js
|
372
|
+
sri: "sha384-ZvpUoO/+PpLXR1lu4jmpXWu80pZlYUAfxl5NsBMWOEPSjUn/6Z/hRTt8+pR6L4N2"
|
373
|
+
fancybox:
|
374
|
+
source: cdnjs
|
375
|
+
url: fancybox/3.5.7/jquery.fancybox.min.js
|
376
|
+
sri: "sha384-Zm+UU4tdcfAm29vg+MTbfu//q5B/lInMbMCr4T8c9rQFyOv6PlfQYpB5wItcXWe7"
|
377
|
+
justifiedGallery:
|
378
|
+
source: cdnjs
|
379
|
+
url: justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js
|
380
|
+
sri: "sha384-TOxsBplaL96/QDWPIUg+ye3v89qSE3s22XNtJMmCeZEep3cVDmXy1zEfZvVv+y2m"
|
381
|
+
copy_tex:
|
382
|
+
source: cdnjs
|
383
|
+
url: KaTeX/0.16.9/contrib/copy-tex.min.js
|
384
|
+
sri: "sha384-ww/583aHhxWkz5DEVn6OKtNiIaLi2iBRNZXfJRiY1Ai7tnJ9UXpEsyvOITVpTl4A"
|
377
385
|
css:
|
378
|
-
katex:
|
379
|
-
|
380
|
-
|
381
|
-
|
386
|
+
katex:
|
387
|
+
source: cdnjs
|
388
|
+
url: KaTeX/0.16.9/katex.min.css
|
389
|
+
sri: "sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV"
|
390
|
+
comment:
|
391
|
+
source: local
|
392
|
+
url: css/comment.css
|
393
|
+
sri: ""
|
394
|
+
fancybox:
|
395
|
+
source: cdnjs
|
396
|
+
url: fancybox/3.5.7/jquery.fancybox.min.css
|
397
|
+
sri: "sha384-Q8BgkilbsFGYNNiDqJm69hvDS7NCJWOodvfK/cwTyQD4VQA0qKzuPpvqNER1UC0F"
|
398
|
+
justifiedGallery:
|
399
|
+
source: cdnjs
|
400
|
+
url: justifiedGallery/3.8.1/css/justifiedGallery.min.css
|
401
|
+
sri: "sha384-V/1Ew9pYm8xpy/L9i078ZXT6HSEOrGC6KNFYLbXOdtqb3+c6brpGqVzZtEPSQOiz"
|
@@ -128,7 +128,7 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
128
128
|
!= partial('_partials/third-party/clarity.pug', {}, {cache: true})
|
129
129
|
!= partial('_partials/third-party/google-analytics.pug', {}, {cache: true})
|
130
130
|
|
131
|
-
!= vendor_js()
|
131
|
+
!= vendor_js('pace')
|
132
132
|
if theme.polyfill.enable
|
133
133
|
script(src=`https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?version=4.8.0&features=${theme.polyfill.features}` defer)
|
134
134
|
|
package/package.json
CHANGED
@@ -29,7 +29,11 @@ hexo.extend.generator.register('script', function (locals) {
|
|
29
29
|
},
|
30
30
|
css: {
|
31
31
|
katex: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.katex),
|
32
|
-
mermaid:
|
32
|
+
mermaid: {
|
33
|
+
url: theme.css + '/mermaid.css',
|
34
|
+
local: true,
|
35
|
+
sri: ''
|
36
|
+
},
|
33
37
|
fancybox: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.fancybox),
|
34
38
|
justifiedGallery: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.justifiedGallery)
|
35
39
|
},
|
package/scripts/helpers/asset.js
CHANGED
@@ -57,13 +57,9 @@ hexo.extend.helper.register('_js', function (...urls) {
|
|
57
57
|
const { statics, js } = hexo.theme.config;
|
58
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
59
|
});
|
60
|
-
hexo.extend.helper.register('vendor_js', function () {
|
61
|
-
const
|
62
|
-
|
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;
|
60
|
+
hexo.extend.helper.register('vendor_js', function (vendor) {
|
61
|
+
const res = (0, utils_1.getVendorLink)(hexo, hexo.theme.config.vendors.js[vendor]);
|
62
|
+
return (0, hexo_util_1.htmlTag)('script', { src: res.url, integrity: res.sri, crossorigin: 'anonymous', fetchpriority: 'high' }, '');
|
67
63
|
});
|
68
64
|
hexo.extend.helper.register('_striptags', function (data) {
|
69
65
|
return (0, hexo_util_1.stripHTML)(data);
|
package/scripts/utils.js
CHANGED
@@ -2,12 +2,19 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getVendorLink = getVendorLink;
|
4
4
|
function getVendorLink(hexo, source) {
|
5
|
-
const
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
const vendorsCfg = hexo.theme.config.vendors;
|
6
|
+
if (source.source === "local") {
|
7
|
+
return {
|
8
|
+
url: source.url,
|
9
|
+
local: true,
|
10
|
+
sri: ''
|
11
|
+
};
|
9
12
|
}
|
10
13
|
else {
|
11
|
-
return
|
14
|
+
return {
|
15
|
+
url: vendorsCfg.cdns[source.source] + '/' + source.url,
|
16
|
+
local: false,
|
17
|
+
sri: source.sri
|
18
|
+
};
|
12
19
|
}
|
13
20
|
}
|
@@ -1,6 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
type vendorUrl = {
|
2
|
+
url: string
|
3
|
+
local: boolean
|
4
|
+
sri?: string
|
5
|
+
}
|
6
|
+
|
4
7
|
interface AudioItem {
|
5
8
|
title: string;
|
6
9
|
list: string[];
|
@@ -80,14 +83,14 @@ interface configType {
|
|
80
83
|
switch: boolean
|
81
84
|
}
|
82
85
|
js: {
|
83
|
-
copy_tex:
|
84
|
-
fancybox:
|
86
|
+
copy_tex: vendorUrl
|
87
|
+
fancybox: vendorUrl
|
85
88
|
}
|
86
89
|
css: {
|
87
|
-
valine:
|
88
|
-
katex:
|
89
|
-
mermaid:
|
90
|
-
fancybox:
|
90
|
+
valine: vendorUrl
|
91
|
+
katex: vendorUrl
|
92
|
+
mermaid: vendorUrl
|
93
|
+
fancybox: vendorUrl
|
91
94
|
}
|
92
95
|
search: any,
|
93
96
|
waline: {
|
@@ -4,28 +4,22 @@ import { createChild } from './proto'
|
|
4
4
|
|
5
5
|
/**
|
6
6
|
* 用途是根据不同的资源名称和类型生成相应的资源 URL。
|
7
|
-
* @deprecated Use smart bundle and import() instead.
|
8
7
|
*/
|
9
8
|
const assetUrl = (asset: string, type: string): string => {
|
10
|
-
const str = CONFIG[asset][type]
|
11
|
-
if (str.
|
9
|
+
const str = CONFIG[asset][type].url as string
|
10
|
+
if (str.startsWith('https')) {
|
12
11
|
return str
|
13
12
|
}
|
14
|
-
if (str.
|
15
|
-
|
16
|
-
|
17
|
-
if (str.includes('npm')) {
|
18
|
-
return `https://cdn.jsdelivr.net/${str}`
|
13
|
+
if (str.startsWith('http')) {
|
14
|
+
console.warn(`Upgrade vendor ${asset}/${type} to HTTPS, Please use HTTPS url instead of HTTP url.`)
|
15
|
+
return str.replace('http', 'https')
|
19
16
|
}
|
20
17
|
return `/${str}`
|
21
18
|
}
|
22
19
|
|
23
|
-
/**
|
24
|
-
@deprecated Use smart bundle and import() instead. Will be removed in the v0.5
|
25
|
-
*/
|
26
20
|
export const vendorJs = (type: string, callback?: Function, condition?: string) => {
|
27
21
|
if (LOCAL[type]) {
|
28
|
-
getScript(assetUrl('js', type), callback || function () {
|
22
|
+
getScript(assetUrl('js', type),CONFIG['js'][type].sri, callback || function () {
|
29
23
|
window[type] = true
|
30
24
|
}, condition || window[type])
|
31
25
|
}
|
@@ -37,10 +31,16 @@ export const vendorCss = (type: string, condition?: string): void => {
|
|
37
31
|
}
|
38
32
|
|
39
33
|
if (LOCAL[type]) {
|
40
|
-
|
34
|
+
const attr:any = {
|
41
35
|
rel: 'stylesheet',
|
42
|
-
href: assetUrl('css', type)
|
43
|
-
}
|
36
|
+
href: assetUrl('css', type),
|
37
|
+
}
|
38
|
+
const vendor = CONFIG['css'][type] as vendorUrl
|
39
|
+
if (!vendor.local) {
|
40
|
+
attr.integrity = vendor.sri
|
41
|
+
attr.crossOrigin = 'anonymous'
|
42
|
+
}
|
43
|
+
createChild(document.head, 'link', attr)
|
44
44
|
|
45
45
|
window['css' + type] = true
|
46
46
|
}
|
@@ -10,13 +10,13 @@ export function cloudflareInit () {
|
|
10
10
|
window.addEventListener('load', function () {
|
11
11
|
if (inCloudFlare) {
|
12
12
|
window.dispatchEvent(new Event('DOMContentLoaded'))
|
13
|
-
console.log('%c ☁️cloudflare patch ' + '%c running
|
13
|
+
console.log('%c ☁️cloudflare patch ' + '%c running', 'color: white; background: #ff8c00; padding: 5px 3px;', 'padding: 4px;border:1px solid #ff8c00')
|
14
14
|
}
|
15
15
|
})
|
16
16
|
}
|
17
17
|
}
|
18
18
|
|
19
|
-
export const getScript = (url: string, callback?: Function, condition?: string): void => {
|
19
|
+
export const getScript = (url: string,sri: string, callback?: Function, condition?: string): void => {
|
20
20
|
// url: 脚本文件的URL地址
|
21
21
|
// callback: 当脚本加载完成时要执行的回调函数
|
22
22
|
// condition: 可选的条件参数,如果存在,则执行callback
|
@@ -39,6 +39,8 @@ export const getScript = (url: string, callback?: Function, condition?: string):
|
|
39
39
|
}
|
40
40
|
}
|
41
41
|
script.src = url
|
42
|
+
script.integrity = sri
|
43
|
+
script.crossOrigin = 'anonymous'
|
42
44
|
document.head.appendChild(script)
|
43
45
|
}
|
44
46
|
}
|