hexo-theme-shokax 0.3.9 → 0.3.11

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.
Files changed (49) hide show
  1. package/README.md +4 -1
  2. package/_config.yml +26 -28
  3. package/layout/_mixin/comment.pug +1 -34
  4. package/layout/_mixin/segment.pug +1 -1
  5. package/layout/_partials/head/head.pug +1 -4
  6. package/layout/_partials/layout.pug +2 -2
  7. package/package.json +18 -17
  8. package/scripts/filters/locals.js +6 -0
  9. package/scripts/filters/post.js +2 -0
  10. package/scripts/generaters/archive.js +13 -1
  11. package/scripts/generaters/config.js +4 -1
  12. package/scripts/generaters/images.js +2 -0
  13. package/scripts/generaters/index.js +5 -2
  14. package/scripts/generaters/pages.js +0 -2
  15. package/scripts/generaters/script.js +34 -9
  16. package/scripts/helpers/asset.js +16 -7
  17. package/scripts/helpers/engine.js +24 -1
  18. package/scripts/helpers/list_categories.js +4 -0
  19. package/scripts/helpers/summary_ai.js +4 -0
  20. package/scripts/helpers/symbols_count_time.js +14 -8
  21. package/scripts/plugin/check.js +5 -3
  22. package/scripts/plugin/index.js +36 -9
  23. package/scripts/plugin/lib/injects.js +15 -0
  24. package/scripts/tags/media.js +1 -0
  25. package/source/js/_app/components/sidebar.js +54 -56
  26. package/source/js/_app/fireworks.js +6 -137
  27. package/source/js/_app/globals/globalVars.js +80 -96
  28. package/source/js/_app/globals/handles.js +81 -60
  29. package/source/js/_app/globals/themeColor.js +30 -26
  30. package/source/js/_app/globals/thirdparty.js +25 -24
  31. package/source/js/_app/globals/tools.js +36 -30
  32. package/source/js/_app/library/anime.js +31 -17
  33. package/source/js/_app/library/dom.js +12 -5
  34. package/source/js/_app/library/loadFile.js +7 -9
  35. package/source/js/_app/library/proto.js +59 -7
  36. package/source/js/_app/library/scriptPjax.js +14 -9
  37. package/source/js/_app/library/storage.js +2 -4
  38. package/source/js/_app/library/vue.js +16 -19
  39. package/source/js/_app/page/comment.js +10 -11
  40. package/source/js/_app/page/common.js +8 -12
  41. package/source/js/_app/page/fancybox.js +13 -14
  42. package/source/js/_app/page/post.js +43 -45
  43. package/source/js/_app/page/search.js +20 -20
  44. package/source/js/_app/page/tab.js +7 -10
  45. package/source/js/_app/pjax/domInit.js +29 -29
  46. package/source/js/_app/pjax/refresh.js +45 -50
  47. package/source/js/_app/pjax/siteInit.js +27 -31
  48. package/source/js/_app/player.js +44 -27
  49. package/test/dom.test.js +0 -86
package/README.md CHANGED
@@ -80,7 +80,10 @@ AGPL许可证主要目的是限制修改后的分发行为,避免未经许可
80
80
  | hexo-theme-shoka | amehime | 本项目的父主题 |
81
81
 
82
82
  ## 开发者们
83
- [![](https://contributors-img.web.app/image?repo=theme-shoka-x/hexo-theme-shokaX)](https://github.com/theme-shoka-x/hexo-theme-shokaX/graphs/contributors)
83
+ Hexo 主题: \
84
+ [![](https://contributors-img.web.app/image?repo=theme-shoka-x/hexo-theme-shokaX)](https://github.com/theme-shoka-x/hexo-theme-shokaX/graphs/contributors) \
85
+ ShokaX 文档: \
86
+ [![](https://contributors-img.web.app/image?repo=theme-shoka-x/shokaX-docs)](https://github.com/theme-shoka-x/shokaX-docs/graphs/contributors) \
84
87
 
85
88
  ## 特别鸣谢
86
89
  [<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.png" width="25%">](https://jb.gg/OpenSourceSupport)
package/_config.yml CHANGED
@@ -83,13 +83,34 @@ polyfill:
83
83
  - fetch
84
84
 
85
85
  # 显示的动画(烟花)
86
+ # 参阅 https://github.com/D-Sketon/mouse-firework
86
87
  fireworks:
87
88
  enable: true
88
- color:
89
- - "rgba(255,182,185,.9)"
90
- - "rgba(250,227,217,.9)"
91
- - "rgba(187,222,214,.9)"
92
- - "rgba(138,198,209,.9)"
89
+ options:
90
+ excludeElements: ["a"]
91
+ particles:
92
+ - shape: circle
93
+ move: ["emit"]
94
+ easing: easeOutExpo
95
+ colors:
96
+ - "rgba(255,182,185,.9)"
97
+ - "rgba(250,227,217,.9)"
98
+ - "rgba(187,222,214,.9)"
99
+ - "rgba(138,198,209,.9)"
100
+ number: 30
101
+ duration: [1200, 1800]
102
+ shapeOptions:
103
+ radius: [16, 32]
104
+ - shape: circle
105
+ move: ["diffuse"]
106
+ easing: easeOutExpo
107
+ colors: ["#fff"]
108
+ number: 1
109
+ duration: [1200, 1800]
110
+ shapeOptions:
111
+ radius: 20
112
+ alpha: 0.5
113
+ lineWidth: 6
93
114
 
94
115
  font:
95
116
  enable: true
@@ -183,29 +204,6 @@ waline:
183
204
  pageSize: 10 # 每页评论条数
184
205
  pageview: false # 是否开启浏览量统计,可独立开启
185
206
 
186
- # https://github.com/gitalk/gitalk/blob/master/readme-cn.md
187
- gitalk:
188
- clientID:
189
- clientSecret:
190
- repo:
191
- owner:
192
- admin:
193
- proxy: # 选填
194
-
195
- # https://giscus.app/zh-CN
196
- giscus:
197
- repo:
198
- repoId:
199
- category:
200
- categoryId:
201
- mapping:
202
- strict:
203
- reactionsEnabled:
204
- emitMetadata:
205
- inputPosition:
206
- commentTheme:
207
- lang:
208
-
209
207
  summary:
210
208
  enable: false
211
209
  introduce: "我是基于ChatGPT-turbo-3.5实现的AI助手,在此网站上负责整理和概括文章" # AI自我介绍
@@ -1,6 +1,6 @@
1
1
  mixin CommentRender()
2
2
  != shokax_inject('comment')
3
- - var tk = theme?.twikoo?.enable,wl = theme?.waline?.enable,gt=theme?.gitalk?.enable,gs=theme?.giscus?.enable
3
+ - var tk = theme?.twikoo?.enable,wl = theme?.waline?.enable
4
4
  if page.comment !== false && !theme.experiments.disableThemeComment
5
5
  if tk
6
6
  div(class="wrap" id="tcomments")
@@ -37,38 +37,5 @@ mixin CommentRender()
37
37
  dark: 'html[data-theme="dark"]'
38
38
  });
39
39
  }, 1000)
40
- else if gt
41
- div(class="wrap" id="gtcomments")
42
- script(type="text/javascript" data-pjax).
43
- const gproxy = theme.gitalk.proxy || undefined
44
- const gitalk = new Gitalk({
45
- clientID: '#{theme.gitalk.clientID}',
46
- clientSecret: '#{theme.gitalk.clientSecret}',
47
- repo: '#{theme.gitalk.repo}',
48
- owner: '#{theme.gitalk.owner}',
49
- admin: #{theme.gitalk.admin},
50
- id: location.pathname, // Ensure uniqueness and length less than 50
51
- distractionFreeMode: false, // Facebook-like distraction free mode
52
- proxy: "#{gproxy}"
53
- });
54
- gitalk.render("gtcomments")
55
- else if gs
56
- div(class="wrap giscus" id="gscomments")
57
- script( src="https://giscus.app/client.js"
58
- data-repo="#{theme.giscus.repo}"
59
- data-repo-id="#{theme.giscus.repoId}"
60
- data-category="#{theme.giscus.category}"
61
- data-category-id="#{theme.giscus.categoryId}"
62
- data-mapping="#{theme.giscus.mapping}"
63
- data-strict="#{theme.giscus.strict}"
64
- data-reactions-enabled="#{theme.giscus.reactionsEnabled}"
65
- data-emit-metadata="#{theme.giscus.emitMetadata}"
66
- data-input-position="#{theme.giscus.inputPosition}"
67
- data-theme="#{theme.giscus.commentTheme}"
68
- data-lang="#{theme.giscus.lang}"
69
- data-loading="lazy"
70
- crossorigin="anonymous"
71
- async
72
- )
73
40
 
74
41
 
@@ -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_index(item) +'" alt="article cover">', {itemprop: 'url', title: postText})
14
+ != _url(link1, '<img data-src="'+ _cover(item) +'" alt="article cover">', {itemprop: 'url', title: postText})
15
15
  div(class="info")
16
16
  +PMRender(item)
17
17
  h3
@@ -3,7 +3,7 @@
3
3
  - var siteTitle = config.title,noBaiduT = theme?.seo?.disable_baidu_transformation
4
4
  - var feedLink = full_url_for("/feed.json")
5
5
  - var tk= theme?.twikoo?.enable
6
- - var wl = theme.waline.enable,gt=theme?.gitalk?.enable
6
+ - var wl = theme.waline.enable
7
7
  meta(charset="UTF-8")
8
8
  meta(name="viewport" content="width=device-width,initial-scale=1,maximum-scale=2")
9
9
  meta(name="theme-color" content="#222")
@@ -54,9 +54,6 @@ if tk
54
54
  script(src=theme.twikoo.link)
55
55
  else if wl
56
56
  link(rel="stylesheet" href="https://unpkg.com/@waline/client@v2/dist/waline.css")
57
- else if gt
58
- link(rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css")
59
- script(src="https://unpkg.com/gitalk/dist/gitalk.min.js")
60
57
 
61
58
  - var qw = theme?.qweather?.enable
62
59
  if qw
@@ -2,7 +2,7 @@ include ../_mixin/breadcrumb.pug
2
2
  include ../_mixin/sidebar.pug
3
3
  include ../_mixin/widgets.pug
4
4
 
5
- - var ignores = []
5
+ - ignores = []
6
6
  if (theme.quicklink.ignores)
7
7
  - ignores.push(theme.quicklink.ignores)
8
8
 
@@ -40,7 +40,7 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
40
40
  - var coverImage = theme.experiments.fixedCover || "https://7ed.net/bing/api"
41
41
  img(src=coverImage)
42
42
  else
43
- - var covers = _cover(page, 6)
43
+ - var covers = _cover_index(page, 6)
44
44
  if covers.length === 6
45
45
  ul
46
46
  each image in covers
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
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
9
  "scripts": {
10
- "test": "mocha test",
11
- "build": "pnpm install && tsc"
10
+ "test": "tsc --build --verbose",
11
+ "build": "cd ./source && tsc --build --verbose && cd ../scripts && tsc --build --verbose"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@types/chai": "^4.3.11",
@@ -18,32 +18,33 @@
18
18
  "@types/js-yaml": "^4.0.9",
19
19
  "@types/lozad": "^1.16.4",
20
20
  "@types/mocha": "^10.0.6",
21
- "@types/node": "^20.10.2",
22
- "@typescript-eslint/eslint-plugin": "^6.13.1",
23
- "@typescript-eslint/parser": "^6.13.1",
24
- "chai": "^4.3.10",
25
- "eslint": "^8.55.0",
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",
25
+ "eslint": "^8.56.0",
26
26
  "eslint-config-standard": "~17",
27
27
  "eslint-plugin-chai-friendly": "^0.7.2",
28
- "eslint-plugin-import": "^2.29.0",
29
- "eslint-plugin-n": "^16.3.1",
28
+ "eslint-plugin-import": "^2.29.1",
29
+ "eslint-plugin-n": "^16.6.1",
30
30
  "eslint-plugin-promise": "^6.1.1",
31
31
  "eslint-plugin-vue": "^9.19.2",
32
32
  "hexo-fs": "^4.1.1",
33
33
  "hexo-util": "^3.1.0",
34
- "instantsearch.js": "^4.60.0",
35
- "jsdom": "^23.0.1",
34
+ "instantsearch.js": "^4.63.0",
35
+ "jsdom": "^23.1.0",
36
36
  "mocha": "^10.2.0",
37
- "typescript": "^5.3.2",
38
- "vue": "^3.3.9"
37
+ "typescript": "^5.3.3",
38
+ "vue": "^3.4.5"
39
39
  },
40
40
  "dependencies": {
41
- "esbuild": "^0.19.8",
41
+ "esbuild": "^0.19.11",
42
42
  "hexo": "^7.0.0",
43
43
  "js-yaml": "^4.1.0",
44
44
  "lozad": "^1.16.0",
45
- "theme-shokax-anime": "^0.0.4",
46
- "theme-shokax-pjax": "^0.0.2"
45
+ "mouse-firework": "^0.0.3",
46
+ "theme-shokax-anime": "^0.0.6",
47
+ "theme-shokax-pjax": "^0.0.3"
47
48
  },
48
49
  "engines": {
49
50
  "node": ">=18.0.0"
@@ -1,15 +1,19 @@
1
+ // @ts-ignore
1
2
  const fmtNum = (num) => {
2
3
  return num < 10 ? '0' + num : num;
3
4
  };
4
5
  hexo.extend.filter.register('template_locals', (locals) => {
5
6
  const { config } = hexo;
6
7
  const { __, theme } = locals;
8
+ // @ts-ignore
7
9
  const { i18n } = hexo.theme;
8
10
  const pangu = {
9
11
  spacing: (data) => {
10
12
  return data;
11
13
  }
12
14
  };
15
+ // Language & Config
16
+ // 根据主题配置的 Creative Commons 许可证生成链接
13
17
  locals.alternate = theme.alternate;
14
18
  locals.title = pangu.spacing(__('title') !== 'title' ? __('title') : config.title);
15
19
  locals.subtitle = pangu.spacing(__('subtitle') !== 'subtitle' ? __('subtitle') : config.subtitle);
@@ -19,6 +23,8 @@ hexo.extend.filter.register('template_locals', (locals) => {
19
23
  locals.languages.splice(locals.languages.indexOf('default'), 1);
20
24
  locals.page.lang = locals.page.lang || locals.page.language;
21
25
  locals.hostname = new URL(config.url).hostname || config.url;
26
+ // Creative Commons
27
+ // 根据主题配置的 Creative Commons 许可证生成链接
22
28
  if (theme.creative_commons.license === 'zero') {
23
29
  locals.ccURL = 'https://creativecommons.org/' + 'publicdomain/zero/1.0/' + (theme.creative_commons.language || '');
24
30
  }
@@ -1,3 +1,5 @@
1
+ /* global hexo */
1
2
  hexo.extend.filter.register('after_post_render', (data) => {
3
+ // 使用正则表达式将<img>标签的src属性替换为data-src属性
2
4
  data.content = data.content.replace(/(<img[^>]*) src=/img, '$1 data-src=');
3
5
  }, 0);
@@ -1,13 +1,17 @@
1
+ /* global hexo */
1
2
  'use strict';
2
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
5
  };
5
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ // @ts-ignore
6
8
  const hexo_pagination_1 = __importDefault(require("hexo-pagination"));
9
+ // @ts-ignore
7
10
  const fmtNum = num => {
8
11
  return num < 10 ? '0' + num : num;
9
12
  };
10
13
  if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
14
+ // when archive disabled pagination, per_page should be 0.
11
15
  let per_page;
12
16
  if (hexo.config.archive === 1) {
13
17
  per_page = 0;
@@ -28,6 +32,7 @@ if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
28
32
  const config = hexo.config;
29
33
  let archiveDir = config.archive_dir;
30
34
  const paginationDir = config.pagination_dir || 'page';
35
+ // @ts-ignore
31
36
  const allPosts = locals.posts.sort(config.archive_generator.order_by || '-date');
32
37
  const perPage = config.archive_generator.per_page;
33
38
  let result = [];
@@ -49,11 +54,14 @@ if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
49
54
  if (!config.archive_generator.yearly)
50
55
  return result;
51
56
  const posts = {};
57
+ // 按日期对文章进行分类
52
58
  allPosts.forEach(post => {
53
59
  const date = post.date;
54
60
  const year = date.year();
55
- const month = date.month() + 1;
61
+ const month = date.month() + 1; // month is started from 0
56
62
  if (!Object.prototype.hasOwnProperty.call(posts, year)) {
63
+ // 13个数组. 第一个数组是给这一年的文章准备的
64
+ // 其他则是各个月份的文章
57
65
  posts[year] = [
58
66
  [],
59
67
  [],
@@ -72,6 +80,7 @@ if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
72
80
  }
73
81
  posts[year][0].push(post);
74
82
  posts[year][month].push(post);
83
+ // Daily
75
84
  if (config.archive_generator.daily) {
76
85
  const day = date.date();
77
86
  if (!Object.prototype.hasOwnProperty.call(posts[year][month], 'day')) {
@@ -83,6 +92,7 @@ if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
83
92
  const Query = this.model('Post').Query;
84
93
  const years = Object.keys(posts);
85
94
  let year, data, month, monthData, url;
95
+ // Yearly
86
96
  for (let i = 0, len = years.length; i < len; i++) {
87
97
  year = +years[i];
88
98
  data = posts[year];
@@ -92,6 +102,7 @@ if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
92
102
  generate(url, new Query(data[0]), { year });
93
103
  if (!config.archive_generator.monthly && !config.archive_generator.daily)
94
104
  continue;
105
+ // Monthly
95
106
  for (month = 1; month <= 12; month++) {
96
107
  monthData = data[month];
97
108
  if (!monthData.length)
@@ -104,6 +115,7 @@ if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
104
115
  }
105
116
  if (!config.archive_generator.daily)
106
117
  continue;
118
+ // Daily
107
119
  for (let day = 1; day <= 31; day++) {
108
120
  const dayData = monthData.day[day];
109
121
  if (!dayData || !dayData.length)
@@ -3,19 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ /* global hexo */
6
7
  const hexo_util_1 = require("hexo-util");
7
8
  const node_fs_1 = __importDefault(require("node:fs"));
8
9
  const path_1 = __importDefault(require("path"));
9
10
  const js_yaml_1 = __importDefault(require("js-yaml"));
10
11
  hexo.extend.filter.register('before_generate', () => {
11
12
  if (hexo.config.theme_config) {
13
+ // @ts-ignore
12
14
  hexo.theme.config = (0, hexo_util_1.deepMerge)(hexo.theme.config, hexo.config.theme_config);
13
15
  }
14
16
  const data = hexo.locals.get('data');
15
17
  if (data.languages) {
18
+ // @ts-ignore
16
19
  const { i18n } = hexo.theme;
17
20
  const mergeLang = lang => {
18
- if (data.languages[lang]) {
21
+ if (data.languages[lang]) { // @ts-ignore
19
22
  i18n.set(lang, (0, hexo_util_1.deepMerge)(i18n.get([lang]), data.languages[lang]));
20
23
  }
21
24
  };
@@ -1,5 +1,7 @@
1
+ /* global hexo */
1
2
  'use strict';
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ // @ts-ignore
3
5
  const fs = require("hexo-fs");
4
6
  hexo.extend.generator.register('images', function (locals) {
5
7
  const theme = hexo.theme.config;
@@ -1,3 +1,5 @@
1
+ // @ts-nocheck
2
+ /* global hexo */
1
3
  'use strict';
2
4
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
5
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -15,7 +17,7 @@ hexo.extend.generator.register('index', function (locals) {
15
17
  let pages;
16
18
  const config = hexo.config;
17
19
  const sticky = locals.posts.find({ sticky: true }).sort(config.index_generator.order_by);
18
- const posts = locals.posts.find({ sticky: { $exists: false } }).sort(config.index_generator.order_by);
20
+ const posts = locals.posts.find({ sticky: { $in: [false, undefined] } }).sort(config.index_generator.order_by);
19
21
  const paginationDir = config.pagination_dir || 'page';
20
22
  const path = config.index_generator.path || '';
21
23
  const categories = locals.categories;
@@ -96,7 +98,8 @@ hexo.extend.generator.register('index', function (locals) {
96
98
  data: {
97
99
  __index: true,
98
100
  catlist,
99
- sticky
101
+ sticky,
102
+ current: 1,
100
103
  }
101
104
  }];
102
105
  }
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  hexo.extend.generator.register('pages', function () {
4
2
  const config = hexo.config;
5
3
  return [
@@ -1,16 +1,40 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const package_json_1 = __importDefault(require("../../package.json"));
7
- const fs = require("hexo-fs");
8
- const esbuild = require("esbuild");
26
+ /* global hexo */
27
+ // import env from '../../package.json'
28
+ const fs = __importStar(require("hexo-fs"));
29
+ const esbuild_1 = require("esbuild");
30
+ const env = {
31
+ version: '0.3.10'
32
+ };
9
33
  hexo.extend.generator.register('script', function (locals) {
10
34
  const config = hexo.config;
11
35
  const theme = hexo.theme.config;
12
36
  const siteConfig = {
13
- version: package_json_1.default.version,
37
+ version: env.version,
14
38
  hostname: config.url,
15
39
  root: config.root,
16
40
  statics: theme.statics,
@@ -27,6 +51,7 @@ hexo.extend.generator.register('script', function (locals) {
27
51
  fancybox: theme.vendors.js.fancybox
28
52
  },
29
53
  css: {
54
+ // valine: theme.css + '/comment.css',
30
55
  katex: theme.vendors.css.katex,
31
56
  mermaid: theme.css + '/mermaid.css',
32
57
  fancybox: theme.vendors.css.fancybox
@@ -45,8 +70,8 @@ hexo.extend.generator.register('script', function (locals) {
45
70
  disableVL: theme.disableVL,
46
71
  noPlayer: theme.experiments?.noPlayer,
47
72
  audio: undefined,
48
- fireworks: (theme.fireworks && theme.fireworks.enable)
49
- ? (theme.fireworks.color || ['rgba(255,182,185,.9)', 'rgba(250,227,217,.9)', 'rgba(187,222,214,.9)', 'rgba(138,198,209,.9)'])
73
+ fireworks: (theme.fireworks && theme.fireworks.enable && theme.fireworks.options)
74
+ ? theme.fireworks.options
50
75
  : undefined
51
76
  };
52
77
  if (config?.algolia) {
@@ -69,7 +94,7 @@ hexo.extend.generator.register('script', function (locals) {
69
94
  enterPoint = 'node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.js';
70
95
  }
71
96
  text = 'const CONFIG = ' + JSON.stringify(siteConfig) + ';';
72
- esbuild.buildSync({
97
+ (0, esbuild_1.buildSync)({
73
98
  entryPoints: [enterPoint],
74
99
  bundle: true,
75
100
  outfile: 'shokax_temp.js',
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ /* global hexo */
5
3
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const package_json_1 = __importDefault(require("../../package.json"));
4
+ // import theme_env from '../../package.json'
7
5
  const hexo_util_1 = require("hexo-util");
6
+ const theme_env = {
7
+ version: '0.3.10'
8
+ };
8
9
  hexo.extend.helper.register('_new_comments', function (mode) {
9
10
  const root = this.config.url.replace(/^(https?:\/\/)?[^\/]*/, '');
10
11
  if (mode === 'twikoo') {
@@ -85,7 +86,7 @@ hexo.extend.helper.register('hexo_env', function (type) {
85
86
  return this.env[type];
86
87
  });
87
88
  hexo.extend.helper.register('theme_env', function (type) {
88
- return package_json_1.default[type];
89
+ return theme_env[type];
89
90
  });
90
91
  hexo.extend.helper.register('_vendor_font', () => {
91
92
  const config = hexo.theme.config.font;
@@ -95,6 +96,7 @@ hexo.extend.helper.register('_vendor_font', () => {
95
96
  const fontSubset = '&subset=latin,latin-ext';
96
97
  const fontStyles = ':300,300italic,400,400italic,700,700italic';
97
98
  const fontHost = 'https://fonts.googleapis.com';
99
+ // Get a font list from config
98
100
  let fontFamilies = ['global', 'logo', 'title', 'headings', 'posts', 'codes'].map(item => {
99
101
  if (config[item] && config[item].family && config[item].external) {
100
102
  return config[item].family + fontStyles;
@@ -102,8 +104,11 @@ hexo.extend.helper.register('_vendor_font', () => {
102
104
  return '';
103
105
  });
104
106
  fontFamilies = fontFamilies.filter(item => item !== '');
107
+ // @ts-ignore
105
108
  fontFamilies = [...new Set(fontFamilies)];
109
+ // @ts-ignore
106
110
  fontFamilies = fontFamilies.join('|');
111
+ // Merge extra parameters to the final processed font string
107
112
  return fontFamilies
108
113
  ? (0, hexo_util_1.htmlTag)('link', {
109
114
  rel: 'stylesheet',
@@ -111,10 +116,12 @@ hexo.extend.helper.register('_vendor_font', () => {
111
116
  })
112
117
  : '';
113
118
  });
119
+ // TODO 废弃方法
114
120
  hexo.extend.helper.register('_vendor_js', () => {
115
121
  const config = hexo.theme.config.vendors.js;
116
122
  if (!config)
117
123
  return '';
124
+ // Get a font list from config
118
125
  let vendorJs = ['pace', 'pjax', 'fetch', 'anime', 'algolia', 'instantsearch', 'lazyload', 'quicklink'].map(item => {
119
126
  if (config[item]) {
120
127
  return config[item];
@@ -122,7 +129,9 @@ hexo.extend.helper.register('_vendor_js', () => {
122
129
  return '';
123
130
  });
124
131
  vendorJs = vendorJs.filter(item => item !== '');
132
+ // @ts-ignore
125
133
  vendorJs = [...new Set(vendorJs)];
134
+ // @ts-ignore
126
135
  vendorJs = vendorJs.join(',');
127
136
  return vendorJs ? (0, hexo_util_1.htmlTag)('script', { src: `https://cdn.jsdelivr.net/combine/${vendorJs}` }, '') : '';
128
137
  });
@@ -130,12 +139,12 @@ hexo.extend.helper.register('_css', function (...urls) {
130
139
  const { statics, css } = hexo.theme.config;
131
140
  return urls.map(url => (0, hexo_util_1.htmlTag)('link', {
132
141
  rel: 'stylesheet',
133
- href: hexo_util_1.url_for.call(this, `${statics}${css}/${url}?v=${package_json_1.default.version}`)
142
+ href: hexo_util_1.url_for.call(this, `${statics}${css}/${url}?v=${theme_env.version}`)
134
143
  })).join('');
135
144
  });
136
145
  hexo.extend.helper.register('_js', function (...urls) {
137
146
  const { statics, js } = hexo.theme.config;
138
- 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('');
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('');
139
148
  });
140
149
  hexo.extend.helper.register('_list_vendor_js', () => {
141
150
  return hexo.theme.config.vendorsList.js;
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ // @ts-ignore
3
4
  const hexo_util_1 = require("hexo-util");
4
5
  const randomServer = parseInt(String(Math.random() * 4), 10) + 1;
5
6
  const randomBG = function (count = 1, image_server = null, image_list = []) {
@@ -18,7 +19,7 @@ const randomBG = function (count = 1, image_server = null, image_list = []) {
18
19
  if (img.startsWith('//') || img.startsWith('http')) {
19
20
  return img;
20
21
  }
21
- else if (hexo.theme.config.experiments?.usingRelative) {
22
+ else if (hexo.theme.config.experiments?.usingRelative) { // support relative url
22
23
  return img;
23
24
  }
24
25
  else {
@@ -47,7 +48,9 @@ const randomBG = function (count = 1, image_server = null, image_list = []) {
47
48
  }
48
49
  return parseImage(image_list[Math.floor(Math.random() * image_list.length)], 'mw690');
49
50
  };
51
+ // 注册hexo主题中的URL帮助方法
50
52
  hexo.extend.helper.register('_url', function (path, text, options = {}) {
53
+ // 如果未提供URL路径,则返回
51
54
  if (!path) {
52
55
  return;
53
56
  }
@@ -59,6 +62,7 @@ hexo.extend.helper.register('_url', function (path, text, options = {}) {
59
62
  if (attrs.class && Array.isArray(attrs.class)) {
60
63
  attrs.class = attrs.class.join(' ');
61
64
  }
65
+ // 返回HTML标记字符串
62
66
  return (0, hexo_util_1.htmlTag)(tag, attrs, decodeURI(text), false);
63
67
  });
64
68
  hexo.extend.helper.register('_image_url', function (img, path = '') {
@@ -95,24 +99,43 @@ hexo.extend.helper.register('_cover_index', function (item) {
95
99
  return randomBG(1, image_server, index_images.length === 0 ? image_list : index_images);
96
100
  }
97
101
  });
102
+ // 注册hexo主题的永久链接帮助方法
98
103
  hexo.extend.helper.register('_permapath', function (str) {
104
+ // 获取hexo的永久链接配置
99
105
  const { permalink } = hexo.config;
106
+ // 将输入字符串中的'index.html'替换为空字符串
100
107
  let url = str.replace(/index\.html$/, '');
108
+ // 如果永久链接不以'.html'结尾,将输入字符串中的'.html'替换为空字符串
101
109
  if (!permalink.endsWith('.html')) {
102
110
  url = url.replace(/\.html$/, '');
103
111
  }
112
+ // 返回处理后的URL字符串
104
113
  return url;
105
114
  });
106
115
  hexo.extend.helper.register('canonical', function () {
107
116
  return `<link rel="canonical" href="${this._permapath(this.url)}">`;
108
117
  });
118
+ /**
119
+ * Get page path given a certain language tag
120
+ */
121
+ // 注册hexo主题的国际化路径帮助方法
109
122
  hexo.extend.helper.register('i18n_path', function (language) {
123
+ // 获取当前页面的path和lang
110
124
  const { path, lang } = this.page;
125
+ // 如果path以lang开头,则截取掉lang部分,作为基础路径
111
126
  const base = path.startsWith(lang) ? path.slice(lang.length + 1) : path;
127
+ // 通过调用url_for方法,生成国际化路径
112
128
  return hexo_util_1.url_for.call(this, `${this.languages.indexOf(language) === 0 ? '' : '/' + language}/${base}`);
113
129
  });
130
+ /**
131
+ * Get the language name
132
+ */
133
+ // 注册hexo主题的语言名称帮助方法
114
134
  hexo.extend.helper.register('language_name', function (language) {
135
+ // 从主题配置中获取指定语言的名称
136
+ // @ts-ignore
115
137
  const name = hexo.theme.i18n.__(language)('name');
138
+ // 如果名称为默认值'name',则返回语言代码,否则返回语言名称
116
139
  return name === 'name' ? language : name;
117
140
  });
118
141
  hexo.extend.helper.register('random_color', function () {