hexo-theme-shokax 0.3.11 → 0.3.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.
package/README.md CHANGED
@@ -1,18 +1,25 @@
1
- # 公告
1
+ # 📣 公告
2
2
  [关于ShokaX markdown扩展特性的讨论](https://github.com/theme-shoka-x/hexo-theme-shokaX/discussions/177) \
3
3
  [关于删除部分评论系统的讨论](https://github.com/theme-shoka-x/hexo-theme-shokaX/discussions/175)
4
+
4
5
  # hexo-theme-shokaX
5
6
  ![LICENSE]( https://img.shields.io/github/license/theme-shoka-x/hexo-theme-shokaX)
6
7
  ![stars](https://img.shields.io/github/stars/theme-shoka-x/hexo-theme-shokaX)
7
8
  ![version](https://shields.io/npm/v/hexo-theme-shokax)
8
9
  ![build](https://img.shields.io/github/actions/workflow/status/theme-shoka-x/hexo-theme-shokaX/build-theme.yml)
9
10
 
10
- 语言(language): 简体中文 | [English](./README_en.MD) \
11
+ #### 语言(language): 简体中文 | [English](./README_en.MD) \
11
12
  此项目是shoka的一个二次开发版(算精神续作),致力于提高性能和优化魔改体验 \
12
13
  诞生原因是目前shoka已经两年没有更新了,积压了大量BUG和功能请求。
13
14
 
14
15
  shokaX的社区资源导航和插件仓库为[awesome-shokaX](https://github.com/theme-shoka-x/awesome-shokaX)
15
16
 
17
+ ## 技术栈
18
+ ![TypeScript](https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge&logo=typescript&logoColor=white)
19
+ ![Vue.js](https://img.shields.io/badge/vuejs-%2335495e.svg?style=for-the-badge&logo=vuedotjs&logoColor=%234FC08D)
20
+ ![Pug](https://img.shields.io/badge/Pug-FFF?style=for-the-badge&logo=pug&logoColor=A86454)
21
+ ![Stylus](https://img.shields.io/badge/stylus-%23ff6347.svg?style=for-the-badge&logo=stylus&logoColor=white)
22
+
16
23
  ## 💬 和shoka的区别
17
24
  原先shoka使用了javascript+Native+nunjucks的技术 \
18
25
  而shokaX则使用了typescript+Vue 3+Pug的技术搭配 \
@@ -61,7 +68,7 @@ SXC install shokaX
61
68
  - [Typescript 中文网](https://www.tslang.cn/docs/home.html)
62
69
  - [Easy hexo](https://easyhexo.com/)
63
70
 
64
- # 许可证
71
+ # [许可证](https://github.com/theme-shoka-x/hexo-theme-shokaX/blob/main/LICENSE)
65
72
  许可证: AGPL 3 or later
66
73
 
67
74
  ## 特别说明
package/README_en.MD CHANGED
@@ -7,12 +7,18 @@
7
7
  ![version](https://shields.io/npm/v/hexo-theme-shokax)
8
8
  ![build](https://img.shields.io/github/actions/workflow/status/theme-shoka-x/hexo-theme-shokaX/build-theme.yml)
9
9
 
10
- Language: [简体中文](./README.md) | English \
10
+ #### Language: [简体中文](./README.md) | English \
11
11
  This project is a fork (spiritual successor) of Shoka, aimed at improving performance and optimizing the modified experience. \
12
12
  The reason for its creation is that Shoka has not been updated for two years, accumulating a large number of bugs and feature requests.
13
13
 
14
14
  The community resource guide and plugin repository for shokaX are available at [awesome-shokaX](https://github.com/theme-shoka-x/awesome-shokaX)
15
15
 
16
+ ## Technology Stack
17
+ ![TypeScript](https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge&logo=typescript&logoColor=white)
18
+ ![Vue.js](https://img.shields.io/badge/vuejs-%2335495e.svg?style=for-the-badge&logo=vuedotjs&logoColor=%234FC08D)
19
+ ![Pug](https://img.shields.io/badge/Pug-FFF?style=for-the-badge&logo=pug&logoColor=A86454)
20
+ ![Stylus](https://img.shields.io/badge/stylus-%23ff6347.svg?style=for-the-badge&logo=stylus&logoColor=white)
21
+
16
22
  ## 💬 Differences from Shoka
17
23
  The original Shoka used a combination of JavaScript + Native + Nunjucks technologies. \
18
24
  ShokaX, on the other hand, uses TypeScript + Vue 3 + Pug technologies and has changed many hard-to-access CDN links.
@@ -35,7 +41,7 @@ Notes:
35
41
  ## 🔧 How to Install
36
42
  Note: This project requires node.js 18.x or higher to run. \
37
43
  It is recommended to use [ShokaX-CLI](https://github.com/zkz098/shokaX-CLI) \
38
- [Click here](https://docs.kaitaku.xyz/guide/#%E9%85%8D%E7%BD%AE%E4%B8%BB%E9%A2%98) for the next configuration steps.
44
+ [Click here](https://docs.kaitaku.xyz/en/guide/) for the next configuration steps.
39
45
 
40
46
  ## 📚 Sub-projects
41
47
  - [ShokaX docs](https://github.com/theme-shoka-x/shokaX-docs) ShokaX Theme Documentation (work in progress, contributions welcome!)
@@ -48,13 +54,15 @@ It is recommended to use [ShokaX-CLI](https://github.com/zkz098/shokaX-CLI) \
48
54
  [ShokaX Official Development Documentation](https://docs.kaitaku.xyz/develop/basic/)
49
55
 
50
56
  Recommended reading for contributing:
51
- - [Hexo Official Documentation](https://hexo.io/zh-cn/docs/templates)
52
- - [Stylus Chinese Documentation](http://stylus.bootcss.com/)
57
+ - [Hexo Official Documentation]([https://hexo.io/zh-cn/docs/templates](https://hexo.io/docs/templates.html))
58
+ - [Stylus Documentation](https://stylus-lang.com/)
59
+ - [Stylus Chinese Documentation](https://stylus.bootcss.com/)
53
60
  - [Pug Template Engine Chinese Documentation](https://www.pugjs.cn/api/getting-started.html)
61
+ - [TypeScript Documentation](https://www.typescriptlang.org/docs/)
54
62
  - [TypeScript Chinese Documentation](https://www.tslang.cn/docs/home.html)
55
63
  - [Easy Hexo](https://easyhexo.com/)
56
64
 
57
- # License
65
+ # [License](https://github.com/theme-shoka-x/hexo-theme-shokaX/blob/main/LICENSE)
58
66
  License: AGPL 3 or later
59
67
 
60
68
  ## Special Note
package/_config.yml CHANGED
@@ -21,7 +21,6 @@ pwa:
21
21
 
22
22
  # 实验性特性
23
23
  experiments:
24
- noIE: true # TODO 阻止IE浏览器访问(ShokaX不支持IE的任何版本)
25
24
  noPlayer: false # 禁用音乐播放器
26
25
  gradient: false # 使用CSS渐变作为文章封面
27
26
  fixedCover: "" # 主页面cover(为空则使用bing随机图片)
@@ -77,7 +76,7 @@ loader:
77
76
 
78
77
  # 使用polyfill.io自动处理浏览器兼容问题
79
78
  polyfill:
80
- enable: true
79
+ enable: false
81
80
  features:
82
81
  - default
83
82
  - fetch
@@ -155,9 +154,9 @@ font:
155
154
  external: true
156
155
  family: Inconsolata
157
156
 
158
- # project of https://www.iconfont.cn/
159
- # //at.alicdn.com/t/font_1832207_c8i9n1ulxlt.css => 1832207_c8i9n1ulxlt
160
- iconfont: "1832207_igi8uaupcus"
157
+ # //at.alicdn.com/t/c/font_4415496_59g1326wajd.css => 4415496_59g1326wajd
158
+ # 自定义iconfont图标参见文档教程
159
+ iconfont: "4415496_59g1326wajd"
161
160
 
162
161
  menu:
163
162
  home: / || home
@@ -175,9 +174,9 @@ menu:
175
174
  # https://twikoo.js.org
176
175
  twikoo:
177
176
  enable: false
178
- link: "https://cdn.staticfile.org/twikoo/1.6.10/twikoo.nocss.min.js"
177
+ link: "https://cdn.staticfile.org/twikoo/1.6.30/twikoo.all.min.js"
179
178
  mode: vercel # vercel或tencent
180
- envId: "https://114514.foo.bar" # twikoo环境ID,vercel填地址
179
+ envId: "https://example.com" # twikoo环境ID,vercel填地址
181
180
  region:
182
181
 
183
182
  # https://waline.js.org/
@@ -212,8 +211,6 @@ summary:
212
211
  openai:
213
212
  remote: "https://api.openai.com"
214
213
  apikey: "key"
215
- custom:
216
- remote: "http://localhost:8000"
217
214
 
218
215
 
219
216
  # Social Links
@@ -222,7 +219,7 @@ summary:
222
219
  # Value before `||` delimiter is the target permalink,
223
220
  # secend value is the name of Font icon.
224
221
  social:
225
- # github: https://github.com/name || github || "#191717"
222
+ github: https://github.com/name || github || "#191717"
226
223
  #google: https://plus.google.com/yourname || google
227
224
  #twitter: https://twitter.com/yourname || twitter || "#00aff0"
228
225
  #zhihu: https://www.zhihu.com/people/yourname || zhihu || "#1e88e5"
@@ -348,58 +345,27 @@ quicklink:
348
345
  #! DO NOT EDIT THE FOLLOWING `vendors` SETTINGS
349
346
  #! UNLESS YOU KNOW WHAT YOU ARE DOING
350
347
  #! ---------------------------------------------------------------
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
348
  vendors:
349
+ cdns:
350
+ npm_webcache: https://npm.webcache.cn
351
+ bytedance: https://lf9-cdn-tos.bytecdntp.com/cdn/expire-6-M
352
+ cdnjs_webcache: https://cdnjs.webstatic.cn/ajax/libs
353
+ cdnjs: https://cdnjs.cloudflare.com/ajax/libs
354
+ unpkg: https://unpkg.com
355
+ js:
356
+ pace: bytedance|pace/1.2.4/pace.min.js
357
+ # pjax: npm_webcache|theme-shokax-pjax@0.0.3/pjax.shokax.min.js
358
+ # anime: npm_webcache|theme-shokax-anime@0.0.6/anime.shokax.min.js
359
+ # lozad: npm_webcache|lozad@1.16.0/dist/lozad.min.js
360
+ algolia: bytedance|algoliasearch/4.12.1/algoliasearch-lite.umd.min.js
361
+ instantsearch: bytedance|instantsearch.js/4.39.0/instantsearch.production.min.js
362
+ quicklink: npm_webcache|quicklink@2.3.0/dist/quicklink.umd.js
363
+ # mouse_firework: npm_webcache|mouse-firework@0.0.4/dist/index.umd.js
364
+ async_js:
365
+ 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
366
+ copy_tex: npm_webcache|katex@0.16.7/dist/contrib/copy-tex.min.js
390
367
  css:
391
- katex: npm/katex@0.16.7/dist/katex.min.css # ok
368
+ katex: npm_webcache|katex@0.16.7/dist/katex.min.css
392
369
  comment: css/comment.css
393
- fancybox: combine/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css,npm/justifiedGallery@3.8.1/dist/css/justifiedGallery.min.css # notok
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
-
370
+ fancybox: npm_webcache|@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css
371
+ 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://unpkg.com/@waline/client@v2/dist/waline.mjs';
22
+ import { init } from 'https://npm.webcache.cn/@waline/client@v2/dist/waline.mjs';
23
23
 
24
24
  setTimeout(function () {
25
25
  init({
@@ -11,7 +11,7 @@ mixin SMRender(item)
11
11
  div(class="cover" style=`background: linear-gradient(to bottom right, ${random_color()}, ${random_color()});`)
12
12
  else
13
13
  div(class="cover")
14
- != _url(link1, '<img data-src="'+ _cover(item) +'" alt="article cover">', {itemprop: 'url', title: postText})
14
+ != _url(link1, '<img loading="lazy" data-src="'+ _cover(item) +'" alt="article cover">', {itemprop: 'url', title: postText})
15
15
  div(class="info")
16
16
  +PMRender(item)
17
17
  h3
@@ -43,17 +43,11 @@ 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
- != _css("twikoo.css")
54
- script(src=theme.twikoo.link)
48
+ script(src=theme.twikoo.link )
55
49
  else if wl
56
- link(rel="stylesheet" href="https://unpkg.com/@waline/client@v2/dist/waline.css")
50
+ link(rel="stylesheet" href="https://npm.webcache.cn/@waline/client@v2/dist/waline.css" media="none" onload="this.media='all'")
57
51
 
58
52
  - var qw = theme?.qweather?.enable
59
53
  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
- if theme.advVendors.enable
123
- each i in _list_vendor_js()
124
- != _adv_vendor_js(i)
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
- != _vendor_js()
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})
@@ -11,7 +11,7 @@ article(itemscope itemtype="http://schema.org/Article" class="post block" lang=t
11
11
  if post.photos && post.photos.length
12
12
  div(class="gallery" itemscope itemtype="http://schema.org/ImageGallery")
13
13
  each photo in post.photos
14
- img(data-src=_image_url(photo, post.path) itemprop="contentUrl")
14
+ img(loading="lazy" data-src=_image_url(photo, post.path) itemprop="contentUrl")
15
15
  if theme.summary.enable && page.layout === 'post'
16
16
  div(class='tabs' id='summary')
17
17
  div(class="show-btn")
@@ -13,6 +13,6 @@ if page.reward !== false
13
13
  else
14
14
  - var translation = name
15
15
  div
16
- img(data-src=`${url_for(theme.statics + theme.assets + image) }` alt=`${ author } ${ translation }`)
16
+ img(loading="lazy" data-src=`${url_for(theme.statics + theme.assets + image) }` alt=`${ author } ${ translation }`)
17
17
  p
18
18
  != translation
@@ -1,5 +1,5 @@
1
1
  div(class="author" itemprop="author" itemscope itemtype="http://schema.org/Person")
2
- img(class="image" itemprop="image" alt=author
2
+ img(loading="lazy" class="image" itemprop="image" alt=author
3
3
  data-src=url_for(theme.statics + theme.assets + '/'+ theme.sidebar.avatar))
4
4
  p(class="name" itemprop="name")
5
5
  != author
package/package.json CHANGED
@@ -1,50 +1,44 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.3.11",
3
+ "version": "0.3.13",
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",
7
7
  "author": "zkz098",
8
8
  "license": "AGPL-3.0-or-later",
9
+ "packageManager": "pnpm@8.14.1",
9
10
  "scripts": {
10
11
  "test": "tsc --build --verbose",
11
12
  "build": "cd ./source && tsc --build --verbose && cd ../scripts && tsc --build --verbose"
12
13
  },
13
14
  "devDependencies": {
14
- "@types/chai": "^4.3.11",
15
15
  "@types/fancybox": "^3.5.6",
16
- "@types/hexo": "^3.8.12",
17
16
  "@types/jquery": "^3.5.29",
18
17
  "@types/js-yaml": "^4.0.9",
19
- "@types/lozad": "^1.16.4",
20
- "@types/mocha": "^10.0.6",
21
- "@types/node": "^20.10.6",
22
- "@typescript-eslint/eslint-plugin": "^6.18.0",
23
- "@typescript-eslint/parser": "^6.18.0",
24
- "chai": "^5.0.0",
18
+ "@types/node": "^20.11.10",
19
+ "@typescript-eslint/eslint-plugin": "^6.19.1",
20
+ "@typescript-eslint/parser": "^6.19.1",
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.1",
24
+ "eslint-plugin-n": "^16.6.2",
30
25
  "eslint-plugin-promise": "^6.1.1",
31
- "eslint-plugin-vue": "^9.19.2",
32
- "hexo-fs": "^4.1.1",
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.1",
37
28
  "typescript": "^5.3.3",
38
- "vue": "^3.4.5"
29
+ "vue": "^3.4.15"
39
30
  },
40
31
  "dependencies": {
41
- "esbuild": "^0.19.11",
42
- "hexo": "^7.0.0",
32
+ "esbuild": "^0.20.0",
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
- "lozad": "^1.16.0",
45
- "mouse-firework": "^0.0.3",
38
+ "mouse-firework": "^0.0.5",
46
39
  "theme-shokax-anime": "^0.0.6",
47
- "theme-shokax-pjax": "^0.0.3"
40
+ "theme-shokax-pjax": "^0.0.3",
41
+ "unlazy": "^0.10.4"
48
42
  },
49
43
  "engines": {
50
44
  "node": ">=18.0.0"
@@ -1,5 +1,5 @@
1
1
  /* global hexo */
2
2
  hexo.extend.filter.register('after_post_render', (data) => {
3
3
  // 使用正则表达式将<img>标签的src属性替换为data-src属性
4
- data.content = data.content.replace(/(<img[^>]*) src=/img, '$1 data-src=');
4
+ data.content = data.content.replace(/(<img[^>]*) src=/img, '$1 loading="lazy" data-src=');
5
5
  }, 0);
@@ -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
- // import env from '../../package.json'
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 env = {
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: env.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
- chart: theme.vendors.js.chart,
50
- copy_tex: theme.vendors.js.copy_tex,
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
- // valine: theme.css + '/comment.css',
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,8 +99,12 @@ hexo.extend.generator.register('script', function (locals) {
99
99
  bundle: true,
100
100
  outfile: 'shokax_temp.js',
101
101
  platform: 'browser',
102
- target: ['es2021'],
103
- minify: true
102
+ format: 'iife',
103
+ target: ['es2022'],
104
+ minify: true,
105
+ define: {
106
+ __UNLAZY_LOGGING__: 'false'
107
+ }
104
108
  });
105
109
  text += fs.readFileSync('shokax_temp.js');
106
110
  const result = hexo.render.renderSync({ text, engine: 'js' });
@@ -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
- // import theme_env from '../../package.json'
7
+ const package_json_1 = __importDefault(require("../../package.json"));
5
8
  const hexo_util_1 = require("hexo-util");
6
- const theme_env = {
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://unpkg.com/@waline/client@v2/dist/waline.mjs'
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 !== '/' ? '/' + 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 theme_env[type];
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=${theme_env.version}`)
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=${theme_env.version}`) }, '')).join('');
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('_list_vendor_js', () => {
150
- return hexo.theme.config.vendorsList.js;
151
- });
152
- hexo.extend.helper.register('_adv_vendor_js', function (js_name) {
153
- const srcHelpers = (src) => { return src.endsWith('/') ? src : src + '/'; };
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
- return (0, hexo_util_1.htmlTag)('script', attr, '');
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);
@@ -11,7 +11,7 @@ let db;
11
11
  function postMessage(path, content, dbPath, startMessage) {
12
12
  if (node_fs_1.default.existsSync('summary.json')) {
13
13
  // @ts-ignore
14
- db = JSON.parse(node_fs_1.default.readFileSync('summary.json'));
14
+ db = JSON.parse(node_fs_1.default.readFileSync('summary.json', { encoding: 'utf-8' }));
15
15
  }
16
16
  else {
17
17
  db = {};