hexo-theme-shokax 0.3.12 → 0.3.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) 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 -92
  6. package/README_en.MD +90 -82
  7. package/UsageRestrictions.md +25 -25
  8. package/_config.yml +370 -373
  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 -58
  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 -87
  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 -451
  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 -115
  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/css/twikoo.css +0 -2002
  158. package/source/js/_app/components/sidebar.js +0 -210
  159. package/source/js/_app/fireworks.js +0 -10
  160. package/source/js/_app/globals/globalVars.js +0 -80
  161. package/source/js/_app/globals/handles.js +0 -138
  162. package/source/js/_app/globals/themeColor.js +0 -62
  163. package/source/js/_app/globals/thirdparty.js +0 -71
  164. package/source/js/_app/globals/tools.js +0 -92
  165. package/source/js/_app/library/anime.js +0 -109
  166. package/source/js/_app/library/dom.js +0 -34
  167. package/source/js/_app/library/loadFile.js +0 -36
  168. package/source/js/_app/library/proto.js +0 -163
  169. package/source/js/_app/library/scriptPjax.js +0 -70
  170. package/source/js/_app/library/storage.js +0 -12
  171. package/source/js/_app/library/vue.js +0 -53
  172. package/source/js/_app/page/comment.js +0 -23
  173. package/source/js/_app/page/common.js +0 -41
  174. package/source/js/_app/page/fancybox.js +0 -65
  175. package/source/js/_app/page/post.js +0 -244
  176. package/source/js/_app/page/search.js +0 -118
  177. package/source/js/_app/page/tab.js +0 -53
  178. package/source/js/_app/pjax/domInit.js +0 -76
  179. package/source/js/_app/pjax/refresh.js +0 -53
  180. package/source/js/_app/pjax/siteInit.js +0 -49
  181. package/source/js/_app/player.js +0 -774
@@ -1,153 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-ignore
4
- const hexo_util_1 = require("hexo-util");
5
- const randomServer = parseInt(String(Math.random() * 4), 10) + 1;
6
- const randomBG = function (count = 1, image_server = null, image_list = []) {
7
- let i;
8
- if (image_server) {
9
- if (count && count > 1) {
10
- const arr = new Array(count);
11
- for (i = 0; i < arr.length; i++) {
12
- arr[i] = image_server + '?' + Math.floor(Math.random() * 999999);
13
- }
14
- return arr;
15
- }
16
- return image_server + '?' + Math.floor(Math.random() * 999999);
17
- }
18
- const parseImage = function (img, size) {
19
- if (img.startsWith('//') || img.startsWith('http')) {
20
- return img;
21
- }
22
- else if (hexo.theme.config.experiments?.usingRelative) { // support relative url
23
- return img;
24
- }
25
- else {
26
- console.warn("sinaimg blocked all request from outside website,so don't use this format");
27
- return `https://tva${randomServer}.sinaimg.cn/` + size + '/' + img;
28
- }
29
- };
30
- if (count && count > 1) {
31
- let shuffled = image_list.slice(0);
32
- while (shuffled.length <= 6) {
33
- shuffled = shuffled.concat(image_list.slice(0));
34
- }
35
- i = shuffled.length;
36
- const min = i - count;
37
- let temp;
38
- let index;
39
- while (i-- > min) {
40
- index = Math.floor((i + 1) * Math.random());
41
- temp = shuffled[index];
42
- shuffled[index] = shuffled[i];
43
- shuffled[i] = temp;
44
- }
45
- return shuffled.slice(min).map(function (img) {
46
- return parseImage(img, 'large');
47
- });
48
- }
49
- return parseImage(image_list[Math.floor(Math.random() * image_list.length)], 'mw690');
50
- };
51
- // 注册hexo主题中的URL帮助方法
52
- hexo.extend.helper.register('_url', function (path, text, options = {}) {
53
- // 如果未提供URL路径,则返回
54
- if (!path) {
55
- return;
56
- }
57
- let tag = 'a';
58
- let attrs = { href: hexo_util_1.url_for.call(this, path), class: undefined, external: undefined, rel: undefined, 'data-url': undefined };
59
- for (const key in options) {
60
- attrs[key] = options[key];
61
- }
62
- if (attrs.class && Array.isArray(attrs.class)) {
63
- attrs.class = attrs.class.join(' ');
64
- }
65
- // 返回HTML标记字符串
66
- return (0, hexo_util_1.htmlTag)(tag, attrs, decodeURI(text), false);
67
- });
68
- hexo.extend.helper.register('_image_url', function (img, path = '') {
69
- const { statics } = hexo.theme.config;
70
- const { post_asset_folder } = hexo.config;
71
- if (img.startsWith('//') || img.startsWith('http')) {
72
- return img;
73
- }
74
- else {
75
- return hexo_util_1.url_for.call(this, statics + (post_asset_folder ? path : '') + img);
76
- }
77
- });
78
- hexo.extend.helper.register('_cover', function (item, num) {
79
- const { image_server, image_list } = hexo.theme.config;
80
- if (item.cover) {
81
- return this._image_url(item.cover, item.path);
82
- }
83
- else if (item.photos && item.photos.length > 0) {
84
- return this._image_url(item.photos[0], item.path);
85
- }
86
- else {
87
- return randomBG(num || 1, image_server, image_list);
88
- }
89
- });
90
- hexo.extend.helper.register('_cover_index', function (item) {
91
- const { index_images, image_list, image_server } = hexo.theme.config;
92
- if (item.cover) {
93
- return this._image_url(item.cover, item.path);
94
- }
95
- else if (item.photos && item.photos.length > 0) {
96
- return this._image_url(item.photos[0], item.path);
97
- }
98
- else {
99
- return randomBG(1, image_server, index_images.length === 0 ? image_list : index_images);
100
- }
101
- });
102
- // 注册hexo主题的永久链接帮助方法
103
- hexo.extend.helper.register('_permapath', function (str) {
104
- // 获取hexo的永久链接配置
105
- const { permalink } = hexo.config;
106
- // 将输入字符串中的'index.html'替换为空字符串
107
- let url = str.replace(/index\.html$/, '');
108
- // 如果永久链接不以'.html'结尾,将输入字符串中的'.html'替换为空字符串
109
- if (!permalink.endsWith('.html')) {
110
- url = url.replace(/\.html$/, '');
111
- }
112
- // 返回处理后的URL字符串
113
- return url;
114
- });
115
- hexo.extend.helper.register('canonical', function () {
116
- return `<link rel="canonical" href="${this._permapath(this.url)}">`;
117
- });
118
- /**
119
- * Get page path given a certain language tag
120
- */
121
- // 注册hexo主题的国际化路径帮助方法
122
- hexo.extend.helper.register('i18n_path', function (language) {
123
- // 获取当前页面的path和lang
124
- const { path, lang } = this.page;
125
- // 如果path以lang开头,则截取掉lang部分,作为基础路径
126
- const base = path.startsWith(lang) ? path.slice(lang.length + 1) : path;
127
- // 通过调用url_for方法,生成国际化路径
128
- return hexo_util_1.url_for.call(this, `${this.languages.indexOf(language) === 0 ? '' : '/' + language}/${base}`);
129
- });
130
- /**
131
- * Get the language name
132
- */
133
- // 注册hexo主题的语言名称帮助方法
134
- hexo.extend.helper.register('language_name', function (language) {
135
- // 从主题配置中获取指定语言的名称
136
- // @ts-ignore
137
- const name = hexo.theme.i18n.__(language)('name');
138
- // 如果名称为默认值'name',则返回语言代码,否则返回语言名称
139
- return name === 'name' ? language : name;
140
- });
141
- hexo.extend.helper.register('random_color', function () {
142
- const arr = [];
143
- for (let i = 0; i < 3; i++) {
144
- arr.push(Math.floor(Math.random() * 128 + 128));
145
- }
146
- const [r, g, b] = arr;
147
- return `#${r.toString(16).length > 1 ? r.toString(16) : '0' + r.toString(16)}${g.toString(16).length > 1 ? g.toString(16) : '0' + g.toString(16)}${b.toString(16).length > 1 ? b.toString(16) : '0' + b.toString(16)}`;
148
- });
149
- hexo.extend.helper.register('shokax_inject', function (point) {
150
- return hexo.theme.config.injects[point]
151
- .map(item => this.partial(item.layout, item.locals, item.options))
152
- .join('');
153
- });
@@ -1,84 +0,0 @@
1
- 'use strict';
2
- /* global hexo */
3
- const prepareQuery = (categories, parent) => {
4
- const query = {
5
- parent: undefined
6
- };
7
- if (parent) {
8
- query.parent = parent;
9
- }
10
- else {
11
- query.parent = { $exists: false };
12
- }
13
- return categories.find(query).sort('name', 1).filter(cat => cat.length);
14
- };
15
- hexo.extend.helper.register('_list_categories', function (depth = 0) {
16
- // let hexo = this
17
- const categories = this.site.categories;
18
- if (!categories || !categories.length)
19
- return '';
20
- const hierarchicalList = (level, parent) => {
21
- let result = '';
22
- prepareQuery(categories, parent).forEach((cat, i) => {
23
- let child;
24
- if (level + 1 < depth) {
25
- child = hierarchicalList(level + 1, cat._id);
26
- }
27
- const catname = `<a itemprop="url" href="${this.url_for(cat.path)}">${cat.name}</a><small>( ${cat.length} )</small>`;
28
- switch (level) {
29
- case 0:
30
- result += `<div><h2 class="item header">${catname}</h2>`;
31
- break;
32
- case 1:
33
- result += `<h3 class="item section">${catname}</h3>`;
34
- break;
35
- case 2:
36
- result += `<div class="item normal"><div class="title">${catname}</div></div>`;
37
- break;
38
- }
39
- if (child) {
40
- result += `${child}`;
41
- }
42
- if (level === 0) {
43
- result += '</div>';
44
- }
45
- });
46
- return result;
47
- };
48
- return hierarchicalList(0);
49
- });
50
- hexo.extend.helper.register('_category_prev', function (name) {
51
- // let hexo = this
52
- const categories = this.site.categories;
53
- if (!categories || !categories.length)
54
- return '';
55
- let result = '';
56
- categories.find({ name }).forEach((current) => {
57
- if (current.parent) {
58
- categories.find({ _id: current.parent }).forEach((cat, i) => {
59
- result += `<a href="${this.url_for(cat.path)}">${cat.name}</a>`;
60
- });
61
- }
62
- });
63
- return result;
64
- });
65
- hexo.extend.helper.register('_category_posts', function (page) {
66
- // let hexo = this
67
- const categories = this.site.categories;
68
- if (!categories || !categories.length || !page.categories || !page.categories.length)
69
- return '';
70
- let result = '';
71
- const cat = page.categories.toArray();
72
- categories.find({ _id: cat[cat.length - 1]._id }).forEach((category) => {
73
- if (category.posts) {
74
- category.posts.sort('date', 1).forEach((post) => {
75
- let current = '';
76
- if (post.path === page.path) {
77
- current = ' class="active"';
78
- }
79
- result += `<li ${current}><a href="${this.url_for(post.path)}" rel="bookmark" title="${post.title}">${post.title}</a></li>`;
80
- });
81
- }
82
- });
83
- return result;
84
- });
@@ -1,107 +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
- const node_fs_1 = __importDefault(require("node:fs"));
7
- function getContent(post) {
8
- return post?.raw ?? post?._content ?? post.content;
9
- }
10
- let db;
11
- function postMessage(path, content, dbPath, startMessage) {
12
- if (node_fs_1.default.existsSync('summary.json')) {
13
- // @ts-ignore
14
- db = JSON.parse(node_fs_1.default.readFileSync('summary.json'));
15
- }
16
- else {
17
- db = {};
18
- }
19
- const config = hexo.theme.config.summary;
20
- if (config.enable) {
21
- if (typeof db?.[path] !== 'undefined' && typeof db?.[path]?.[dbPath] !== 'undefined') {
22
- return db[path][dbPath];
23
- }
24
- else {
25
- if (typeof db?.[path] === 'undefined') {
26
- db[path] = {};
27
- }
28
- else {
29
- db[path][dbPath] = '';
30
- }
31
- }
32
- if (config.mode === 'openai') {
33
- const request = () => {
34
- fetch(`${config.openai.remote}/v1/chat/completions`, {
35
- method: 'POST',
36
- headers: requestHeaders,
37
- body: JSON.stringify(requestBody)
38
- }).then((response) => {
39
- if (!response.ok) {
40
- throw Error('ERROR: Failed to get summary from Openai API');
41
- }
42
- response.json().then((data) => {
43
- // @ts-ignore
44
- const summary = data.choices[0].message.content;
45
- try {
46
- db[path][dbPath] = summary;
47
- }
48
- catch (e) {
49
- db ??= {};
50
- db[path] ??= {};
51
- db[path][dbPath] ??= '';
52
- db[path][dbPath] = summary;
53
- }
54
- node_fs_1.default.writeFileSync('summary.json', JSON.stringify(db));
55
- if (node_fs_1.default.existsSync('requested.lock')) {
56
- node_fs_1.default.unlinkSync('requested.lock');
57
- }
58
- return summary;
59
- });
60
- });
61
- };
62
- const checkTime = (waitTime) => {
63
- if (node_fs_1.default.existsSync('request.lock')) {
64
- if (node_fs_1.default.existsSync('requested.lock')) {
65
- setTimeout(checkTime, 1000 * waitTime);
66
- return;
67
- }
68
- // Openai API 针对个人用户免费试用限制 3 RPM,这里是25s后发送请求
69
- node_fs_1.default.writeFileSync('requested.lock', '');
70
- setTimeout(request, 1000 * 2.5 * waitTime);
71
- node_fs_1.default.unlinkSync('request.lock');
72
- }
73
- else {
74
- node_fs_1.default.writeFileSync('request.lock', '');
75
- request();
76
- }
77
- };
78
- const requestHeaders = {
79
- 'Content-Type': 'application/json',
80
- Authorization: `Bearer ${config.openai.apikey}`
81
- };
82
- const requestBody = {
83
- model: 'gpt-3.5-turbo',
84
- messages: [{ role: 'user', content: `${startMessage} ${content}` }],
85
- temperature: 0.7
86
- };
87
- if (config.pricing === 'trial') {
88
- hexo.log.info('Requesting OpenAI API... (3 RPM mode)');
89
- hexo.log.info('It may take 20 minutes or more (depending on the number of articles, each one takes 25 seconds)');
90
- checkTime(10);
91
- }
92
- else {
93
- hexo.log.info('Requesting OpenAI API... (60 RPM mode)');
94
- checkTime(0.5);
95
- }
96
- }
97
- else {
98
- // custom尚未支持
99
- }
100
- }
101
- }
102
- hexo.extend.helper.register('get_summary', (post) => {
103
- return postMessage(post.path, getContent(post), 'summary', '请为下述文章提供一份200字以内的概括,使用中文回答且尽可能简洁: ');
104
- });
105
- hexo.extend.helper.register('get_introduce', () => {
106
- return hexo.theme.config.summary.introduce;
107
- });
@@ -1,69 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /* global hexo */
4
- /*!
5
- hexo-symbols-count-time by theme-next
6
- under GNU Lesser General Public License v3.0 or later
7
- https://github.com/theme-next/hexo-symbols-count-time/blob/master/LICENSE
8
- */
9
- const hexo_util_1 = require("hexo-util");
10
- const config = hexo.config.symbols_count_time = Object.assign({
11
- symbols: true,
12
- time: true,
13
- total_symbols: true,
14
- total_time: true,
15
- exclude_codeblock: false,
16
- awl: 4,
17
- wpm: 275,
18
- suffix: 'mins.'
19
- }, hexo.config.symbols_count_time);
20
- function getSymbols(post) {
21
- return post?._content?.length ?? post?.content?.length ?? post.length;
22
- }
23
- function getSymbolsTotal(site) {
24
- let symbolsResultCount = 0;
25
- site.posts.forEach((post) => {
26
- symbolsResultCount += getSymbols(post);
27
- });
28
- return symbolsResultCount;
29
- }
30
- function getFormatTime(minutes, suffix) {
31
- const fHours = Math.floor(minutes / 60);
32
- let fMinutes = Math.floor(minutes - (fHours * 60));
33
- if (fMinutes < 1) {
34
- fMinutes = 1; // 0 => 1
35
- }
36
- return fHours < 1
37
- ? fMinutes + ' ' + suffix // < 59 => 59 mins.
38
- : fHours + ':' + ('00' + fMinutes).slice(-2); // = 61 => 1:01
39
- }
40
- hexo.extend.helper.register('symbolsCount', function (post) {
41
- let symbolsResult = getSymbols(post);
42
- if (symbolsResult > 9999) {
43
- symbolsResult = Math.round(symbolsResult / 1000) + 'k'; // > 9999 => 11k
44
- }
45
- else if (symbolsResult > 999) {
46
- symbolsResult = Math.round(symbolsResult / 100) / 10 + 'k'; // > 999 => 1.1k
47
- } // < 999 => 111
48
- return symbolsResult;
49
- });
50
- hexo.extend.helper.register('symbolsTime', function (post, awl = config.awl, wpm = config.wpm, suffix = config.suffix) {
51
- const minutes = Math.round(getSymbols(post) / (awl * wpm));
52
- return getFormatTime(minutes, suffix);
53
- });
54
- hexo.extend.helper.register('symbolsCountTotal', function (site) {
55
- const symbolsResultTotal = getSymbolsTotal(site);
56
- return symbolsResultTotal < 1000000
57
- ? Math.round(symbolsResultTotal / 1000) + 'k' // < 999k => 111k
58
- : Math.round(symbolsResultTotal / 100000) / 10 + 'm'; // > 999k => 1.1m
59
- });
60
- hexo.extend.helper.register('symbolsTimeTotal', function (site, awl = config.awl, wpm = config.wpm, suffix = config.suffix) {
61
- const minutes = Math.round(getSymbolsTotal(site) / (awl * wpm));
62
- return getFormatTime(minutes, suffix);
63
- });
64
- hexo.extend.filter.register('after_post_render', (data) => {
65
- let { content } = data;
66
- if (config.exclude_codeblock)
67
- content = content.replace(/<pre>.*?<\/pre>/g, '');
68
- data.length = (0, hexo_util_1.stripHTML)(content).replace(/\r?\n|\r/g, '').replace(/\s+/g, '').length;
69
- }, 0);
@@ -1,32 +0,0 @@
1
- /* global hexo */
2
- let findProblem = false;
3
- hexo.on('generateBefore', function () {
4
- if (hexo.config.syntax_highlighter) {
5
- findProblem = true;
6
- hexo.log.error('[SXEC 101] Highlight.js or Prismjs enabled. The code block will render incomplete');
7
- }
8
- if (!hexo.config.markdown) {
9
- findProblem = true;
10
- hexo.log.error(`[SXEC 102] Critical rendering plugins are missing or incorrectly configured.
11
- Some features will be disabled or render incorrectly`);
12
- }
13
- if (parseInt(process.version.match(/\d{2,3}/)[0]) < 18) {
14
- findProblem = true;
15
- hexo.log.error('[SXEC 103] Too old Node.js version, install the latest LTS version');
16
- }
17
- if (!hexo.config.title || !hexo.config.description || !hexo.config.language || !hexo.config.timezone || !hexo.config.url) {
18
- findProblem = true;
19
- hexo.log.warn('[SXEC 201] Essential information(title, desc, lang, etc) config incorrectly, Page will render incorrectly');
20
- }
21
- if (hexo.theme.config.gitalk?.clientID || hexo.theme.config.giscus?.repo) {
22
- findProblem = true;
23
- hexo.log.warn('[SXEC 202] You are using an deprecated feature and it was removed in the v0.3.10');
24
- }
25
- });
26
- hexo.on('generateAfter', function () {
27
- if (findProblem) {
28
- hexo.log.warn(`The environment check found some problems that can lead to rendering errors, effect errors,
29
- performance degradation, not working correctly, etc`);
30
- hexo.log.warn('ShokaX has output them into console, read them to get more information. You can search error code in docs(For example, SXEC 101)');
31
- }
32
- });
@@ -1,78 +0,0 @@
1
- "use strict";
2
- /*!
3
- index.js in next-theme/hexo-theme-next by next-theme
4
- under GNU AFFERO GENERAL PUBLIC LICENSE v3.0 OR LATER
5
- https://github.com/next-theme/hexo-theme-next/blob/master/LICENSE.md
6
- */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
- Object.defineProperty(o, "default", { enumerable: true, value: v });
20
- }) : function(o, v) {
21
- o["default"] = v;
22
- });
23
- var __importStar = (this && this.__importStar) || function (mod) {
24
- if (mod && mod.__esModule) return mod;
25
- var result = {};
26
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27
- __setModuleDefault(result, mod);
28
- return result;
29
- };
30
- var __importDefault = (this && this.__importDefault) || function (mod) {
31
- return (mod && mod.__esModule) ? mod : { "default": mod };
32
- };
33
- Object.defineProperty(exports, "__esModule", { value: true });
34
- const injects_1 = __importDefault(require("./lib/injects"));
35
- const package_json_1 = require("../../package.json");
36
- const fs = __importStar(require("node:fs"));
37
- hexo.on('generateBefore', () => {
38
- // 加载`theme_injects`过滤器
39
- (0, injects_1.default)(hexo);
40
- if (fs.existsSync('request.lock')) {
41
- fs.unlinkSync('request.lock');
42
- }
43
- if (fs.existsSync('requested.lock')) {
44
- fs.unlinkSync('requested.lock');
45
- }
46
- });
47
- hexo.on('generateAfter', () => {
48
- // 检查版本更新
49
- fetch('https://api.github.com/repos/theme-shoka-x/hexo-theme-shokaX/releases/latest').then((res) => {
50
- res.json().then((resp) => {
51
- try {
52
- const latest = resp.tag_name.replace('v', '').split('.');
53
- const current = package_json_1.version.split('.');
54
- let isOutdated = false;
55
- for (let i = 0; i < Math.max(latest.length, current.length); i++) {
56
- if (!current[i] || latest[i] > current[i]) {
57
- isOutdated = true;
58
- break;
59
- }
60
- if (latest[i] < current[i]) {
61
- break;
62
- }
63
- }
64
- if (isOutdated) {
65
- hexo.log.warn(`Your theme ShokaX is outdated. Current version: v${current.join('.')}, latest version: v${latest.join('.')}`);
66
- hexo.log.warn('Visit https://github.com/theme-shoka-x/hexo-theme-shokaX/releases for more information.');
67
- }
68
- }
69
- catch (e) {
70
- hexo.log.warn('Failed to detect version info. Error message:');
71
- hexo.log.warn(e);
72
- }
73
- }).catch((e) => {
74
- hexo.log.warn('Failed to detect version info. Error message:');
75
- hexo.log.warn(e);
76
- });
77
- });
78
- });
@@ -1,20 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {
4
- views: [
5
- 'head',
6
- 'sidebar',
7
- 'rightNav',
8
- 'postMeta',
9
- 'postBodyEnd',
10
- 'footer',
11
- 'bodyEnd',
12
- 'comment',
13
- 'status'
14
- ],
15
- styles: [
16
- 'variable',
17
- 'mixin',
18
- 'style'
19
- ]
20
- };
@@ -1,89 +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
- /*!
7
- inject.js in next-theme/hexo-theme-next by next-theme
8
- under GNU AFFERO GENERAL PUBLIC LICENSE v3.0 OR LATER
9
- https://github.com/next-theme/hexo-theme-next/blob/master/LICENSE.md
10
- */
11
- const node_fs_1 = __importDefault(require("node:fs"));
12
- const node_path_1 = __importDefault(require("node:path"));
13
- const injects_point_1 = __importDefault(require("./injects-point"));
14
- const defaultExtname = '.pug';
15
- class StylusInject {
16
- files;
17
- base_dir;
18
- constructor(base_dir) {
19
- this.base_dir = base_dir;
20
- this.files = [];
21
- }
22
- push(file) {
23
- this.files.push(node_path_1.default.resolve(this.base_dir, file));
24
- }
25
- }
26
- // Defining view types
27
- class ViewInject {
28
- base_dir;
29
- raws;
30
- constructor(base_dir) {
31
- this.base_dir = base_dir;
32
- this.raws = [];
33
- }
34
- raw(name, raw, ...args) {
35
- // Set default extname
36
- if (node_path_1.default.extname(name) === '') {
37
- name += defaultExtname;
38
- }
39
- this.raws.push({ name, raw, args });
40
- }
41
- file(name, file, ...args) {
42
- // Set default extname from file's extname
43
- if (node_path_1.default.extname(name) === '') {
44
- name += node_path_1.default.extname(file);
45
- }
46
- // Get absolute path base on hexo dir
47
- this.raw(name, node_fs_1.default.readFileSync(node_path_1.default.resolve(this.base_dir, file), 'utf8'), ...args);
48
- }
49
- }
50
- // Init injects
51
- function initInject(base_dir) {
52
- const injects = {};
53
- injects_point_1.default.styles.forEach(item => {
54
- injects[item] = new StylusInject(base_dir);
55
- });
56
- injects_point_1.default.views.forEach(item => {
57
- injects[item] = new ViewInject(base_dir);
58
- });
59
- return injects;
60
- }
61
- exports.default = (hexo) => {
62
- // Exec theme_inject filter
63
- const injects = initInject(hexo.base_dir);
64
- hexo.execFilterSync('theme_inject', injects);
65
- hexo.theme.config.injects = {};
66
- // Inject stylus
67
- injects_point_1.default.styles.forEach(type => {
68
- hexo.theme.config.injects[type] = injects[type].files;
69
- });
70
- // Inject views
71
- injects_point_1.default.views.forEach(type => {
72
- const configs = Object.create(null);
73
- hexo.theme.config.injects[type] = [];
74
- // Add or override view.
75
- injects[type].raws.forEach((injectObj, index) => {
76
- const name = `inject/${type}/${injectObj.name}`;
77
- hexo.theme.setView(name, injectObj.raw);
78
- configs[name] = {
79
- layout: name,
80
- locals: injectObj.args[0],
81
- options: injectObj.args[1],
82
- order: injectObj.args[2] || index
83
- };
84
- });
85
- // Views sort.
86
- hexo.theme.config.injects[type] = Object.values(configs)
87
- .sort((x, y) => x.order - y.order);
88
- });
89
- };
@@ -1,44 +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
- const node_fs_1 = __importDefault(require("node:fs"));
7
- const node_path_1 = __importDefault(require("node:path"));
8
- const js_yaml_1 = __importDefault(require("js-yaml"));
9
- function linkGrid(args, content) {
10
- const theme = hexo.theme.config;
11
- if (!args[0] && !content) {
12
- return;
13
- }
14
- if (args[0]) {
15
- const filepath = node_path_1.default.join(hexo.source_dir, args[0]);
16
- if (node_fs_1.default.existsSync(filepath)) {
17
- content = node_fs_1.default.readFileSync(filepath, { encoding: 'utf-8' });
18
- }
19
- }
20
- if (!content) {
21
- return;
22
- }
23
- const list = js_yaml_1.default.load(content);
24
- let result = '';
25
- list.forEach((item) => {
26
- if (!item.url || !item.site) {
27
- return;
28
- }
29
- let item_image = item.image || theme.assets + '/404.png';
30
- if (!item_image.startsWith('//') && !item_image.startsWith('http')) {
31
- item_image = theme.statics + item_image;
32
- }
33
- item.color = item.color ? ` style="--block-color:${item.color};"` : '';
34
- result += `<div class="item" title="${item.owner || item.site}"${item.color}>`;
35
- result += `<a href="${item.url}" class="image" data-background-image="${item_image}"></a>
36
- <div class="info">
37
- <a href="${item.url}" class="title">${item.site}</a>
38
- <p class="desc">${item.desc || item.url}</p>
39
- </div></div>`;
40
- });
41
- return `<div class="links">${result}</div>`;
42
- }
43
- hexo.extend.tag.register('links', linkGrid, { ends: true });
44
- hexo.extend.tag.register('linksfile', linkGrid, { ends: false, async: true });