hexo-theme-shokax 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. package/.eslintrc.cjs +5 -3
  2. package/README.md +11 -2
  3. package/_config.yml +12 -12
  4. package/layout/_mixin/comment.pug +1 -2
  5. package/layout/_mixin/widgets.pug +1 -1
  6. package/layout/_partials/layout.pug +23 -23
  7. package/package.json +27 -19
  8. package/scripts/generaters/script.js +17 -50
  9. package/scripts/helpers/asset.js +5 -2
  10. package/scripts/helpers/summary_ai.js +0 -1
  11. package/scripts/plugin/index.js +2 -2
  12. package/source/css/_common/scaffolding/normalize.styl +165 -180
  13. package/source/js/_app/components/sidebar.js +49 -35
  14. package/source/js/_app/fireworks.js +32 -19
  15. package/source/js/_app/globals/globalVars.js +91 -26
  16. package/source/js/_app/globals/handles.js +54 -42
  17. package/source/js/_app/globals/themeColor.js +22 -12
  18. package/source/js/_app/globals/thirdparty.js +17 -7
  19. package/source/js/_app/globals/tools.js +25 -14
  20. package/source/js/_app/library/anime.js +13 -3
  21. package/source/js/_app/library/dom.js +5 -0
  22. package/source/js/_app/library/loadFile.js +7 -1
  23. package/source/js/_app/library/proto.js +108 -102
  24. package/source/js/_app/library/scriptPjax.js +18 -10
  25. package/source/js/_app/library/storage.js +4 -1
  26. package/source/js/_app/library/vue.js +16 -9
  27. package/source/js/_app/page/comment.js +14 -7
  28. package/source/js/_app/page/common.js +13 -7
  29. package/source/js/_app/page/fancybox.js +12 -6
  30. package/source/js/_app/page/post.js +43 -29
  31. package/source/js/_app/page/search.js +21 -14
  32. package/source/js/_app/page/tab.js +9 -3
  33. package/source/js/_app/pjax/domInit.js +36 -23
  34. package/source/js/_app/pjax/refresh.js +48 -30
  35. package/source/js/_app/pjax/siteInit.js +30 -13
  36. package/source/js/_app/player.js +29 -16
  37. package/test/dom.test.js +86 -0
package/.eslintrc.cjs CHANGED
@@ -9,11 +9,13 @@ module.exports = {
9
9
  extends: [
10
10
  'standard',
11
11
  'plugin:@typescript-eslint/recommended',
12
- 'plugin:vue/vue3-recommended'
12
+ 'plugin:vue/vue3-recommended',
13
+ 'plugin:chai-friendly/recommended'
13
14
  ],
14
15
  plugins: [
15
16
  '@typescript-eslint',
16
- 'vue'
17
+ 'vue',
18
+ 'chai-friendly'
17
19
  ],
18
20
  parserOptions: {
19
21
  ecmaVersion: 12
@@ -25,6 +27,6 @@ module.exports = {
25
27
  '@typescript-eslint/ban-ts-comment': 'off',
26
28
  '@typescript-eslint/no-var-requires': 'off',
27
29
  '@typescript-eslint/no-unused-vars': 'off',
28
- 'prefer-const': 'warn'
30
+ 'prefer-const': 'off'
29
31
  }
30
32
  }
package/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 📣 公告
2
+ * [ShokaX 正在寻找社区维护者](https://github.com/theme-shoka-x/hexo-theme-shokaX/discussions/137)
3
+
1
4
  # hexo-theme-shokaX
2
5
  [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fzkz098%2Fhexo-theme-shokaX.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fzkz098%2Fhexo-theme-shokaX?ref=badge_shield)
3
6
  ![LICENSE]( https://img.shields.io/github/license/theme-shoka-x/hexo-theme-shokaX)
@@ -47,6 +50,13 @@ github仓库建议通过右边的 releases 下载,步骤为:
47
50
  - 下载 Assets 中的 `Source code(zip)`
48
51
  - 解压即可作为主题使用
49
52
 
53
+ ## 📚子项目
54
+ - [ShokaX docs](https://github.com/theme-shoka-x/shokaX-docs) ShokaX 主题文档 (正在编写中,欢迎加入!)
55
+ - [HRMNMI](https://github.com/theme-shoka-x/hexo-renderer-multi-next-markdown-it) ShokaX 正在使用的 markdown 渲染器 (等待重构)
56
+ - [ShokaX CLI](https://github.com/theme-shoka-x/shokaX-CLI) ShokaX 命令行安装程序
57
+ - [ShokaX Pjax](https://github.com/theme-shoka-x/theme-shokax-pjax) ShokaX 提供的高效 Pjax 实现
58
+ - [ShokaX Anime](https://github.com/theme-shoka-x/theme-shokax-anime) ShokaX 提供的精简版 Anime.js 实现
59
+
50
60
  ## 🛠️二次开发
51
61
  [ShokaX官方开发文档](https://docs.kaitaku.xyz/develop/basic/)
52
62
 
@@ -58,8 +68,7 @@ github仓库建议通过右边的 releases 下载,步骤为:
58
68
  - [Easy hexo](https://easyhexo.com/)
59
69
 
60
70
  # 许可证
61
- 许可证: AGPL 3 or later \
62
- [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fzkz098%2Fhexo-theme-shokaX.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fzkz098%2Fhexo-theme-shokaX?ref=badge_large)
71
+ 许可证: AGPL 3 or later
63
72
 
64
73
  ## 特别说明
65
74
  AGPL许可证主要目的是限制修改后的分发行为,避免未经许可的二次修改封装商业行为 \
package/_config.yml CHANGED
@@ -358,18 +358,18 @@ advVendors:
358
358
  js:
359
359
  pace:
360
360
  src: bytedance:pace/1.0.2/pace.min.js
361
- pjax:
362
- src: npm:theme-shokax-pjax@latest/pjax.shokax.min.js
361
+ # pjax:
362
+ # src: npm:theme-shokax-pjax@latest/pjax.shokax.min.js
363
363
  fetch:
364
364
  src: npm:whatwg-fetch@3.4.0/dist/fetch.umd.js
365
- anime:
366
- src: npm:theme-shokax-anime@latest/anime.shokax.min.js
365
+ # anime:
366
+ # src: npm:theme-shokax-anime@latest/anime.shokax.min.js
367
367
  algolia:
368
368
  src: bytedance:algoliasearch/4.12.1/algoliasearch-lite.umd.min.js
369
369
  instantsearch:
370
370
  src: bytedance:instantsearch.js/4.39.0/instantsearch.production.min.js
371
- lazyload:
372
- src: bytedance:lozad.js/1.16.0/lozad.min.js
371
+ # lazyload:
372
+ # src: bytedance:lozad.js/1.16.0/lozad.min.js
373
373
  quicklink:
374
374
  src: bytedance:quicklink/2.2.0/quicklink.umd.min.js
375
375
  fancybox:
@@ -388,11 +388,11 @@ advVendors:
388
388
  vendorsList:
389
389
  js:
390
390
  - pace
391
- - pjax
392
- - anime
391
+ # - pjax
392
+ # - anime
393
393
  - algolia
394
394
  - instantsearch
395
- - lazyload
395
+ # - lazyload
396
396
  - quicklink
397
397
  - fancybox
398
398
  - copy_tex
@@ -405,12 +405,12 @@ vendors:
405
405
 
406
406
  js:
407
407
  pace: npm/pace-js@1.0.2/pace.min.js # ok
408
- pjax: npm/theme-shokax-pjax@latest/pjax.shokax.min.js # ok
408
+ # pjax: npm/theme-shokax-pjax@latest/pjax.shokax.min.js # ok
409
409
  fetch: npm/whatwg-fetch@3.4.0/dist/fetch.umd.min.js # ok
410
- anime: npm/theme-shokax-anime@latest/anime.shokax.min.js
410
+ # anime: npm/theme-shokax-anime@latest/anime.shokax.min.js
411
411
  algolia: npm/algoliasearch@4/dist/algoliasearch-lite.umd.js # ok
412
412
  instantsearch: npm/instantsearch.js@4/dist/instantsearch.production.min.js # ok
413
- lazyload: npm/lozad@1/dist/lozad.min.js # ok
413
+ # lazyload: npm/lozad@1/dist/lozad.min.js # ok
414
414
  quicklink: npm/quicklink@2/dist/quicklink.umd.js # ok
415
415
  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
416
416
  valine: gh/amehime/MiniValine@4.2.2-beta10/dist/MiniValine.min.js # TODO 弃用
@@ -21,7 +21,6 @@ mixin CommentRender()
21
21
  script(type="module" data-pjax).
22
22
  import { init } from 'https://unpkg.com/@waline/client@v2/dist/waline.mjs';
23
23
 
24
- const path = document.getElementById("twikoo_visitors").getAttribute("data-path");
25
24
  setTimeout(function () {
26
25
  init({
27
26
  el: '#wcomments',
@@ -34,7 +33,7 @@ mixin CommentRender()
34
33
  wordLimit: #{theme.waline.wordLimit},
35
34
  pageSize: #{theme.waline.pageSize},
36
35
  pageview: #{theme.waline.pageview},
37
- path: path,
36
+ path: window.location.pathname,
38
37
  dark: 'html[data-theme="dark"]'
39
38
  });
40
39
  }, 1000)
@@ -26,7 +26,7 @@ mixin WRender(item)
26
26
  ul(class="leancloud-recent-comment" id="new-comment")
27
27
  if tk || waline
28
28
  li(v-for="com in coms" class="item")
29
- a(v-bind:href="com.href" data-pjax-state="data-pjax-state")
29
+ a(v-bind:href="root + com.href" data-pjax-state="data-pjax-state")
30
30
  span(class="breadcrumb") {{com.nick}} @ {{com.time}}
31
31
  span {{com.text}}
32
32
  br
@@ -73,17 +73,17 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
73
73
  - var ccText = theme.creative_commons.license.toUpperCase()
74
74
  script(data-config type="text/javascript").
75
75
  var LOCAL = {
76
- path: `#{_permapath(page.path)}`,
77
- favicon: {
78
- show: `#{__('favicon.show')}`,
79
- hide: `#{__('favicon.hide')}`
80
- },
81
- search: {
82
- placeholder: "!{__('search.placeholder')}",
83
- empty: "!{__('search.empty')}",
84
- stats: "!{__('search.stats')}"
85
- },
86
- valine: #{page.valine ? _safedump(page.valine) : true},
76
+ path: `#{_permapath(page.path)}`,
77
+ favicon: {
78
+ show: `#{__('favicon.show')}`,
79
+ hide: `#{__('favicon.hide')}`
80
+ },
81
+ search: {
82
+ placeholder: "!{__('search.placeholder')}",
83
+ empty: "!{__('search.empty')}",
84
+ stats: "!{__('search.stats')}"
85
+ },
86
+ valine: #{page.valine ? _safedump(page.valine) : true},
87
87
  chart: #{!!page.chart},
88
88
  copy_tex: #{!!page.math},
89
89
  katex: #{!!page.math},
@@ -94,18 +94,18 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
94
94
  outime: #{page.outime !== false},
95
95
  template: `#{__('outime.template')}`,
96
96
  quiz: {
97
- choice: `#{__('quiz.choice')}`,
98
- multiple: `#{__('quiz.multiple')}`,
99
- true_false: `#{__('quiz.true_false')}`,
100
- essay: `#{__('quiz.essay')}`,
101
- gap_fill: `#{__('quiz.gap_fill')}`,
102
- mistake: `#{__('quiz.mistake')}`
103
- },
104
- ignores: [
105
- (uri) => uri.includes('#'),
106
- (uri) => new RegExp(LOCAL.path + '$').test(uri),
107
- !{JSON.stringify(ignores)}
108
- ]
97
+ choice: `#{__('quiz.choice')}`,
98
+ multiple: `#{__('quiz.multiple')}`,
99
+ true_false: `#{__('quiz.true_false')}`,
100
+ essay: `#{__('quiz.essay')}`,
101
+ gap_fill: `#{__('quiz.gap_fill')}`,
102
+ mistake: `#{__('quiz.mistake')}`
103
+ },
104
+ ignores: [
105
+ (uri) => uri.includes('#'),
106
+ (uri) => new RegExp(LOCAL.path + '$').test(uri),
107
+ !{JSON.stringify(ignores)}
108
+ ]
109
109
  };
110
110
 
111
111
  if theme.polyfill.enable
package/package.json CHANGED
@@ -1,43 +1,51 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
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": "tsc",
10
+ "test": "mocha test --coverage",
11
11
  "build": "pnpm install && tsc"
12
12
  },
13
13
  "devDependencies": {
14
+ "@types/chai": "^4.3.5",
14
15
  "@types/fancybox": "^3.5.3",
15
16
  "@types/hexo": "^3.8.8",
16
17
  "@types/jquery": "^3.5.16",
17
18
  "@types/js-yaml": "^4.0.5",
18
19
  "@types/lozad": "^1.16.1",
19
- "@types/node": "^20.2.3",
20
- "@typescript-eslint/eslint-plugin": "^6.0.0",
21
- "@typescript-eslint/parser": "^5.59.7",
22
- "eslint": "^8.41.0",
20
+ "@types/mocha": "^10.0.1",
21
+ "@types/node": "^20.4.4",
22
+ "@typescript-eslint/eslint-plugin": "^6.2.0",
23
+ "@typescript-eslint/parser": "^6.2.0",
24
+ "chai": "^4.3.7",
25
+ "eslint": "^8.45.0",
23
26
  "eslint-config-standard": "*",
27
+ "eslint-plugin-chai-friendly": "^0.7.2",
24
28
  "eslint-plugin-import": "^2.27.5",
25
- "eslint-plugin-n": "^16.0.0",
29
+ "eslint-plugin-n": "^16.0.1",
26
30
  "eslint-plugin-promise": "^6.1.1",
27
- "eslint-plugin-vue": "^9.14.0",
31
+ "eslint-plugin-vue": "^9.15.1",
28
32
  "hexo-fs": "^4.1.1",
29
- "hexo-util": "^3.0.1",
30
- "instantsearch.js": "^4.56.0",
31
- "theme-shokax-anime": "^0.0.4",
32
- "theme-shokax-pjax": "^0.0.2",
33
- "typescript": "^5.0.4",
34
- "vue": "^3.3.4"
33
+ "hexo-util": "^3.1.0",
34
+ "instantsearch.js": "^4.56.7",
35
+ "mocha": "^10.2.0",
36
+ "typescript": "^5.1.6",
37
+ "vue": "^3.3.4",
38
+ "jsdom": "^22.1.0"
35
39
  },
36
40
  "dependencies": {
37
- "js-yaml": "^4.1.0"
41
+ "esbuild": "^0.18.17",
42
+ "js-yaml": "^4.1.0",
43
+ "lozad": "^1.16.0",
44
+ "theme-shokax-anime": "^0.0.4",
45
+ "theme-shokax-pjax": "^0.0.2"
46
+ },
47
+ "engines": {
48
+ "node": ">=18.0.0"
38
49
  },
39
- "engines": {
40
- "node": ">=18.0.0"
41
- },
42
- "engineStrict": true
50
+ "engineStrict": true
43
51
  }
@@ -5,26 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const package_json_1 = __importDefault(require("../../package.json"));
7
7
  const fs = require("hexo-fs");
8
- const node_path_1 = __importDefault(require("node:path"));
9
- function findJsFile(path) {
10
- console.log(path);
11
- let result = [];
12
- fs.readdirSync(path).forEach((item) => {
13
- console.log(item);
14
- if (!item.endsWith('js')) {
15
- result = result.concat(findJsFile(node_path_1.default.join(path, item)));
16
- }
17
- else {
18
- if (item.indexOf('player') === -1 && item.indexOf('fireworks') === -1) {
19
- console.log('push');
20
- result.push(node_path_1.default.join(path, item));
21
- }
22
- }
23
- });
24
- return result;
25
- }
8
+ const esbuild = require("esbuild");
26
9
  hexo.extend.generator.register('script', function (locals) {
27
- const log = hexo.log || console.log;
28
10
  const config = hexo.config;
29
11
  const theme = hexo.theme.config;
30
12
  const siteConfig = {
@@ -62,6 +44,7 @@ hexo.extend.generator.register('script', function (locals) {
62
44
  },
63
45
  playerAPI: theme.playerAPI,
64
46
  disableVL: theme.disableVL,
47
+ noPlayer: theme.experiments?.noPlayer,
65
48
  audio: undefined,
66
49
  fireworks: undefined
67
50
  };
@@ -76,42 +59,26 @@ hexo.extend.generator.register('script', function (locals) {
76
59
  if (theme?.audio) {
77
60
  siteConfig.audio = theme.audio;
78
61
  }
79
- let text = '';
80
- let path = '';
81
- if (fs.existsSync('themes/shokaX/source/js/_app/library/dom.js')) {
82
- path = 'themes/shokaX/source/js/_app';
62
+ let text;
63
+ let enterPoint;
64
+ if (fs.existsSync('themes/shokaX/source/js/_app/pjax/siteInit.js')) {
65
+ enterPoint = 'themes/shokaX/source/js/_app/pjax/siteInit.js';
83
66
  }
84
67
  else {
85
- path = 'node_modules/hexo-theme-shokax/source/js/_app';
68
+ enterPoint = 'node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.js';
86
69
  }
87
- let files = findJsFile(node_path_1.default.join(path, 'library'));
88
- files = files.concat(findJsFile(node_path_1.default.join(path, 'globals')));
89
- files = files.concat(findJsFile(node_path_1.default.join(path, 'page')));
90
- files = files.concat(findJsFile(node_path_1.default.join(path, 'pjax')));
91
- files = files.concat(findJsFile(node_path_1.default.join(path, 'components')));
92
- console.log(files);
93
- files.forEach(function (item) {
94
- text += fs.readFileSync(item).toString();
70
+ text = 'const CONFIG = ' + JSON.stringify(siteConfig) + ';';
71
+ esbuild.buildSync({
72
+ entryPoints: [enterPoint],
73
+ bundle: true,
74
+ outfile: 'shokax_temp.js',
75
+ platform: 'browser',
76
+ target: ['es2021'],
77
+ minify: true
95
78
  });
96
- if (!theme.experiments?.noPlayer) {
97
- if (fs.existsSync('themes/shokaX/source/js/_app/player.js')) {
98
- text += fs.readFileSync('themes/shokaX/source/js/_app/player.js').toString();
99
- }
100
- else {
101
- text += fs.readFileSync('node_modules/hexo-theme-shokax/source/js/_app/player.js').toString();
102
- }
103
- }
104
- if (theme.fireworks && theme.fireworks.enable) {
105
- if (fs.existsSync('themes/shokaX/source/js/_app/fireworks.js')) {
106
- text += fs.readFileSync('themes/shokaX/source/js/_app/fireworks.js').toString();
107
- }
108
- else {
109
- text += fs.readFileSync('node_modules/hexo-theme-shokax/source/js/_app/fireworks.js').toString();
110
- }
111
- siteConfig.fireworks = theme.fireworks.color || ['rgba(255,182,185,.9)', 'rgba(250,227,217,.9)', 'rgba(187,222,214,.9)', 'rgba(138,198,209,.9)'];
112
- }
113
- text = 'const CONFIG = ' + JSON.stringify(siteConfig) + ';' + text;
79
+ text += fs.readFileSync('shokax_temp.js');
114
80
  const result = hexo.render.renderSync({ text, engine: 'js' });
81
+ fs.unlinkSync('shokax_temp.js');
115
82
  return {
116
83
  path: theme.js + '/app.js',
117
84
  data: function () {
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const package_json_1 = __importDefault(require("../../package.json"));
7
7
  const hexo_util_1 = require("hexo-util");
8
8
  hexo.extend.helper.register('_new_comments', function (mode) {
9
+ const root = this.config.url.replace(/^(https?:\/\/)?[^\/]*/, '');
9
10
  if (mode === 'twikoo') {
10
11
  return `<script data-pjax type="module">
11
12
  let comments = []
@@ -29,7 +30,8 @@ hexo.extend.helper.register('_new_comments', function (mode) {
29
30
  Vue.createApp({
30
31
  data() {
31
32
  return {
32
- coms: comments
33
+ coms: comments,
34
+ root: '${root}'
33
35
  }
34
36
  }
35
37
  }).mount('#new-comment')
@@ -61,7 +63,8 @@ hexo.extend.helper.register('_new_comments', function (mode) {
61
63
  Vue.createApp({
62
64
  data() {
63
65
  return {
64
- coms: items
66
+ coms: items,
67
+ root: '${root}'
65
68
  }
66
69
  }
67
70
  }).mount('#new-comment')
@@ -47,7 +47,6 @@ function postMessage(path, content, dbPath, startMessage) {
47
47
  db ??= {};
48
48
  db[path] ??= {};
49
49
  db[path][dbPath] ??= '';
50
- console.log(db[path]);
51
50
  db[path][dbPath] = summary;
52
51
  }
53
52
  node_fs_1.default.writeFileSync('summary.json', JSON.stringify(db));
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
- index.js in next-theme/hexo-theme-next by theme-next
4
- under GNU AFFERO GENERAL PUBLIC LICENSE v3.0
3
+ index.js in next-theme/hexo-theme-next by next-theme
4
+ under GNU AFFERO GENERAL PUBLIC LICENSE v3.0 OR LATER
5
5
  https://github.com/next-theme/hexo-theme-next/blob/master/LICENSE.md
6
6
  */
7
7
  var __importDefault = (this && this.__importDefault) || function (mod) {