hexo-theme-shokax 0.5.0-dev-f787465 → 0.5.0-dev-36bb58f
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.
- package/README.md +2 -2
- package/UsageRestrictions.md +1 -1
- package/_config.yml +14 -15
- package/languages/en.yml +2 -0
- package/languages/ja.yml +2 -0
- package/languages/zh-CN.yml +2 -0
- package/languages/zh-HK.yml +2 -0
- package/languages/zh-TW.yml +2 -0
- package/layout/_partials/layout.pug +10 -5
- package/layout/_partials/post/footer.pug +8 -5
- package/package.json +31 -21
- package/scripts/generaters/config.js +12 -7
- package/scripts/generaters/images.js +9 -8
- package/scripts/generaters/script.js +21 -33
- package/scripts/generaters/summary_ai.js +130 -0
- package/scripts/helpers/summary_ai.js +1 -108
- package/scripts/plugin/index.js +32 -69
- package/source/css/_common/outline/sidebar/quick.styl +1 -1
- package/source/css/_common/outline/sidebar/sidebar.styl +2 -0
- package/source/js/_app/components/comments.ts +0 -2
- package/source/js/_app/components/sidebar.ts +37 -36
- package/source/js/_app/globals/globalVars.ts +0 -3
- package/source/js/_app/globals/handles.ts +9 -9
- package/source/js/_app/globals/themeColor.ts +5 -6
- package/source/js/_app/globals/thirdparty.ts +2 -2
- package/source/js/_app/globals/tools.ts +4 -6
- package/source/js/_app/library/anime.ts +30 -19
- package/source/js/_app/library/declare.d.ts +1 -0
- package/source/js/_app/library/proto.ts +0 -67
- package/source/js/_app/library/vue.ts +6 -7
- package/source/js/_app/page/common.ts +8 -10
- package/source/js/_app/page/fancybox.ts +13 -13
- package/source/js/_app/page/post.ts +42 -44
- package/source/js/_app/page/search.ts +0 -1
- package/source/js/_app/page/tab.ts +8 -9
- package/source/js/_app/pjax/domInit.ts +2 -5
- package/source/js/_app/pjax/refresh.ts +9 -0
- package/source/js/_app/pjax/siteInit.ts +18 -14
- package/source/js/_app/player.ts +26 -27
- package/toolbox/compiler.mjs +20 -48
- package/scripts/plugin/lib/injects-point.js +0 -41
- package/scripts/plugin/lib/injects.js +0 -105
- package/source/js/_app/library/dom.ts +0 -28
- package/source/js/_app/library/storage.ts +0 -12
package/README.md
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
- [x] 移除 pjax
|
6
6
|
- [x] 移除 quicklink
|
7
7
|
- [x] 移除 assetUrl 为基的动态 Vendor 机制
|
8
|
-
- [
|
8
|
+
- [x] 移除 ShokaX Inject
|
9
9
|
- [ ] 引入新的 Inject 类技术 (长期)
|
10
10
|
- [ ] 引入新的工作流程
|
11
|
-
- [ ] 引入 CI 自动测试
|
12
11
|
- [ ] 重构 player (暂时移除)
|
12
|
+
- [ ] 重构并修改代码块
|
13
13
|
- [ ] 优化 menu 配置格式
|
14
14
|
- [ ] 优化和异步化 Smart Bundle 技术
|
15
15
|
- [ ] 优化 CSS 结构和加载
|
package/UsageRestrictions.md
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
## 处理方式
|
17
17
|
如果您违反了上述使用限制和AGPLv3的任何规定,ShokaX 项目组保留采取以下措施之一或多个的权利:
|
18
18
|
- 发出警告通知并要求立即纠正违规行为;(根据`AGPLv3 八`)
|
19
|
-
- 暂停或终止您对 ShokaX 及其子项目的使用权限并取消
|
19
|
+
- 暂停或终止您对 ShokaX 及其子项目的使用权限并取消AGPLv3授予您的权利;(根据`AGPLv3 八`)
|
20
20
|
- 取消您获取 ShokaX 社区支持和进行协作的权利;(社区管理)
|
21
21
|
- 追究法律责任,包括要求赔偿因违规行为给 ShokaX 项目组造成的损失。(依照相关法律而定)
|
22
22
|
|
package/_config.yml
CHANGED
@@ -34,6 +34,7 @@ experiments:
|
|
34
34
|
enablePreload: true #是否开启预加载头图
|
35
35
|
enableNextGradientCover: false # 使用CSS渐变作为上/下一页封面
|
36
36
|
copyrightLength: 50 # 自定义复制时显示copyright的长度
|
37
|
+
antiFakeWebsite: true # 防止恶意网站伪装
|
37
38
|
|
38
39
|
homeConfig:
|
39
40
|
gradient: false # 使用CSS渐变作为文章封面
|
@@ -202,12 +203,12 @@ waline:
|
|
202
203
|
lang: "zh-CN"
|
203
204
|
locale: {} # https://waline.js.org/guide/features/i18n.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E8%AF%AD%E8%A8%80
|
204
205
|
emoji: # 表情包
|
205
|
-
- https://unpkg.com/@waline/emojis@1.0.1/weibo
|
206
|
-
- https://unpkg.com/@waline/emojis@1.0.1/alus
|
207
|
-
- https://unpkg.com/@waline/emojis@1.0.1/bilibili
|
208
|
-
- https://unpkg.com/@waline/emojis@1.0.1/qq
|
209
|
-
- https://unpkg.com/@waline/emojis@1.0.1/tieba
|
210
|
-
- https://unpkg.com/@waline/emojis@1.0.1/tw-emoji
|
206
|
+
# - https://unpkg.com/@waline/emojis@1.0.1/weibo
|
207
|
+
# - https://unpkg.com/@waline/emojis@1.0.1/alus
|
208
|
+
# - https://unpkg.com/@waline/emojis@1.0.1/bilibili
|
209
|
+
# - https://unpkg.com/@waline/emojis@1.0.1/qq
|
210
|
+
# - https://unpkg.com/@waline/emojis@1.0.1/tieba
|
211
|
+
# - https://unpkg.com/@waline/emojis@1.0.1/tw-emoji
|
211
212
|
meta: # 可以填写的内容
|
212
213
|
- nick
|
213
214
|
- mail
|
@@ -221,12 +222,13 @@ waline:
|
|
221
222
|
|
222
223
|
summary:
|
223
224
|
enable: false
|
224
|
-
introduce: "
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
225
|
+
introduce: "" # AI自我介绍
|
226
|
+
model:
|
227
|
+
apiKey:
|
228
|
+
apiUrl:
|
229
|
+
temperature:
|
230
|
+
initalPrompt:
|
231
|
+
concurrency: 5
|
230
232
|
|
231
233
|
# Social Links
|
232
234
|
# Usage: `Key: permalink || icon || color`
|
@@ -343,9 +345,6 @@ search:
|
|
343
345
|
hits:
|
344
346
|
per_page: 10
|
345
347
|
|
346
|
-
# Dependencies: https://github.com/amehime/hexo-renderer-multi-markdown-it
|
347
|
-
pangu: false
|
348
|
-
|
349
348
|
#! ---------------------------------------------------------------
|
350
349
|
#! DO NOT EDIT THE FOLLOWING `vendors` SETTINGS
|
351
350
|
#! UNLESS YOU KNOW WHAT YOU ARE DOING
|
package/languages/en.yml
CHANGED
@@ -67,6 +67,7 @@ footer:
|
|
67
67
|
powered: "Powered by %s"
|
68
68
|
total_views: Total Views
|
69
69
|
total_visitors: Total Visitors
|
70
|
+
loading: "Loading..."
|
70
71
|
|
71
72
|
counter:
|
72
73
|
index:
|
@@ -109,6 +110,7 @@ symbol:
|
|
109
110
|
comma: ", "
|
110
111
|
period: ". "
|
111
112
|
colon: ": "
|
113
|
+
space: " "
|
112
114
|
year: "Y"
|
113
115
|
month: "M"
|
114
116
|
|
package/languages/ja.yml
CHANGED
@@ -67,6 +67,7 @@ footer:
|
|
67
67
|
powered: "Powered by %s"
|
68
68
|
total_views: 閲覧合計数
|
69
69
|
total_visitors: 合計閲覧者数
|
70
|
+
loading: "ローディング..."
|
70
71
|
|
71
72
|
counter:
|
72
73
|
index:
|
@@ -109,6 +110,7 @@ symbol:
|
|
109
110
|
comma: "、"
|
110
111
|
period: "。"
|
111
112
|
colon: ":"
|
113
|
+
space: " "
|
112
114
|
year: 年
|
113
115
|
month: 月
|
114
116
|
|
package/languages/zh-CN.yml
CHANGED
@@ -67,6 +67,7 @@ footer:
|
|
67
67
|
powered: "基于 %s"
|
68
68
|
total_views: 总访问量
|
69
69
|
total_visitors: 总访客量
|
70
|
+
loading: "加载中..."
|
70
71
|
|
71
72
|
counter:
|
72
73
|
index:
|
@@ -109,6 +110,7 @@ symbol:
|
|
109
110
|
comma: ","
|
110
111
|
period: "。"
|
111
112
|
colon: ":"
|
113
|
+
space: " "
|
112
114
|
year: 年
|
113
115
|
month: 月
|
114
116
|
|
package/languages/zh-HK.yml
CHANGED
@@ -67,6 +67,7 @@ footer:
|
|
67
67
|
powered: "基於 %s"
|
68
68
|
total_views: 總瀏覽次數
|
69
69
|
total_visitors: 訪客總數
|
70
|
+
loading: "載入中..."
|
70
71
|
|
71
72
|
counter:
|
72
73
|
index:
|
@@ -109,6 +110,7 @@ symbol:
|
|
109
110
|
comma: ","
|
110
111
|
period: "。"
|
111
112
|
colon: ":"
|
113
|
+
space: " "
|
112
114
|
year: 年
|
113
115
|
month: 月
|
114
116
|
|
package/languages/zh-TW.yml
CHANGED
@@ -67,6 +67,7 @@ footer:
|
|
67
67
|
powered: "基於 %s"
|
68
68
|
total_views: 總瀏覽次數
|
69
69
|
total_visitors: 訪客總數
|
70
|
+
loading: "載入中..."
|
70
71
|
|
71
72
|
counter:
|
72
73
|
index:
|
@@ -109,6 +110,7 @@ symbol:
|
|
109
110
|
comma: ","
|
110
111
|
period: "。"
|
111
112
|
colon: ":"
|
113
|
+
space: " "
|
112
114
|
year: 年
|
113
115
|
month: 月
|
114
116
|
|
@@ -14,9 +14,11 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
14
14
|
if enablePreload && enableCover
|
15
15
|
if enableFixedCover
|
16
16
|
link(rel="preload" href=theme.homeConfig.fixedCover as="image" fetchpriority="high")
|
17
|
-
else
|
17
|
+
else if Array.isArray(covers)
|
18
18
|
each image in covers
|
19
|
-
link(rel="preload" href
|
19
|
+
link(rel="preload" href!=image as="image" fetchpriority="high")
|
20
|
+
else
|
21
|
+
link(rel="preload" href!=covers as="image" fetchpriority="high")
|
20
22
|
|
21
23
|
!= partial('_partials/head/head_com.pug')
|
22
24
|
!= shokax_inject('head')
|
@@ -89,11 +91,13 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
89
91
|
else
|
90
92
|
- audioValue = "undefined"
|
91
93
|
|
94
|
+
- var ccIcon = '<i class="ic i-creative-commons"></i>'
|
95
|
+
- var ccText = theme.creative_commons.license.toUpperCase()
|
92
96
|
script(data-config type="text/javascript").
|
93
97
|
var LOCAL = {
|
94
98
|
ispost: !{is_post()},
|
95
|
-
|
96
|
-
|
99
|
+
path: `#{_permapath(page.path)}`,
|
100
|
+
favicon: {
|
97
101
|
show: `#{__('favicon.show')}`,
|
98
102
|
hide: `#{__('favicon.hide')}`
|
99
103
|
},
|
@@ -102,6 +106,8 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
102
106
|
empty: "!{__('search.empty')}",
|
103
107
|
stats: "!{__('search.stats')}"
|
104
108
|
},
|
109
|
+
nocopy: "!{!!page.nocopy}",
|
110
|
+
copyright: `!{page.copyright !== false ? (page.nocopy === true ? __("tips.nocopy") : __("tips.copyright", ccIcon + ccText)) : undefined}`,
|
105
111
|
copy_tex: #{!!page.math},
|
106
112
|
katex: #{!!page.math},
|
107
113
|
mermaid: #{!!page.mermaid},
|
@@ -137,4 +143,3 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
137
143
|
!= shokax_inject('bodyEnd')
|
138
144
|
|
139
145
|
|
140
|
-
|
@@ -1,16 +1,19 @@
|
|
1
1
|
div(class="meta")
|
2
|
-
if
|
3
|
-
|
2
|
+
if theme.twikoo.enable || theme.waline.pageview
|
3
|
+
span(class="item")
|
4
4
|
span(class="icon")
|
5
5
|
i(class="ic i-eye")
|
6
|
-
span
|
6
|
+
span(class="text")
|
7
|
+
!=__('footer.total_views') + __('symbol.colon')
|
7
8
|
- var prefixedPath = post.path.startsWith('/') ? post.path : '/' + post.path
|
8
|
-
span(id="twikoo_visitors" class="waline-pageview-count" data-path=prefixedPath)
|
9
|
+
span(id="twikoo_visitors" class="waline-pageview-count" data-path=prefixedPath)
|
10
|
+
!=__('footer.loading')
|
11
|
+
if date(post.date) !== date(post.updated) || time(post.date) !== time(post.updated)
|
9
12
|
span(class="item")
|
10
13
|
span(class="icon")
|
11
14
|
i(class="ic i-calendar-check")
|
12
15
|
span(class="text")
|
13
|
-
!= __('post.edited')
|
16
|
+
!= __('post.edited') + __('symbol.space')
|
14
17
|
time(title=__('post.modified') + __('symbol.colon') + full_date(post.updated) itemprop="dateModified" datetime=moment(post.updated).format())
|
15
18
|
!= date(post.updated)
|
16
19
|
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "hexo-theme-shokax",
|
3
|
-
"version": "0.5.0-dev-
|
3
|
+
"version": "0.5.0-dev-36bb58f",
|
4
4
|
"description": "a hexo theme based on shoka",
|
5
5
|
"main": "index.js",
|
6
6
|
"repository": "https://github.com/theme-shoka-x/hexo-theme-shokaX",
|
7
7
|
"author": "zkz098",
|
8
8
|
"license": "AGPL-3.0-or-later",
|
9
|
-
"packageManager": "pnpm@
|
9
|
+
"packageManager": "pnpm@10.6.5",
|
10
10
|
"scripts": {
|
11
11
|
"test": "tsc --build --verbose",
|
12
12
|
"build": "node ./toolbox/compiler.mjs"
|
@@ -16,34 +16,40 @@
|
|
16
16
|
"@types/jquery": "^3.5.32",
|
17
17
|
"@types/js-yaml": "^4.0.9",
|
18
18
|
"@types/katex": "^0.16.7",
|
19
|
-
"@types/node": "^22.
|
20
|
-
"@
|
21
|
-
"@typescript-eslint/
|
22
|
-
"eslint": "^
|
19
|
+
"@types/node": "^22.13.10",
|
20
|
+
"@types/quicklink": "^2.3.4",
|
21
|
+
"@typescript-eslint/eslint-plugin": "^8.27.0",
|
22
|
+
"@typescript-eslint/parser": "^8.27.0",
|
23
|
+
"eslint": "^9.22.0",
|
23
24
|
"eslint-config-standard": "~17",
|
24
|
-
"eslint-plugin-vue": "^
|
25
|
-
"glob": "^11.0.
|
26
|
-
"typescript": "^5.
|
25
|
+
"eslint-plugin-vue": "^10.0.0",
|
26
|
+
"glob": "^11.0.1",
|
27
|
+
"typescript": "^5.8.2"
|
27
28
|
},
|
28
29
|
"dependencies": {
|
29
|
-
"@algolia/client-search": "^5.
|
30
|
-
"@
|
31
|
-
"
|
32
|
-
"
|
30
|
+
"@algolia/client-search": "^5.21.0",
|
31
|
+
"@common.js/p-limit": "^6.1.0",
|
32
|
+
"@waline/client": "^3.5.6",
|
33
|
+
"algoliasearch": "5.21.0",
|
34
|
+
"dompurify": "^3.2.4",
|
35
|
+
"es-toolkit": "^1.33.0",
|
36
|
+
"esbuild": "^0.25.1",
|
33
37
|
"hexo": "^7.3.0",
|
34
38
|
"hexo-algoliasearch": "^2.0.1",
|
35
39
|
"hexo-feed": "^1.1.2",
|
36
|
-
"hexo-fs": "^
|
40
|
+
"hexo-fs": "^5.0.0",
|
37
41
|
"hexo-pagination": "^4.0.0",
|
38
42
|
"hexo-renderer-pug": "^3.0.0",
|
39
43
|
"hexo-util": "^3.3.0",
|
40
|
-
"instantsearch.js": "^4.
|
44
|
+
"instantsearch.js": "^4.78.0",
|
41
45
|
"js-yaml": "^4.1.0",
|
42
|
-
"katex": "^0.16.
|
43
|
-
"mouse-firework": "^0.
|
44
|
-
"
|
45
|
-
"
|
46
|
-
"
|
46
|
+
"katex": "^0.16.21",
|
47
|
+
"mouse-firework": "^0.1.1",
|
48
|
+
"quicklink": "^2.3.0",
|
49
|
+
"theme-shokax-anime": "^0.0.8",
|
50
|
+
"theme-shokax-pjax": "^0.0.3",
|
51
|
+
"twikoo": "^1.6.41",
|
52
|
+
"unlazy": "^0.12.3"
|
47
53
|
},
|
48
54
|
"engines": {
|
49
55
|
"node": ">=20.0.0"
|
@@ -60,6 +66,10 @@
|
|
60
66
|
"object.fromentries": "npm:@nolyfill/object.fromentries@latest",
|
61
67
|
"object.groupby": "npm:@nolyfill/object.groupby@latest",
|
62
68
|
"object.values": "npm:@nolyfill/object.values@latest"
|
63
|
-
}
|
69
|
+
},
|
70
|
+
"onlyBuiltDependencies": [
|
71
|
+
"esbuild",
|
72
|
+
"hexo-util"
|
73
|
+
]
|
64
74
|
}
|
65
75
|
}
|
@@ -22,10 +22,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
22
22
|
mod
|
23
23
|
));
|
24
24
|
var import_hexo_util = require("hexo-util");
|
25
|
-
var
|
25
|
+
var import_promises = __toESM(require("node:fs/promises"));
|
26
26
|
var import_path = __toESM(require("path"));
|
27
27
|
var import_js_yaml = __toESM(require("js-yaml"));
|
28
|
-
hexo.extend.filter.register("before_generate", () => {
|
28
|
+
hexo.extend.filter.register("before_generate", async () => {
|
29
29
|
if (hexo.config.theme_config) {
|
30
30
|
hexo.theme.config = (0, import_hexo_util.deepMerge)(hexo.theme.config, hexo.config.theme_config);
|
31
31
|
}
|
@@ -44,20 +44,25 @@ hexo.extend.filter.register("before_generate", () => {
|
|
44
44
|
hexo.theme.config.style = {};
|
45
45
|
for (const style of ["iconfont", "colors", "custom"]) {
|
46
46
|
const custom_file = "source/_data/" + style + ".styl";
|
47
|
-
|
47
|
+
try {
|
48
|
+
await import_promises.default.readFile(custom_file);
|
48
49
|
hexo.theme.config.style[style] = import_path.default.resolve(hexo.base_dir, custom_file);
|
50
|
+
} catch {
|
49
51
|
}
|
50
52
|
}
|
51
53
|
if (data.images && data.images.length > 0) {
|
52
54
|
hexo.theme.config.image_list = data.images;
|
53
55
|
} else {
|
54
|
-
hexo.theme.config.image_list = import_js_yaml.default.load(
|
56
|
+
hexo.theme.config.image_list = import_js_yaml.default.load(await import_promises.default.readFile(import_path.default.join(__dirname, "../../_images.yml"), { encoding: "utf-8" }));
|
55
57
|
}
|
56
58
|
if (data.images_index && data.images_index.length > 0) {
|
57
59
|
hexo.theme.config.index_images = data.images_index;
|
58
|
-
} else if (import_node_fs.default.existsSync(import_path.default.join(__dirname, "../../_images_index.yml"))) {
|
59
|
-
hexo.theme.config.index_images = import_js_yaml.default.load(import_node_fs.default.readFileSync(import_path.default.join(__dirname, "../../_images_index.yml"), { encoding: "utf-8" }));
|
60
60
|
} else {
|
61
|
-
|
61
|
+
try {
|
62
|
+
const fileContent = await import_promises.default.readFile(import_path.default.join(__dirname, "../../_images_index.yml"), "utf-8");
|
63
|
+
hexo.theme.config.index_images = import_js_yaml.default.load(fileContent);
|
64
|
+
} catch (e) {
|
65
|
+
hexo.theme.config.index_images = data.index_images || [];
|
66
|
+
}
|
62
67
|
}
|
63
68
|
});
|
@@ -1,19 +1,20 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
hexo.extend.generator.register("images", function(locals) {
|
2
|
+
var import_promises = require("node:fs/promises");
|
3
|
+
hexo.extend.generator.register("images", async function(locals) {
|
4
4
|
const theme = hexo.theme.config;
|
5
5
|
const dir = "source/_data/" + theme.assets + "/";
|
6
|
-
|
6
|
+
try {
|
7
|
+
await (0, import_promises.readdir)(dir);
|
8
|
+
} catch (e) {
|
7
9
|
return;
|
8
10
|
}
|
9
11
|
const result = [];
|
10
|
-
const files =
|
11
|
-
files.forEach((file) => {
|
12
|
+
const files = await (0, import_promises.readdir)(dir);
|
13
|
+
files.forEach(async (file) => {
|
14
|
+
const fileContent = await (0, import_promises.readFile)(dir + file);
|
12
15
|
result.push({
|
13
16
|
path: theme.assets + "/" + file,
|
14
|
-
data:
|
15
|
-
return fs.createReadStream(dir + file);
|
16
|
-
}
|
17
|
+
data: fileContent
|
17
18
|
});
|
18
19
|
});
|
19
20
|
return result;
|
@@ -21,10 +21,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
21
21
|
mod
|
22
22
|
));
|
23
23
|
var import_package = __toESM(require("../../package.json"));
|
24
|
-
var
|
24
|
+
var import_promises = __toESM(require("node:fs/promises"));
|
25
25
|
var import_esbuild = require("esbuild");
|
26
26
|
var import_utils = require("../utils");
|
27
|
-
hexo.extend.generator.register("script", function(locals) {
|
27
|
+
hexo.extend.generator.register("script", async function(locals) {
|
28
28
|
const config = hexo.config;
|
29
29
|
const theme = hexo.theme.config;
|
30
30
|
const siteConfig = {
|
@@ -39,10 +39,6 @@ hexo.extend.generator.register("script", function(locals) {
|
|
39
39
|
darkmode: theme.darkmode,
|
40
40
|
auto_dark: theme.auto_dark,
|
41
41
|
auto_scroll: theme.auto_scroll,
|
42
|
-
js: {
|
43
|
-
copy_tex: (0, import_utils.getVendorLink)(hexo, theme.vendors.async_js.copy_tex),
|
44
|
-
fancybox: (0, import_utils.getVendorLink)(hexo, theme.vendors.async_js.fancybox)
|
45
|
-
},
|
46
42
|
css: {
|
47
43
|
katex: (0, import_utils.getVendorLink)(hexo, theme.vendors.css.katex),
|
48
44
|
mermaid: {
|
@@ -93,14 +89,15 @@ hexo.extend.generator.register("script", function(locals) {
|
|
93
89
|
siteConfig.audio = theme.audio;
|
94
90
|
}
|
95
91
|
let enterPoint, patchDir;
|
96
|
-
|
97
|
-
|
92
|
+
try {
|
93
|
+
await import_promises.default.readFile("themes/shokaX/source/js/_app/pjax/siteInit.ts", "utf-8");
|
98
94
|
enterPoint = "themes/shokaX/source/js/_app/pjax/siteInit.ts";
|
99
|
-
|
100
|
-
|
95
|
+
patchDir = "themes/shokaX/source/js/_app/components/cloudflare.ts";
|
96
|
+
} catch (e) {
|
101
97
|
enterPoint = "node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.ts";
|
98
|
+
patchDir = "node_modules/hexo-theme-shokax/source/js/_app/components/cloudflare.ts";
|
102
99
|
}
|
103
|
-
(0, import_esbuild.
|
100
|
+
const result = await (0, import_esbuild.build)({
|
104
101
|
entryPoints: [enterPoint],
|
105
102
|
bundle: true,
|
106
103
|
outdir: "shokaxTemp",
|
@@ -133,40 +130,33 @@ hexo.extend.generator.register("script", function(locals) {
|
|
133
130
|
__shokax_fancybox__: theme.modules.fancybox ? "true" : "false",
|
134
131
|
__shokax_waline__: theme.waline.enable ? "true" : "false",
|
135
132
|
__shokax_twikoo__: theme.twikoo.enable ? "true" : "false",
|
133
|
+
__shokax_antiFakeWebsite__: theme.experiments.antiFakeWebsite ? "true" : "false",
|
136
134
|
shokax_CONFIG: JSON.stringify(siteConfig),
|
137
135
|
shokax_siteURL: "'" + config.url + "'"
|
138
136
|
}
|
139
137
|
});
|
140
138
|
const res = [];
|
141
|
-
|
142
|
-
const
|
143
|
-
if (
|
144
|
-
const result = hexo.render.renderSync({ text: fileText, engine: "js" });
|
139
|
+
result.outputFiles.forEach((file) => {
|
140
|
+
const fileName = file.path.split("/").pop();
|
141
|
+
if (fileName.endsWith(".js")) {
|
145
142
|
res.push({
|
146
|
-
path: theme.js + "/" +
|
147
|
-
data:
|
148
|
-
return result;
|
149
|
-
}
|
143
|
+
path: theme.js + "/" + fileName,
|
144
|
+
data: file.text
|
150
145
|
});
|
151
|
-
} else if (
|
152
|
-
const result = hexo.render.renderSync({ text: fileText, engine: "css" });
|
146
|
+
} else if (fileName.endsWith(".css")) {
|
153
147
|
res.push({
|
154
|
-
path: theme.css + "/" +
|
155
|
-
data:
|
156
|
-
return result;
|
157
|
-
}
|
148
|
+
path: theme.css + "/" + fileName,
|
149
|
+
data: file.text
|
158
150
|
});
|
159
151
|
} else {
|
160
152
|
res.push({
|
161
|
-
path: theme.js + "/" +
|
162
|
-
data:
|
163
|
-
return fileText;
|
164
|
-
}
|
153
|
+
path: theme.js + "/" + fileName,
|
154
|
+
data: file.text
|
165
155
|
});
|
166
156
|
}
|
167
157
|
});
|
168
158
|
if (theme.experiments.cloudflarePatch) {
|
169
|
-
const
|
159
|
+
const patchRes = await (0, import_esbuild.build)({
|
170
160
|
entryPoints: [patchDir],
|
171
161
|
bundle: true,
|
172
162
|
platform: "browser",
|
@@ -186,9 +176,7 @@ hexo.extend.generator.register("script", function(locals) {
|
|
186
176
|
});
|
187
177
|
res.push({
|
188
178
|
path: theme.js + "/cf-patch.js",
|
189
|
-
data:
|
190
|
-
return import_node_fs.default.readFileSync("./cf-patch.js", { encoding: "utf-8" });
|
191
|
-
}
|
179
|
+
data: patchRes.outputFiles[0].text
|
192
180
|
});
|
193
181
|
}
|
194
182
|
return res;
|
@@ -0,0 +1,130 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
9
|
+
for (let key of __getOwnPropNames(from))
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
11
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
12
|
+
}
|
13
|
+
return to;
|
14
|
+
};
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
|
+
mod
|
22
|
+
));
|
23
|
+
var import_node_crypto = require("node:crypto");
|
24
|
+
var import_promises = __toESM(require("node:fs/promises"));
|
25
|
+
async function getSummaryByAPI(content) {
|
26
|
+
const apiKey = hexo.theme.config.summary.apiKey;
|
27
|
+
const apiUrl = hexo.theme.config.summary.apiUrl;
|
28
|
+
const model = hexo.theme.config.summary.model;
|
29
|
+
const temperature = hexo.theme.config.summary.temperature ?? 1.3;
|
30
|
+
const initalPrompt = hexo.theme.config.summary.initalPrompt;
|
31
|
+
const res = await fetch(apiUrl, {
|
32
|
+
method: "POST",
|
33
|
+
headers: {
|
34
|
+
"Content-Type": "application/json",
|
35
|
+
"Authorization": `Bearer ${apiKey}`
|
36
|
+
},
|
37
|
+
body: JSON.stringify({
|
38
|
+
model,
|
39
|
+
messages: [{
|
40
|
+
role: "system",
|
41
|
+
content: `${initalPrompt}`
|
42
|
+
}, {
|
43
|
+
role: "user",
|
44
|
+
content: `${content}`
|
45
|
+
}],
|
46
|
+
temperature
|
47
|
+
})
|
48
|
+
});
|
49
|
+
if (!res.ok) {
|
50
|
+
throw new Error(`Error: ${res.status} ${res.statusText}`);
|
51
|
+
}
|
52
|
+
const data = await res.json();
|
53
|
+
if (data.error) {
|
54
|
+
throw new Error(`Error: ${data.error.message}`);
|
55
|
+
}
|
56
|
+
const summary = data.choices[0].message.content;
|
57
|
+
return summary;
|
58
|
+
}
|
59
|
+
class SummaryDatabase {
|
60
|
+
fileChanged;
|
61
|
+
data;
|
62
|
+
constructor() {
|
63
|
+
this.fileChanged = false;
|
64
|
+
this.data = {
|
65
|
+
version: 2,
|
66
|
+
features: {
|
67
|
+
incremental: false
|
68
|
+
},
|
69
|
+
summaries: {}
|
70
|
+
};
|
71
|
+
}
|
72
|
+
async readDB() {
|
73
|
+
try {
|
74
|
+
await import_promises.default.access("summary.json");
|
75
|
+
this.data = JSON.parse(await import_promises.default.readFile("summary.json", "utf-8"));
|
76
|
+
} catch (error) {
|
77
|
+
}
|
78
|
+
if (this.data.version !== 2) {
|
79
|
+
throw new Error(`Incompatible version of summary database: ${this.data.version}`);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
async writeDB() {
|
83
|
+
if (this.fileChanged) {
|
84
|
+
await import_promises.default.writeFile("summary.json", JSON.stringify(this.data));
|
85
|
+
}
|
86
|
+
}
|
87
|
+
async getPostSummary(path, content) {
|
88
|
+
const pathHash = (0, import_node_crypto.createHash)("sha256").update(path).digest("hex");
|
89
|
+
const contentHash = (0, import_node_crypto.createHash)("sha256").update(content).digest("hex");
|
90
|
+
if (this.data.summaries[pathHash]?.sha256 === contentHash) {
|
91
|
+
return this.data.summaries[pathHash].summary;
|
92
|
+
} else {
|
93
|
+
const summaryContent = await getSummaryByAPI(content);
|
94
|
+
this.data.summaries[pathHash] = {
|
95
|
+
summary: summaryContent,
|
96
|
+
sha256: contentHash
|
97
|
+
};
|
98
|
+
this.fileChanged = true;
|
99
|
+
return summaryContent;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
hexo.extend.generator.register("summary_ai", async function(locals) {
|
104
|
+
const posts = locals.posts;
|
105
|
+
if (!hexo.theme.config.summary.enable) {
|
106
|
+
return;
|
107
|
+
}
|
108
|
+
const db = new SummaryDatabase();
|
109
|
+
await db.readDB();
|
110
|
+
const postArray = posts.toArray();
|
111
|
+
const pLimit = require("@common.js/p-limit").default;
|
112
|
+
const concurrencyLimit = pLimit(hexo.theme.config.summary?.concurrency || 5);
|
113
|
+
const processingPromises = postArray.map((post) => concurrencyLimit(async () => {
|
114
|
+
const content = post.content;
|
115
|
+
const path = post.path;
|
116
|
+
const published = post.published;
|
117
|
+
if (content && path && published && content.length > 0) {
|
118
|
+
try {
|
119
|
+
const summary = await db.getPostSummary(path, content);
|
120
|
+
post.summary = summary;
|
121
|
+
} catch (error) {
|
122
|
+
hexo.log.error(`[ShokaX Summary AI] \u5904\u7406\u6587\u7AE0 ${path} \u65F6\u51FA\u9519:`, error.message);
|
123
|
+
post.summary = `${error.message}`;
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}));
|
127
|
+
await Promise.all(processingPromises);
|
128
|
+
await db.writeDB();
|
129
|
+
hexo.log.info(`[ShokaX Summary AI] \u6240\u6709\u6587\u7AE0\u6458\u8981\u5904\u7406\u5B8C\u6210\uFF0C\u5DF2\u4FDD\u5B58\u5230\u6570\u636E\u5E93`);
|
130
|
+
});
|