hexo-theme-shokax 0.4.6-dev6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. package/CODE_OF_CONDUCT.md +128 -128
  2. package/CONTRIBUTING.md +58 -58
  3. package/LICENSE +660 -660
  4. package/LICENSE-shoka +21 -21
  5. package/README.md +76 -99
  6. package/README_en.MD +75 -91
  7. package/UsageRestrictions.md +25 -25
  8. package/_config.yml +381 -381
  9. package/_images.yml +9 -9
  10. package/eslint.config.mjs +55 -55
  11. package/languages/README.md +19 -19
  12. package/languages/default.yml +1 -1
  13. package/languages/en.yml +153 -153
  14. package/languages/ja.yml +153 -153
  15. package/languages/zh-CN.yml +153 -153
  16. package/languages/zh-HK.yml +153 -153
  17. package/languages/zh-TW.yml +153 -153
  18. package/layout/_alternate/atom.ejs +30 -30
  19. package/layout/_alternate/json.ejs +16 -16
  20. package/layout/_alternate/rss.ejs +34 -34
  21. package/layout/_mixin/breadcrumb.pug +33 -33
  22. package/layout/_mixin/card.pug +38 -38
  23. package/layout/_mixin/comment.pug +6 -6
  24. package/layout/_mixin/postmeta.pug +29 -29
  25. package/layout/_mixin/segment.pug +35 -35
  26. package/layout/_mixin/sidebar.pug +40 -40
  27. package/layout/_mixin/widgets.pug +28 -28
  28. package/layout/_partials/footer.pug +43 -43
  29. package/layout/_partials/head/head.pug +55 -55
  30. package/layout/_partials/head/head_com.pug +24 -24
  31. package/layout/_partials/head/pwa.pug +18 -18
  32. package/layout/_partials/header.pug +18 -18
  33. package/layout/_partials/layout.pug +140 -140
  34. package/layout/_partials/loading.pug +13 -13
  35. package/layout/_partials/pagination.pug +4 -4
  36. package/layout/_partials/post/copyright.pug +20 -20
  37. package/layout/_partials/post/footer.pug +17 -17
  38. package/layout/_partials/post/nav.pug +13 -13
  39. package/layout/_partials/post/post.pug +41 -41
  40. package/layout/_partials/post/reward.pug +18 -18
  41. package/layout/_partials/sidebar/menu.pug +37 -37
  42. package/layout/_partials/sidebar/overview.pug +42 -42
  43. package/layout/_partials/third-party/baidu-analytics.pug +11 -11
  44. package/layout/_partials/third-party/clarity.pug +8 -8
  45. package/layout/_partials/third-party/google-analytics.pug +9 -9
  46. package/layout/archive.pug +118 -118
  47. package/layout/category.pug +59 -59
  48. package/layout/index.pug +33 -33
  49. package/layout/page.pug +55 -55
  50. package/layout/post.pug +36 -36
  51. package/layout/tag.pug +43 -43
  52. package/package.json +71 -72
  53. package/scripts/filters/locals.js +52 -0
  54. package/scripts/filters/post.js +5 -0
  55. package/scripts/generaters/archive.js +133 -0
  56. package/scripts/generaters/config.js +51 -0
  57. package/scripts/generaters/images.js +23 -0
  58. package/scripts/generaters/index.js +107 -0
  59. package/scripts/generaters/pages.js +15 -0
  60. package/scripts/generaters/script.js +156 -0
  61. package/scripts/helpers/asset.js +73 -0
  62. package/scripts/helpers/engine.js +177 -0
  63. package/scripts/helpers/list_categories.js +80 -0
  64. package/scripts/helpers/summary_ai.js +107 -0
  65. package/scripts/helpers/symbols_count_time.js +69 -0
  66. package/scripts/plugin/check.js +32 -0
  67. package/scripts/plugin/index.js +81 -0
  68. package/scripts/plugin/lib/injects-point.js +20 -0
  69. package/scripts/plugin/lib/injects.js +89 -0
  70. package/scripts/tags/links.js +44 -0
  71. package/scripts/tags/media.js +19 -0
  72. package/scripts/utils.js +13 -0
  73. package/source/assets/algolia_logo.svg +9 -9
  74. package/source/assets/logo.svg +16 -16
  75. package/source/css/_colors.styl +207 -207
  76. package/source/css/_common/components/components.styl +6 -6
  77. package/source/css/_common/components/highlight/highlight.styl +357 -357
  78. package/source/css/_common/components/highlight/operation.styl +21 -21
  79. package/source/css/_common/components/pages/collapse.styl +119 -119
  80. package/source/css/_common/components/pages/home.styl +391 -391
  81. package/source/css/_common/components/pages/pages.styl +56 -56
  82. package/source/css/_common/components/pages/tag-cloud.styl +12 -12
  83. package/source/css/_common/components/post/breadcrumb.styl +39 -39
  84. package/source/css/_common/components/post/copyright.styl +41 -41
  85. package/source/css/_common/components/post/expand.styl +263 -263
  86. package/source/css/_common/components/post/footer.styl +11 -11
  87. package/source/css/_common/components/post/header.styl +79 -79
  88. package/source/css/_common/components/post/nav.styl +64 -64
  89. package/source/css/_common/components/post/post.styl +29 -29
  90. package/source/css/_common/components/post/reward.styl +50 -50
  91. package/source/css/_common/components/post/rtl.styl +12 -12
  92. package/source/css/_common/components/post/tags.styl +39 -39
  93. package/source/css/_common/components/tags/collapse.styl +72 -72
  94. package/source/css/_common/components/tags/container.styl +49 -49
  95. package/source/css/_common/components/tags/label.styl +12 -12
  96. package/source/css/_common/components/tags/links.styl +77 -77
  97. package/source/css/_common/components/tags/list.styl +131 -131
  98. package/source/css/_common/components/tags/note.styl +70 -70
  99. package/source/css/_common/components/tags/player.styl +361 -361
  100. package/source/css/_common/components/tags/quiz.styl +200 -200
  101. package/source/css/_common/components/tags/tabs.styl +89 -89
  102. package/source/css/_common/components/tags/tags.styl +9 -9
  103. package/source/css/_common/components/third-party/loading.styl +222 -222
  104. package/source/css/_common/components/third-party/mermaid/class.styl +90 -90
  105. package/source/css/_common/components/third-party/mermaid/flowchart.styl +72 -72
  106. package/source/css/_common/components/third-party/mermaid/gantt.styl +251 -251
  107. package/source/css/_common/components/third-party/mermaid/git.styl +7 -7
  108. package/source/css/_common/components/third-party/mermaid/mermaid.styl +37 -37
  109. package/source/css/_common/components/third-party/mermaid/pie.styl +9 -9
  110. package/source/css/_common/components/third-party/mermaid/sequence.styl +95 -95
  111. package/source/css/_common/components/third-party/mermaid/state.styl +130 -130
  112. package/source/css/_common/components/third-party/pace.styl +18 -18
  113. package/source/css/_common/components/third-party/search.styl +167 -167
  114. package/source/css/_common/components/third-party/theme.styl +151 -151
  115. package/source/css/_common/components/third-party/third-party.styl +22 -22
  116. package/source/css/_common/components/third-party/widgets.styl +57 -57
  117. package/source/css/_common/outline/footer/footer.styl +67 -67
  118. package/source/css/_common/outline/header/brand.styl +77 -77
  119. package/source/css/_common/outline/header/header.styl +20 -20
  120. package/source/css/_common/outline/header/image.styl +85 -85
  121. package/source/css/_common/outline/header/menu.styl +117 -117
  122. package/source/css/_common/outline/header/nav.styl +81 -81
  123. package/source/css/_common/outline/header/right.styl +15 -15
  124. package/source/css/_common/outline/header/tool.styl +207 -207
  125. package/source/css/_common/outline/header/waves.styl +57 -57
  126. package/source/css/_common/outline/mobile.styl +46 -46
  127. package/source/css/_common/outline/outline.styl +78 -78
  128. package/source/css/_common/outline/sidebar/author.styl +59 -59
  129. package/source/css/_common/outline/sidebar/dimmer.styl +23 -23
  130. package/source/css/_common/outline/sidebar/menu.styl +63 -63
  131. package/source/css/_common/outline/sidebar/quick.styl +43 -43
  132. package/source/css/_common/outline/sidebar/related.styl +56 -56
  133. package/source/css/_common/outline/sidebar/sidebar.styl +80 -80
  134. package/source/css/_common/outline/sidebar/social.styl +69 -69
  135. package/source/css/_common/outline/sidebar/state.styl +37 -37
  136. package/source/css/_common/outline/sidebar/tab.styl +71 -71
  137. package/source/css/_common/outline/sidebar/toc.styl +47 -47
  138. package/source/css/_common/scaffolding/animate.styl +322 -322
  139. package/source/css/_common/scaffolding/base.styl +190 -190
  140. package/source/css/_common/scaffolding/buttons.styl +48 -48
  141. package/source/css/_common/scaffolding/divider.styl +36 -36
  142. package/source/css/_common/scaffolding/iconfont.styl +443 -443
  143. package/source/css/_common/scaffolding/normalize.styl +273 -273
  144. package/source/css/_common/scaffolding/pagination.styl +81 -81
  145. package/source/css/_common/scaffolding/ribbon.styl +38 -38
  146. package/source/css/_common/scaffolding/scaffolding.styl +14 -14
  147. package/source/css/_common/scaffolding/scrollbar.styl +37 -37
  148. package/source/css/_common/scaffolding/tables.styl +50 -50
  149. package/source/css/_common/scaffolding/tip.styl +19 -19
  150. package/source/css/_common/scaffolding/toggles.styl +59 -59
  151. package/source/css/_iconfont.styl +455 -455
  152. package/source/css/_mixins.styl +148 -148
  153. package/source/css/_variables.styl +89 -89
  154. package/source/css/app.styl +41 -41
  155. package/source/css/mermaid.styl +5 -5
  156. package/source/css/optimize.styl +5 -5
  157. package/source/js/_app/components/comments.ts +88 -88
  158. package/source/js/_app/components/sidebar.ts +239 -239
  159. package/source/js/_app/components/tcomments.ts +54 -54
  160. package/source/js/_app/globals/globalVars.ts +99 -99
  161. package/source/js/_app/globals/handles.ts +124 -124
  162. package/source/js/_app/globals/themeColor.ts +63 -63
  163. package/source/js/_app/globals/thirdparty.ts +63 -63
  164. package/source/js/_app/globals/tools.ts +75 -75
  165. package/source/js/_app/library/anime.ts +110 -110
  166. package/source/js/_app/library/declare.d.ts +128 -128
  167. package/source/js/_app/library/dom.ts +28 -28
  168. package/source/js/_app/library/loadFile.ts +47 -47
  169. package/source/js/_app/library/proto.ts +137 -137
  170. package/source/js/_app/library/scriptPjax.ts +72 -72
  171. package/source/js/_app/library/storage.ts +12 -12
  172. package/source/js/_app/library/vue.ts +49 -49
  173. package/source/js/_app/page/common.ts +43 -43
  174. package/source/js/_app/page/fancybox.ts +72 -72
  175. package/source/js/_app/page/post.ts +266 -266
  176. package/source/js/_app/page/search.ts +115 -115
  177. package/source/js/_app/page/tab.ts +60 -60
  178. package/source/js/_app/pjax/domInit.ts +97 -97
  179. package/source/js/_app/pjax/refresh.ts +140 -140
  180. package/source/js/_app/pjax/siteInit.ts +106 -106
  181. package/source/js/_app/player.ts +798 -798
  182. package/toolbox/compiler.mjs +10 -19
  183. package/toolbox/hoistdep.mjs +5 -5
  184. package/toolbox/lib.mjs +63 -63
  185. package/index.html +0 -231
  186. package/meta.json +0 -6431
@@ -0,0 +1,52 @@
1
+ // @ts-ignore
2
+ const fmtNum = (num) => {
3
+ return num < 10 ? '0' + num : num;
4
+ };
5
+ hexo.extend.filter.register('template_locals', (locals) => {
6
+ const { config } = hexo;
7
+ const { __, theme } = locals;
8
+ // @ts-ignore
9
+ const { i18n } = hexo.theme;
10
+ const pangu = {
11
+ spacing: (data) => {
12
+ return data;
13
+ }
14
+ };
15
+ // Language & Config
16
+ // 根据主题配置的 Creative Commons 许可证生成链接
17
+ locals.alternate = theme.alternate;
18
+ locals.title = pangu.spacing(__('title') !== 'title' ? __('title') : config.title);
19
+ locals.subtitle = pangu.spacing(__('subtitle') !== 'subtitle' ? __('subtitle') : config.subtitle);
20
+ locals.author = __('author') !== 'author' ? __('author') : config.author;
21
+ locals.description = pangu.spacing(__('description') !== 'description' ? __('description') : config.description);
22
+ locals.languages = [...i18n.languages];
23
+ locals.languages.splice(locals.languages.indexOf('default'), 1);
24
+ locals.page.lang = locals.page.lang || locals.page.language;
25
+ locals.hostname = new URL(config.url).hostname || config.url;
26
+ // Creative Commons
27
+ // 根据主题配置的 Creative Commons 许可证生成链接
28
+ if (theme.creative_commons.license === 'zero') {
29
+ locals.ccURL = 'https://creativecommons.org/' + 'publicdomain/zero/1.0/' + (theme.creative_commons.language || '');
30
+ }
31
+ else {
32
+ locals.ccURL = 'https://creativecommons.org/' + 'licenses/' + theme.creative_commons.license + '/4.0/' + (theme.creative_commons.language || '');
33
+ }
34
+ if (locals.page.title) {
35
+ locals.page.title = pangu.spacing(locals.page.title);
36
+ }
37
+ locals.page.lastcat = '';
38
+ if (locals.page.categories) {
39
+ locals.page.categories.map((cat) => {
40
+ if (cat.name) {
41
+ cat.name = locals.page.lastcat = pangu.spacing(cat.name);
42
+ }
43
+ return cat;
44
+ });
45
+ }
46
+ if (locals.page.category) {
47
+ locals.page.title = pangu.spacing(locals.page.category);
48
+ }
49
+ if (locals.page.month) {
50
+ locals.page.month = fmtNum(locals.page.month);
51
+ }
52
+ });
@@ -0,0 +1,5 @@
1
+ /* global hexo */
2
+ hexo.extend.filter.register('after_post_render', (data) => {
3
+ // 使用正则表达式将<img>标签的src属性替换为data-src属性
4
+ data.content = data.content.replace(/(<img[^>]*) src=/img, '$1 loading="lazy" data-src=');
5
+ }, 0);
@@ -0,0 +1,133 @@
1
+ /* global hexo */
2
+ 'use strict';
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ // @ts-ignore
8
+ const hexo_pagination_1 = __importDefault(require("hexo-pagination"));
9
+ // @ts-ignore
10
+ const fmtNum = (num) => {
11
+ return num < 10 ? '0' + num : num;
12
+ };
13
+ if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
14
+ // when archive disabled pagination, per_page should be 0.
15
+ let per_page;
16
+ if (hexo.config.archive === 1) {
17
+ per_page = 0;
18
+ }
19
+ else if (typeof hexo.config.per_page === 'undefined') {
20
+ per_page = 10;
21
+ }
22
+ else {
23
+ per_page = hexo.config.per_page;
24
+ }
25
+ hexo.config.archive_generator = Object.assign({
26
+ per_page,
27
+ yearly: true,
28
+ monthly: true,
29
+ daily: false
30
+ }, hexo.config.archive_generator);
31
+ hexo.extend.generator.register('archive', function (locals) {
32
+ const config = hexo.config;
33
+ let archiveDir = config.archive_dir;
34
+ const paginationDir = config.pagination_dir || 'page';
35
+ // @ts-ignore
36
+ const allPosts = locals.posts.sort(config.archive_generator.order_by || '-date');
37
+ const perPage = config.archive_generator.per_page;
38
+ let result = [];
39
+ if (!allPosts.length)
40
+ return;
41
+ if (archiveDir[archiveDir.length - 1] !== '/')
42
+ archiveDir += '/';
43
+ function generate(path, posts, options) {
44
+ options = options || {};
45
+ options.archive = true;
46
+ result = result.concat((0, hexo_pagination_1.default)(path, posts, {
47
+ perPage: path === archiveDir ? 0 : perPage,
48
+ layout: ['archive', 'index'],
49
+ format: paginationDir + '/%d/',
50
+ data: options
51
+ }));
52
+ }
53
+ generate(archiveDir, allPosts);
54
+ if (!config.archive_generator.yearly)
55
+ return result;
56
+ const posts = {};
57
+ // 按日期对文章进行分类
58
+ allPosts.forEach(post => {
59
+ const date = post.date;
60
+ const year = date.year();
61
+ const month = date.month() + 1; // month is started from 0
62
+ if (!Object.prototype.hasOwnProperty.call(posts, year)) {
63
+ // 13个数组. 第一个数组是给这一年的文章准备的
64
+ // 其他则是各个月份的文章
65
+ posts[year] = [
66
+ [],
67
+ [],
68
+ [],
69
+ [],
70
+ [],
71
+ [],
72
+ [],
73
+ [],
74
+ [],
75
+ [],
76
+ [],
77
+ [],
78
+ []
79
+ ];
80
+ }
81
+ posts[year][0].push(post);
82
+ posts[year][month].push(post);
83
+ // Daily
84
+ if (config.archive_generator.daily) {
85
+ const day = date.date();
86
+ if (!Object.prototype.hasOwnProperty.call(posts[year][month], 'day')) {
87
+ posts[year][month].day = {};
88
+ }
89
+ (posts[year][month].day[day] || (posts[year][month].day[day] = [])).push(post);
90
+ }
91
+ });
92
+ const Query = this.model('Post').Query;
93
+ const years = Object.keys(posts);
94
+ let year, data, month, monthData, url;
95
+ // Yearly
96
+ for (let i = 0, len = years.length; i < len; i++) {
97
+ year = +years[i];
98
+ data = posts[year];
99
+ url = archiveDir + year + '/';
100
+ if (!data[0].length)
101
+ continue;
102
+ generate(url, new Query(data[0]), { year });
103
+ if (!config.archive_generator.monthly && !config.archive_generator.daily)
104
+ continue;
105
+ // Monthly
106
+ for (month = 1; month <= 12; month++) {
107
+ monthData = data[month];
108
+ if (!monthData.length)
109
+ continue;
110
+ if (config.archive_generator.monthly) {
111
+ generate(url + fmtNum(month) + '/', new Query(monthData), {
112
+ year,
113
+ month
114
+ });
115
+ }
116
+ if (!config.archive_generator.daily)
117
+ continue;
118
+ // Daily
119
+ for (let day = 1; day <= 31; day++) {
120
+ const dayData = monthData.day[day];
121
+ if (!dayData || !dayData.length)
122
+ continue;
123
+ generate(url + fmtNum(month) + '/' + fmtNum(day) + '/', new Query(dayData), {
124
+ year,
125
+ month,
126
+ day
127
+ });
128
+ }
129
+ }
130
+ }
131
+ return result;
132
+ });
133
+ }
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /* global hexo */
7
+ const hexo_util_1 = require("hexo-util");
8
+ const node_fs_1 = __importDefault(require("node:fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const js_yaml_1 = __importDefault(require("js-yaml"));
11
+ hexo.extend.filter.register('before_generate', () => {
12
+ if (hexo.config.theme_config) {
13
+ // @ts-ignore
14
+ hexo.theme.config = (0, hexo_util_1.deepMerge)(hexo.theme.config, hexo.config.theme_config);
15
+ }
16
+ const data = hexo.locals.get('data');
17
+ if (data.languages) {
18
+ // @ts-ignore
19
+ const { i18n } = hexo.theme;
20
+ const mergeLang = lang => {
21
+ if (data.languages[lang]) { // @ts-ignore
22
+ i18n.set(lang, (0, hexo_util_1.deepMerge)(i18n.get([lang]), data.languages[lang]));
23
+ }
24
+ };
25
+ for (const lang of ['en', 'ja', 'zh-CN', 'zh-HK', 'zh-TW']) {
26
+ mergeLang(lang);
27
+ }
28
+ }
29
+ hexo.theme.config.style = {};
30
+ for (const style of ['iconfont', 'colors', 'custom']) {
31
+ const custom_file = 'source/_data/' + style + '.styl';
32
+ if (node_fs_1.default.existsSync(custom_file)) {
33
+ hexo.theme.config.style[style] = path_1.default.resolve(hexo.base_dir, custom_file);
34
+ }
35
+ }
36
+ if (data.images && data.images.length > 0) {
37
+ hexo.theme.config.image_list = data.images;
38
+ }
39
+ else {
40
+ hexo.theme.config.image_list = js_yaml_1.default.load(node_fs_1.default.readFileSync(path_1.default.join(__dirname, '../../_images.yml'), { encoding: 'utf-8' }));
41
+ }
42
+ if (data.images_index && data.images_index.length > 0) {
43
+ hexo.theme.config.index_images = data.images_index;
44
+ }
45
+ else if (node_fs_1.default.existsSync(path_1.default.join(__dirname, '../../_images_index.yml'))) {
46
+ hexo.theme.config.index_images = js_yaml_1.default.load(node_fs_1.default.readFileSync(path_1.default.join(__dirname, '../../_images_index.yml'), { encoding: 'utf-8' }));
47
+ }
48
+ else {
49
+ hexo.theme.config.index_images = data.index_images || [];
50
+ }
51
+ });
@@ -0,0 +1,23 @@
1
+ /* global hexo */
2
+ 'use strict';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ // @ts-ignore
5
+ const fs = require("hexo-fs");
6
+ hexo.extend.generator.register('images', function (locals) {
7
+ const theme = hexo.theme.config;
8
+ const dir = 'source/_data/' + theme.assets + '/';
9
+ if (!fs.existsSync(dir)) {
10
+ return;
11
+ }
12
+ const result = [];
13
+ const files = fs.listDirSync(dir);
14
+ files.forEach((file) => {
15
+ result.push({
16
+ path: theme.assets + '/' + file,
17
+ data: function () {
18
+ return fs.createReadStream(dir + file);
19
+ }
20
+ });
21
+ });
22
+ return result;
23
+ });
@@ -0,0 +1,107 @@
1
+ // @ts-nocheck
2
+ /* global hexo */
3
+ 'use strict';
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const fs = require("hexo-fs");
9
+ const hexo_pagination_1 = __importDefault(require("hexo-pagination"));
10
+ hexo.config.index_generator = Object.assign({
11
+ per_page: typeof hexo.config.per_page === 'undefined' ? 10 : hexo.config.per_page,
12
+ order_by: '-date'
13
+ }, hexo.config.index_generator);
14
+ hexo.extend.generator.register('index', function (locals) {
15
+ const covers = [];
16
+ const catlist = [];
17
+ let pages;
18
+ const config = hexo.config;
19
+ const sticky = locals.posts.find({ sticky: true }).sort(config.index_generator.order_by);
20
+ const posts = locals.posts.find({ sticky: { $in: [false, undefined] } }).sort(config.index_generator.order_by);
21
+ const paginationDir = config.pagination_dir || 'page';
22
+ const path = config.index_generator.path || '';
23
+ const categories = locals.categories;
24
+ const getTopcat = function (cat) {
25
+ if (cat.parent) {
26
+ const pCat = categories.findOne({ _id: cat.parent });
27
+ return getTopcat(pCat);
28
+ }
29
+ else {
30
+ return cat;
31
+ }
32
+ };
33
+ if (categories && categories.length) {
34
+ categories.forEach((cat) => {
35
+ const cover = `source/_posts/${cat.slug}`;
36
+ if (fs.existsSync(cover + '/cover.avif')) {
37
+ covers.push({
38
+ path: cat.slug + '/cover.avif',
39
+ data: function () {
40
+ return fs.createReadStream(cover + '/cover.avif');
41
+ }
42
+ });
43
+ }
44
+ else if (fs.existsSync(cover + '/cover.webp')) {
45
+ covers.push({
46
+ path: cat.slug + '/cover.webp',
47
+ data: function () {
48
+ return fs.createReadStream(cover + '/cover.webp');
49
+ }
50
+ });
51
+ }
52
+ else if (fs.existsSync(cover + '/cover.jpg')) {
53
+ covers.push({
54
+ path: cat.slug + '/cover.jpg',
55
+ data: function () {
56
+ return fs.createReadStream(cover + '/cover.jpg');
57
+ }
58
+ });
59
+ const topcat = getTopcat(cat);
60
+ if (topcat._id !== cat._id) {
61
+ cat.top = topcat;
62
+ }
63
+ const child = categories.find({ parent: cat._id });
64
+ let pl = 6;
65
+ if (child.length !== 0) {
66
+ cat.child = child.length;
67
+ cat.subs = child.sort({ name: 1 }).limit(6).toArray();
68
+ pl = Math.max(0, pl - child.length);
69
+ if (pl > 0) {
70
+ cat.subs.push(...cat.posts.sort({ title: 1 })
71
+ .filter(function (item, i) { return item.categories.last()._id === cat._id; })
72
+ .limit(pl).toArray());
73
+ }
74
+ }
75
+ else {
76
+ cat.subs = cat.posts.sort({ title: 1 }).limit(6).toArray();
77
+ }
78
+ catlist.push(cat);
79
+ }
80
+ });
81
+ }
82
+ if (posts.length > 0) {
83
+ pages = (0, hexo_pagination_1.default)(path, posts, {
84
+ perPage: config.index_generator.per_page,
85
+ layout: ['index', 'archive'],
86
+ format: paginationDir + '/%d/',
87
+ data: {
88
+ __index: true,
89
+ catlist,
90
+ sticky
91
+ }
92
+ });
93
+ }
94
+ else {
95
+ pages = [{
96
+ path,
97
+ layout: ['index', 'archive'],
98
+ data: {
99
+ __index: true,
100
+ catlist,
101
+ sticky,
102
+ current: 1,
103
+ }
104
+ }];
105
+ }
106
+ return [...covers, ...pages];
107
+ });
@@ -0,0 +1,15 @@
1
+ hexo.extend.generator.register('pages', function () {
2
+ const config = hexo.config;
3
+ return [
4
+ {
5
+ path: config.category_dir + '/index.html',
6
+ data: { type: 'categories' },
7
+ layout: 'page'
8
+ },
9
+ {
10
+ path: config.tag_dir + '/index.html',
11
+ data: { type: 'tags' },
12
+ layout: 'page'
13
+ }
14
+ ];
15
+ });
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /* global hexo */
7
+ const package_json_1 = __importDefault(require("../../package.json"));
8
+ const node_fs_1 = __importDefault(require("node:fs"));
9
+ const esbuild_1 = require("esbuild");
10
+ const utils_1 = require("../utils");
11
+ hexo.extend.generator.register('script', function (locals) {
12
+ const config = hexo.config;
13
+ const theme = hexo.theme.config;
14
+ const siteConfig = {
15
+ version: package_json_1.default.version,
16
+ hostname: config.url,
17
+ root: config.root,
18
+ statics: theme.statics,
19
+ favicon: {
20
+ normal: theme.assets + '/favicon.ico',
21
+ hidden: theme.assets + '/failure.ico'
22
+ },
23
+ darkmode: theme.darkmode,
24
+ auto_dark: theme.auto_dark,
25
+ auto_scroll: theme.auto_scroll,
26
+ js: {
27
+ copy_tex: (0, utils_1.getVendorLink)(hexo, theme.vendors.async_js.copy_tex),
28
+ fancybox: (0, utils_1.getVendorLink)(hexo, theme.vendors.async_js.fancybox)
29
+ },
30
+ css: {
31
+ katex: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.katex),
32
+ mermaid: theme.css + '/mermaid.css',
33
+ fancybox: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.fancybox),
34
+ justifiedGallery: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.justifiedGallery)
35
+ },
36
+ loader: theme.loader,
37
+ search: null,
38
+ outime: {
39
+ enable: theme.outime.enable,
40
+ days: theme.outime.days
41
+ },
42
+ quicklink: {
43
+ timeout: theme.quicklink.timeout,
44
+ priority: theme.quicklink.priority
45
+ },
46
+ playerAPI: theme.playerAPI,
47
+ audio: undefined,
48
+ fireworks: (theme.fireworks && theme.fireworks.enable && theme.fireworks.options)
49
+ ? theme.fireworks.options
50
+ : undefined,
51
+ waline: {
52
+ serverURL: theme.waline.serverURL,
53
+ lang: theme.waline.lang,
54
+ locale: theme.waline.locale,
55
+ emoji: theme.waline.emoji,
56
+ meta: theme.waline.meta,
57
+ requiredMeta: theme.waline.requiredMeta,
58
+ wordLimit: theme.waline.wordLimit,
59
+ pageSize: theme.waline.pageSize,
60
+ pageview: theme.waline.pageview
61
+ },
62
+ twikoo: {
63
+ envId: theme.twikoo.envId,
64
+ region: theme.twikoo.region
65
+ }
66
+ };
67
+ if (config?.algolia) {
68
+ siteConfig.search = {
69
+ appID: config.algolia.appId,
70
+ apiKey: config.algolia.apiKey,
71
+ indexName: config.algolia.indexName,
72
+ hits: theme.search.hits
73
+ };
74
+ }
75
+ if (theme?.audio) {
76
+ siteConfig.audio = theme.audio;
77
+ }
78
+ let enterPoint;
79
+ if (node_fs_1.default.existsSync('themes/shokaX/source/js/_app/pjax/siteInit.ts')) {
80
+ enterPoint = 'themes/shokaX/source/js/_app/pjax/siteInit.ts';
81
+ }
82
+ else {
83
+ enterPoint = 'node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.ts';
84
+ }
85
+ (0, esbuild_1.buildSync)({
86
+ entryPoints: [enterPoint],
87
+ bundle: true,
88
+ outdir: 'shokaxTemp',
89
+ tsconfigRaw: {
90
+ compilerOptions: {
91
+ target: 'ES2022',
92
+ esModuleInterop: true,
93
+ module: 'ESNext',
94
+ moduleResolution: 'Node',
95
+ skipLibCheck: true
96
+ }
97
+ },
98
+ platform: 'browser',
99
+ format: 'esm',
100
+ target: ['es2022'],
101
+ minify: true,
102
+ legalComments: 'linked',
103
+ mainFields: ['module', 'browser', 'main'],
104
+ splitting: true,
105
+ define: {
106
+ __UNLAZY_LOGGING__: 'false',
107
+ __UNLAZY_HASH_DECODING__: theme.modules.unlazyHash ? 'true' : 'false',
108
+ __shokax_player__: theme.modules.player ? 'true' : 'false',
109
+ __shokax_VL__: theme.modules.visibilityListener ? 'true' : 'false',
110
+ __shokax_fireworks__: (theme.fireworks && theme.fireworks.enable && theme.fireworks.options && theme.modules.fireworks) ? 'true' : 'false',
111
+ __shokax_search__: config?.algolia ? 'true' : 'false',
112
+ __shokax_outime__: theme.outime.enable ? 'true' : 'false',
113
+ __shokax_tabs__: theme.modules.tabs ? 'true' : 'false',
114
+ __shokax_quiz__: theme.modules.quiz ? 'true' : 'false',
115
+ __shokax_fancybox__: theme.modules.fancybox ? 'true' : 'false',
116
+ __shokax_waline__: theme.waline.enable ? 'true' : 'false',
117
+ __shokax_twikoo__: theme.twikoo.enable ? 'true' : 'false',
118
+ shokax_CONFIG: JSON.stringify(siteConfig),
119
+ shokax_siteURL: "'" + config.url + "'"
120
+ },
121
+ alias: {
122
+ 'algoliasearch/lite': 'algoliasearch/dist/algoliasearch-lite.esm.browser.js'
123
+ }
124
+ });
125
+ const res = [];
126
+ node_fs_1.default.readdirSync('./shokaxTemp').forEach((file) => {
127
+ const fileText = node_fs_1.default.readFileSync(`./shokaxTemp/${file}`, { encoding: 'utf-8' });
128
+ if (file.endsWith('js')) {
129
+ const result = hexo.render.renderSync({ text: fileText, engine: 'js' });
130
+ res.push({
131
+ path: theme.js + '/' + file,
132
+ data: function () {
133
+ return result;
134
+ }
135
+ });
136
+ }
137
+ else if (file.endsWith('css')) {
138
+ const result = hexo.render.renderSync({ text: fileText, engine: 'css' });
139
+ res.push({
140
+ path: theme.css + '/' + file,
141
+ data: function () {
142
+ return result;
143
+ }
144
+ });
145
+ }
146
+ else {
147
+ res.push({
148
+ path: theme.js + '/' + file,
149
+ data: function () {
150
+ return fileText;
151
+ }
152
+ });
153
+ }
154
+ });
155
+ return res;
156
+ });
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ /* global hexo */
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const package_json_1 = __importDefault(require("../../package.json"));
8
+ const hexo_util_1 = require("hexo-util");
9
+ const utils_1 = require("../utils");
10
+ hexo.extend.helper.register('_safedump', (source) => {
11
+ return JSON.stringify(source);
12
+ });
13
+ hexo.extend.helper.register('hexo_env', function (type) {
14
+ return this.env[type];
15
+ });
16
+ hexo.extend.helper.register('theme_env', function (type) {
17
+ return package_json_1.default[type];
18
+ });
19
+ hexo.extend.helper.register('_vendor_font', () => {
20
+ const config = hexo.theme.config.font;
21
+ if (!config || !config.enable)
22
+ return '';
23
+ const fontDisplay = '&display=swap';
24
+ const fontSubset = '&subset=latin,latin-ext';
25
+ const fontStyles = ':400,400italic,700,700italic';
26
+ const fontHost = 'https://fonts.googleapis.com';
27
+ // Get a font list from config
28
+ let fontFamilies = ['global', 'logo', 'title', 'headings', 'posts', 'codes'].map(item => {
29
+ if (config[item] && config[item].family && config[item].external) {
30
+ return config[item].family + fontStyles;
31
+ }
32
+ return '';
33
+ });
34
+ fontFamilies = fontFamilies.filter(item => item !== '');
35
+ // @ts-ignore
36
+ fontFamilies = [...new Set(fontFamilies)];
37
+ // @ts-ignore
38
+ fontFamilies = fontFamilies.join('|');
39
+ // Merge extra parameters to the final processed font string
40
+ return fontFamilies
41
+ ? (0, hexo_util_1.htmlTag)('link', {
42
+ rel: 'stylesheet',
43
+ href: `${fontHost}/css?family=${fontFamilies.concat(fontDisplay, fontSubset)}`,
44
+ media: 'none',
45
+ onload: "this.media='all'"
46
+ })
47
+ : '';
48
+ });
49
+ hexo.extend.helper.register('_css', function (...urls) {
50
+ const { statics, css } = hexo.theme.config;
51
+ return urls.map(url => (0, hexo_util_1.htmlTag)('link', {
52
+ rel: 'stylesheet',
53
+ href: hexo_util_1.url_for.call(this, `${statics}${css}/${url}?v=${package_json_1.default.version}`)
54
+ }), '').join('');
55
+ });
56
+ hexo.extend.helper.register('_js', function (...urls) {
57
+ const { statics, js } = hexo.theme.config;
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
+ });
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;
67
+ });
68
+ hexo.extend.helper.register('_striptags', function (data) {
69
+ return (0, hexo_util_1.stripHTML)(data);
70
+ });
71
+ hexo.extend.helper.register('_truncate', function (data, end) {
72
+ return data.substring(0, end);
73
+ });