hexo-theme-shokax 0.4.6 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
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://lf9-cdn-tos.bytecdntp.com"
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
- npm_webcache: https://npm.webcache.cn
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: bytedance|pace/1.2.4/pace.min.js
364
+ pace:
365
+ source: cdnjs
366
+ url: pace/1.2.4/pace.min.js
367
+ sri: "sha384-k6YtvFUEIuEFBdrLKJ3YAUbBki333tj1CSUisai5Cswsg9wcLNaPzsTHDswp4Az8"
374
368
  async_js:
375
- 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
376
- copy_tex: npm_webcache|katex@0.16.7/dist/contrib/copy-tex.min.js
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: npm_webcache|katex@0.16.7/dist/katex.min.css
379
- comment: css/comment.css
380
- fancybox: npm_webcache|@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css
381
- justifiedGallery: npm_webcache|justifiedGallery@3.8.1/dist/css/justifiedGallery.min.css
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
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",
@@ -31,13 +31,12 @@
31
31
  "dependencies": {
32
32
  "@algolia/client-search": "^4.24.0",
33
33
  "@waline/client": "^3.2.6",
34
- "algoliasearch": "4.23.3",
35
- "esbuild": "^0.21.5",
36
- "hexo": "^7.2.0",
34
+ "algoliasearch": "4.24.0",
35
+ "esbuild": "^0.23.0",
36
+ "hexo": "^7.3.0",
37
37
  "hexo-algoliasearch": "^2.0.1",
38
38
  "hexo-feed": "^1.1.2",
39
39
  "hexo-fs": "^4.1.3",
40
- "hexo-lightning-minify": "^0.1.5",
41
40
  "hexo-pagination": "^3.0.0",
42
41
  "hexo-renderer-pug": "^3.0.0",
43
42
  "hexo-util": "^3.3.0",
@@ -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: theme.css + '/mermaid.css',
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
  },
@@ -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 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;
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 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)}`;
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 source;
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
- 对注释的说明: 部分注释为openai-chatgpt生成的注释,可能存在描述或语义的问题
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: string
84
- fancybox: string
86
+ copy_tex: vendorUrl
87
+ fancybox: vendorUrl
85
88
  }
86
89
  css: {
87
- valine: string
88
- katex: string
89
- mermaid: string
90
- fancybox: string
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.includes('http')) {
9
+ const str = CONFIG[asset][type].url as string
10
+ if (str.startsWith('https')) {
12
11
  return str
13
12
  }
14
- if (str.includes('gh') || str.includes('combine')) {
15
- return `https://cdn.jsdelivr.net/${str}`
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
- createChild(document.head, 'link', {
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(rocket & minify)', 'color: white; background: #ff8c00; padding: 5px 3px;', 'padding: 4px;border:1px solid #ff8c00')
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
  }
@@ -1,16 +1,12 @@
1
1
  /*
2
2
  ShokaX ToolBox - Compiler
3
3
  compatibility: ShokaX v0.4.x
4
- NEED PNPM INSTALLED
5
4
  */
6
5
  import path from "node:path";
7
6
  import fs from 'fs/promises'
8
7
  import child_process from 'child_process'
9
- import {hoistDeps} from "./lib.mjs";
10
8
 
11
9
  const CONFIG = {
12
- depsHoist: true,
13
- minify: false,
14
10
  legacyScript: true,
15
11
  }
16
12
 
@@ -46,10 +42,10 @@ if (CONFIG.legacyScript) {
46
42
  } else if (sPath.startsWith('file:\\')) {
47
43
  sPath = sPath.slice(8); // 去除 'file:\'
48
44
  }
49
- child_process.exec('pnpm install',{
45
+ child_process.exec('npm install',{
50
46
  cwd: path.join(sPath,'./../')
51
47
  }, (code, stdout, stderr) => {
52
- child_process.exec('pnpm --package=typescript dlx tsc --build'.trim(), {
48
+ child_process.exec('"yes" | npx -p typescript tsc --build'.trim(), {
53
49
  cwd: sPath
54
50
  }, async (code, stdout, stderr) => {
55
51
  console.log('Deleting typescript files...')
@@ -61,15 +57,6 @@ if (CONFIG.legacyScript) {
61
57
  throw Error('Not implemented yet.')
62
58
  }
63
59
 
64
- if (CONFIG.depsHoist) {
65
- try {
66
- await hoistDeps()
67
- console.log('Finished hoisting dependencies.')
68
- } catch (e) {
69
- console.log('Skipping hoisting dependencies.')
70
- }
71
- }
72
-
73
60
  console.log('Done.')
74
61
 
75
62