hexo-theme-shokax 0.3.13 → 0.3.14

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 (180) 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 +99 -99
  6. package/README_en.MD +90 -90
  7. package/UsageRestrictions.md +25 -25
  8. package/_config.yml +370 -370
  9. package/_images.yml +9 -9
  10. package/languages/README.md +19 -19
  11. package/languages/default.yml +1 -1
  12. package/languages/en.yml +153 -153
  13. package/languages/ja.yml +153 -153
  14. package/languages/zh-CN.yml +153 -153
  15. package/languages/zh-HK.yml +153 -153
  16. package/languages/zh-TW.yml +153 -153
  17. package/layout/_alternate/atom.ejs +30 -30
  18. package/layout/_alternate/json.ejs +16 -16
  19. package/layout/_alternate/rss.ejs +34 -34
  20. package/layout/_mixin/breadcrumb.pug +33 -33
  21. package/layout/_mixin/card.pug +38 -38
  22. package/layout/_mixin/comment.pug +41 -41
  23. package/layout/_mixin/postmeta.pug +29 -29
  24. package/layout/_mixin/segment.pug +32 -32
  25. package/layout/_mixin/sidebar.pug +40 -40
  26. package/layout/_mixin/widgets.pug +33 -33
  27. package/layout/_partials/footer.pug +42 -42
  28. package/layout/_partials/head/head.pug +57 -57
  29. package/layout/_partials/head/head_com.pug +17 -17
  30. package/layout/_partials/head/pwa.pug +18 -18
  31. package/layout/_partials/header.pug +18 -18
  32. package/layout/_partials/layout.pug +139 -139
  33. package/layout/_partials/loading.pug +13 -13
  34. package/layout/_partials/pagination.pug +4 -4
  35. package/layout/_partials/post/copyright.pug +20 -20
  36. package/layout/_partials/post/footer.pug +25 -25
  37. package/layout/_partials/post/nav.pug +13 -13
  38. package/layout/_partials/post/post.pug +41 -41
  39. package/layout/_partials/post/reward.pug +18 -18
  40. package/layout/_partials/sidebar/menu.pug +37 -37
  41. package/layout/_partials/sidebar/overview.pug +42 -42
  42. package/layout/_partials/third-party/baidu-analytics.pug +11 -11
  43. package/layout/_partials/third-party/clarity.pug +8 -8
  44. package/layout/_partials/third-party/google-analytics.pug +9 -9
  45. package/layout/archive.pug +118 -118
  46. package/layout/category.pug +59 -59
  47. package/layout/index.pug +33 -33
  48. package/layout/page.pug +55 -55
  49. package/layout/post.pug +36 -36
  50. package/layout/tag.pug +43 -43
  51. package/package.json +47 -47
  52. package/source/assets/algolia_logo.svg +9 -9
  53. package/source/assets/logo.svg +16 -16
  54. package/source/css/_colors.styl +207 -207
  55. package/source/css/_common/components/components.styl +6 -6
  56. package/source/css/_common/components/highlight/highlight.styl +357 -357
  57. package/source/css/_common/components/highlight/operation.styl +21 -21
  58. package/source/css/_common/components/pages/collapse.styl +119 -119
  59. package/source/css/_common/components/pages/home.styl +391 -391
  60. package/source/css/_common/components/pages/pages.styl +56 -56
  61. package/source/css/_common/components/pages/tag-cloud.styl +12 -12
  62. package/source/css/_common/components/post/breadcrumb.styl +39 -39
  63. package/source/css/_common/components/post/copyright.styl +41 -41
  64. package/source/css/_common/components/post/expand.styl +263 -263
  65. package/source/css/_common/components/post/footer.styl +11 -11
  66. package/source/css/_common/components/post/header.styl +79 -79
  67. package/source/css/_common/components/post/nav.styl +63 -63
  68. package/source/css/_common/components/post/post.styl +29 -29
  69. package/source/css/_common/components/post/reward.styl +50 -50
  70. package/source/css/_common/components/post/rtl.styl +12 -12
  71. package/source/css/_common/components/post/tags.styl +39 -39
  72. package/source/css/_common/components/tags/collapse.styl +72 -72
  73. package/source/css/_common/components/tags/container.styl +49 -49
  74. package/source/css/_common/components/tags/label.styl +12 -12
  75. package/source/css/_common/components/tags/links.styl +77 -77
  76. package/source/css/_common/components/tags/list.styl +131 -131
  77. package/source/css/_common/components/tags/note.styl +70 -70
  78. package/source/css/_common/components/tags/player.styl +361 -361
  79. package/source/css/_common/components/tags/quiz.styl +200 -200
  80. package/source/css/_common/components/tags/tabs.styl +89 -89
  81. package/source/css/_common/components/tags/tags.styl +9 -9
  82. package/source/css/_common/components/third-party/loading.styl +222 -222
  83. package/source/css/_common/components/third-party/mermaid/class.styl +90 -90
  84. package/source/css/_common/components/third-party/mermaid/flowchart.styl +72 -72
  85. package/source/css/_common/components/third-party/mermaid/gantt.styl +251 -251
  86. package/source/css/_common/components/third-party/mermaid/git.styl +7 -7
  87. package/source/css/_common/components/third-party/mermaid/mermaid.styl +37 -37
  88. package/source/css/_common/components/third-party/mermaid/pie.styl +9 -9
  89. package/source/css/_common/components/third-party/mermaid/sequence.styl +95 -95
  90. package/source/css/_common/components/third-party/mermaid/state.styl +130 -130
  91. package/source/css/_common/components/third-party/pace.styl +18 -18
  92. package/source/css/_common/components/third-party/search.styl +167 -167
  93. package/source/css/_common/components/third-party/theme.styl +151 -151
  94. package/source/css/_common/components/third-party/third-party.styl +22 -22
  95. package/source/css/_common/components/third-party/widgets.styl +57 -57
  96. package/source/css/_common/outline/footer/footer.styl +69 -69
  97. package/source/css/_common/outline/header/brand.styl +77 -77
  98. package/source/css/_common/outline/header/header.styl +20 -20
  99. package/source/css/_common/outline/header/image.styl +85 -85
  100. package/source/css/_common/outline/header/menu.styl +117 -117
  101. package/source/css/_common/outline/header/nav.styl +81 -81
  102. package/source/css/_common/outline/header/right.styl +15 -15
  103. package/source/css/_common/outline/header/tool.styl +207 -207
  104. package/source/css/_common/outline/header/waves.styl +57 -57
  105. package/source/css/_common/outline/mobile.styl +46 -46
  106. package/source/css/_common/outline/outline.styl +78 -78
  107. package/source/css/_common/outline/sidebar/author.styl +59 -59
  108. package/source/css/_common/outline/sidebar/dimmer.styl +23 -23
  109. package/source/css/_common/outline/sidebar/menu.styl +63 -63
  110. package/source/css/_common/outline/sidebar/quick.styl +43 -43
  111. package/source/css/_common/outline/sidebar/related.styl +56 -56
  112. package/source/css/_common/outline/sidebar/sidebar.styl +75 -75
  113. package/source/css/_common/outline/sidebar/social.styl +69 -69
  114. package/source/css/_common/outline/sidebar/state.styl +37 -37
  115. package/source/css/_common/outline/sidebar/tab.styl +71 -71
  116. package/source/css/_common/outline/sidebar/toc.styl +47 -47
  117. package/source/css/_common/scaffolding/animate.styl +322 -322
  118. package/source/css/_common/scaffolding/base.styl +190 -190
  119. package/source/css/_common/scaffolding/buttons.styl +48 -48
  120. package/source/css/_common/scaffolding/divider.styl +36 -36
  121. package/source/css/_common/scaffolding/iconfont.styl +443 -443
  122. package/source/css/_common/scaffolding/normalize.styl +273 -273
  123. package/source/css/_common/scaffolding/pagination.styl +81 -81
  124. package/source/css/_common/scaffolding/ribbon.styl +38 -38
  125. package/source/css/_common/scaffolding/scaffolding.styl +14 -14
  126. package/source/css/_common/scaffolding/scrollbar.styl +37 -37
  127. package/source/css/_common/scaffolding/tables.styl +50 -50
  128. package/source/css/_common/scaffolding/tip.styl +19 -19
  129. package/source/css/_common/scaffolding/toggles.styl +59 -59
  130. package/source/css/_iconfont.styl +455 -455
  131. package/source/css/_mixins.styl +148 -148
  132. package/source/css/_variables.styl +89 -89
  133. package/source/css/app.styl +41 -41
  134. package/source/css/comment.styl +3 -3
  135. package/source/css/mermaid.styl +5 -5
  136. package/source/css/optimize.styl +5 -5
  137. package/scripts/filters/locals.js +0 -52
  138. package/scripts/filters/post.js +0 -5
  139. package/scripts/generaters/archive.js +0 -133
  140. package/scripts/generaters/config.js +0 -48
  141. package/scripts/generaters/images.js +0 -23
  142. package/scripts/generaters/index.js +0 -107
  143. package/scripts/generaters/pages.js +0 -15
  144. package/scripts/generaters/script.js +0 -118
  145. package/scripts/helpers/asset.js +0 -147
  146. package/scripts/helpers/engine.js +0 -153
  147. package/scripts/helpers/list_categories.js +0 -84
  148. package/scripts/helpers/summary_ai.js +0 -107
  149. package/scripts/helpers/symbols_count_time.js +0 -69
  150. package/scripts/plugin/check.js +0 -32
  151. package/scripts/plugin/index.js +0 -78
  152. package/scripts/plugin/lib/injects-point.js +0 -20
  153. package/scripts/plugin/lib/injects.js +0 -89
  154. package/scripts/tags/links.js +0 -44
  155. package/scripts/tags/media.js +0 -19
  156. package/scripts/utils.js +0 -14
  157. package/source/js/_app/components/sidebar.js +0 -209
  158. package/source/js/_app/fireworks.js +0 -10
  159. package/source/js/_app/globals/globalVars.js +0 -80
  160. package/source/js/_app/globals/handles.js +0 -98
  161. package/source/js/_app/globals/themeColor.js +0 -62
  162. package/source/js/_app/globals/thirdparty.js +0 -62
  163. package/source/js/_app/globals/tools.js +0 -66
  164. package/source/js/_app/library/anime.js +0 -106
  165. package/source/js/_app/library/dom.js +0 -34
  166. package/source/js/_app/library/loadFile.js +0 -36
  167. package/source/js/_app/library/proto.js +0 -163
  168. package/source/js/_app/library/scriptPjax.js +0 -70
  169. package/source/js/_app/library/storage.js +0 -12
  170. package/source/js/_app/library/vue.js +0 -53
  171. package/source/js/_app/page/comment.js +0 -23
  172. package/source/js/_app/page/common.js +0 -41
  173. package/source/js/_app/page/fancybox.js +0 -65
  174. package/source/js/_app/page/post.js +0 -244
  175. package/source/js/_app/page/search.js +0 -118
  176. package/source/js/_app/page/tab.js +0 -53
  177. package/source/js/_app/pjax/domInit.js +0 -76
  178. package/source/js/_app/pjax/refresh.js +0 -52
  179. package/source/js/_app/pjax/siteInit.js +0 -51
  180. package/source/js/_app/player.js +0 -771
@@ -1,133 +0,0 @@
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
- }
@@ -1,48 +0,0 @@
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 (node_fs_1.default.existsSync(path_1.default.join(__dirname, '../../_images_index.yml'))) {
43
- 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' }));
44
- }
45
- else {
46
- hexo.theme.config.index_images = data.index_images || [];
47
- }
48
- });
@@ -1,23 +0,0 @@
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
- });
@@ -1,107 +0,0 @@
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
- });
@@ -1,15 +0,0 @@
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
- });
@@ -1,118 +0,0 @@
1
- "use strict";
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;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- /* global hexo */
30
- const package_json_1 = __importDefault(require("../../package.json"));
31
- const fs = __importStar(require("hexo-fs"));
32
- const esbuild_1 = require("esbuild");
33
- const utils_1 = require("../utils");
34
- hexo.extend.generator.register('script', function (locals) {
35
- const config = hexo.config;
36
- const theme = hexo.theme.config;
37
- const siteConfig = {
38
- version: package_json_1.default.version,
39
- hostname: config.url,
40
- root: config.root,
41
- statics: theme.statics,
42
- favicon: {
43
- normal: theme.assets + '/favicon.ico',
44
- hidden: theme.assets + '/failure.ico'
45
- },
46
- darkmode: theme.darkmode,
47
- auto_dark: theme.auto_dark,
48
- auto_scroll: theme.auto_scroll,
49
- js: {
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
- },
53
- css: {
54
- katex: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.katex),
55
- mermaid: theme.css + '/mermaid.css',
56
- fancybox: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.fancybox),
57
- justifiedGallery: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.justifiedGallery)
58
- },
59
- loader: theme.loader,
60
- search: null,
61
- outime: {
62
- enable: theme.outime.enable,
63
- days: theme.outime.days
64
- },
65
- quicklink: {
66
- timeout: theme.quicklink.timeout,
67
- priority: theme.quicklink.priority
68
- },
69
- playerAPI: theme.playerAPI,
70
- disableVL: theme.disableVL,
71
- noPlayer: theme.experiments?.noPlayer,
72
- audio: undefined,
73
- fireworks: (theme.fireworks && theme.fireworks.enable && theme.fireworks.options)
74
- ? theme.fireworks.options
75
- : undefined
76
- };
77
- if (config?.algolia) {
78
- siteConfig.search = {
79
- appID: config.algolia.appId,
80
- apiKey: config.algolia.apiKey,
81
- indexName: config.algolia.indexName,
82
- hits: theme.search.hits
83
- };
84
- }
85
- if (theme?.audio) {
86
- siteConfig.audio = theme.audio;
87
- }
88
- let text;
89
- let enterPoint;
90
- if (fs.existsSync('themes/shokaX/source/js/_app/pjax/siteInit.js')) {
91
- enterPoint = 'themes/shokaX/source/js/_app/pjax/siteInit.js';
92
- }
93
- else {
94
- enterPoint = 'node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.js';
95
- }
96
- text = 'const CONFIG = ' + JSON.stringify(siteConfig) + ';';
97
- (0, esbuild_1.buildSync)({
98
- entryPoints: [enterPoint],
99
- bundle: true,
100
- outfile: 'shokax_temp.js',
101
- platform: 'browser',
102
- format: 'iife',
103
- target: ['es2022'],
104
- minify: true,
105
- define: {
106
- __UNLAZY_LOGGING__: 'false'
107
- }
108
- });
109
- text += fs.readFileSync('shokax_temp.js');
110
- const result = hexo.render.renderSync({ text, engine: 'js' });
111
- fs.unlinkSync('shokax_temp.js');
112
- return {
113
- path: theme.js + '/app.js',
114
- data: function () {
115
- return result;
116
- }
117
- };
118
- });
@@ -1,147 +0,0 @@
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('_new_comments', function (mode) {
11
- const root = this.config.url.replace(/^(https?:\/\/)?[^\/]*/, '');
12
- if (mode === 'twikoo') {
13
- return `<script data-pjax type="module">
14
- let comments = []
15
- twikoo.getRecentComments({
16
- envId: "${hexo.theme.config?.twikoo?.envId}",
17
- pageSize: 10
18
- }).then(function (res) {
19
- res.forEach(function (item) {
20
- let cText = item.commentText
21
- if (item.commentText.length > 50) {
22
- cText = item.commentText.substring(0,50)+'...'
23
- }
24
- const siteLink = item.url + "#" + item.id
25
- comments.push({
26
- href: siteLink,
27
- nick: item.nick,
28
- time: item.relativeTime,
29
- text: cText
30
- })
31
- });
32
- Vue.createApp({
33
- data() {
34
- return {
35
- coms: comments,
36
- root: '${root}'
37
- }
38
- }
39
- }).mount('#new-comment')
40
- }).catch(function (err) {
41
- console.error(err)
42
- })
43
- </script>`;
44
- }
45
- else if (mode === 'waline') {
46
- return `
47
- <script type="module" data-pjax>
48
- let items = []
49
- import { RecentComments } from 'https://npm.webcache.cn/@waline/client@v2/dist/waline.mjs'
50
- RecentComments({
51
- serverURL: '${hexo.theme.config.waline.serverURL.replace(/\/+$/, '')}',
52
- count: 10,
53
- }).then(({ comments }) => {
54
- comments.forEach(function (item) {
55
- let cText = (item.orig.length > 50) ? item.orig.substring(0,50)+'...' : item.orig
56
- item.url = item.url.startsWith('/') ? item.url : '/' + item.url;
57
- const siteLink = item.url + "#" + item.objectId
58
- items.push({
59
- href: siteLink,
60
- nick: item.nick,
61
- time: item.insertedAt.split('T').shift(),
62
- text: cText
63
- })
64
- })
65
- Vue.createApp({
66
- data() {
67
- return {
68
- coms: items,
69
- root: '${root}'
70
- }
71
- }
72
- }).mount('#new-comment')
73
- }).catch(function (err) {
74
- console.error(err)
75
- })
76
- </script>
77
- `;
78
- }
79
- else {
80
- console.log(`${mode} is not supported recent comment`);
81
- }
82
- });
83
- hexo.extend.helper.register('_safedump', (source) => {
84
- return JSON.stringify(source);
85
- });
86
- hexo.extend.helper.register('hexo_env', function (type) {
87
- return this.env[type];
88
- });
89
- hexo.extend.helper.register('theme_env', function (type) {
90
- return package_json_1.default[type];
91
- });
92
- hexo.extend.helper.register('_vendor_font', () => {
93
- const config = hexo.theme.config.font;
94
- if (!config || !config.enable)
95
- return '';
96
- const fontDisplay = '&display=swap';
97
- const fontSubset = '&subset=latin,latin-ext';
98
- const fontStyles = ':300,300italic,400,400italic,700,700italic';
99
- const fontHost = 'https://fonts.googleapis.com';
100
- // Get a font list from config
101
- let fontFamilies = ['global', 'logo', 'title', 'headings', 'posts', 'codes'].map(item => {
102
- if (config[item] && config[item].family && config[item].external) {
103
- return config[item].family + fontStyles;
104
- }
105
- return '';
106
- });
107
- fontFamilies = fontFamilies.filter(item => item !== '');
108
- // @ts-ignore
109
- fontFamilies = [...new Set(fontFamilies)];
110
- // @ts-ignore
111
- fontFamilies = fontFamilies.join('|');
112
- // Merge extra parameters to the final processed font string
113
- return fontFamilies
114
- ? (0, hexo_util_1.htmlTag)('link', {
115
- rel: 'stylesheet',
116
- href: `${fontHost}/css?family=${fontFamilies.concat(fontDisplay, fontSubset)}`
117
- })
118
- : '';
119
- });
120
- hexo.extend.helper.register('_css', function (...urls) {
121
- const { statics, css } = hexo.theme.config;
122
- return urls.map(url => (0, hexo_util_1.htmlTag)('link', {
123
- rel: 'stylesheet',
124
- href: hexo_util_1.url_for.call(this, `${statics}${css}/${url}?v=${package_json_1.default.version}`)
125
- })).join('');
126
- });
127
- hexo.extend.helper.register('_js', function (...urls) {
128
- const { statics, js } = hexo.theme.config;
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('');
130
- });
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]) }, '');
136
- }
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;
141
- });
142
- hexo.extend.helper.register('_striptags', function (data) {
143
- return (0, hexo_util_1.stripHTML)(data);
144
- });
145
- hexo.extend.helper.register('_truncate', function (data, end) {
146
- return data.substring(0, end);
147
- });