hexo-theme-shokax 0.4.22 → 0.4.24

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/_config.yml CHANGED
@@ -228,6 +228,7 @@ summary:
228
228
  apiUrl:
229
229
  temperature:
230
230
  initalPrompt:
231
+ concurrency: 5
231
232
 
232
233
  # Social Links
233
234
  # Usage: `Key: permalink || icon || color`
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.4.22",
3
+ "version": "0.4.24",
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@10.4.1",
9
+ "packageManager": "pnpm@10.6.3",
10
10
  "scripts": {
11
11
  "test": "tsc --build --verbose",
12
12
  "build": "node ./toolbox/compiler.mjs"
@@ -16,23 +16,24 @@
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.13.4",
19
+ "@types/node": "^22.13.10",
20
20
  "@types/quicklink": "^2.3.4",
21
- "@typescript-eslint/eslint-plugin": "^8.24.1",
22
- "@typescript-eslint/parser": "^8.24.1",
23
- "eslint": "^9.20.1",
21
+ "@typescript-eslint/eslint-plugin": "^8.26.1",
22
+ "@typescript-eslint/parser": "^8.26.1",
23
+ "eslint": "^9.22.0",
24
24
  "eslint-config-standard": "~17",
25
- "eslint-plugin-vue": "^9.32.0",
25
+ "eslint-plugin-vue": "^10.0.0",
26
26
  "glob": "^11.0.1",
27
- "typescript": "^5.7.3"
27
+ "typescript": "^5.8.2"
28
28
  },
29
29
  "dependencies": {
30
- "@algolia/client-search": "^5.20.3",
31
- "@waline/client": "^3.5.2",
32
- "algoliasearch": "5.20.3",
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",
33
34
  "dompurify": "^3.2.4",
34
- "es-toolkit": "^1.32.0",
35
- "esbuild": "^0.25.0",
35
+ "es-toolkit": "^1.33.0",
36
+ "esbuild": "^0.25.1",
36
37
  "hexo": "^7.3.0",
37
38
  "hexo-algoliasearch": "^2.0.1",
38
39
  "hexo-feed": "^1.1.2",
@@ -40,7 +41,7 @@
40
41
  "hexo-pagination": "^4.0.0",
41
42
  "hexo-renderer-pug": "^3.0.0",
42
43
  "hexo-util": "^3.3.0",
43
- "instantsearch.js": "^4.77.3",
44
+ "instantsearch.js": "^4.78.0",
44
45
  "js-yaml": "^4.1.0",
45
46
  "katex": "^0.16.21",
46
47
  "mouse-firework": "^0.1.0",
@@ -48,7 +49,7 @@
48
49
  "theme-shokax-anime": "^0.0.8",
49
50
  "theme-shokax-pjax": "^0.0.3",
50
51
  "twikoo": "^1.6.41",
51
- "unlazy": "^0.12.1"
52
+ "unlazy": "^0.12.3"
52
53
  },
53
54
  "engines": {
54
55
  "node": ">=18.0.0"
@@ -22,8 +22,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  ));
23
23
  var import_node_crypto = require("node:crypto");
24
24
  var import_promises = __toESM(require("node:fs/promises"));
25
+ const config = hexo.theme.config.summary;
25
26
  async function getSummaryByAPI(content) {
26
- const config = hexo.theme.config.summary;
27
27
  const apiKey = config.apiKey;
28
28
  const apiUrl = config.apiUrl;
29
29
  const model = config.model;
@@ -37,7 +37,13 @@ async function getSummaryByAPI(content) {
37
37
  },
38
38
  body: JSON.stringify({
39
39
  model,
40
- messages: [{ role: "user", content: `${initalPrompt} ${content}` }],
40
+ messages: [{
41
+ role: "system",
42
+ content: `${initalPrompt}`
43
+ }, {
44
+ role: "user",
45
+ content: `${content}`
46
+ }],
41
47
  temperature
42
48
  })
43
49
  });
@@ -102,14 +108,24 @@ hexo.extend.generator.register("summary_ai", async function(locals) {
102
108
  }
103
109
  const db = new SummaryDatabase();
104
110
  await db.readDB();
105
- for (const post of posts.toArray()) {
111
+ const postArray = posts.toArray();
112
+ const pLimit = require("@common.js/p-limit").default;
113
+ const concurrencyLimit = pLimit(config?.concurrency || 5);
114
+ const processingPromises = postArray.map((post) => concurrencyLimit(async () => {
106
115
  const content = post.content;
107
116
  const path = post.path;
108
117
  const published = post.published;
109
118
  if (content && path && published && content.length > 0) {
110
- const summary = await db.getPostSummary(path, content);
111
- post.summary = summary;
119
+ try {
120
+ const summary = await db.getPostSummary(path, content);
121
+ post.summary = summary;
122
+ } catch (error) {
123
+ hexo.log.error(`[ShokaX Summary AI] \u5904\u7406\u6587\u7AE0 ${path} \u65F6\u51FA\u9519:`, error.message);
124
+ post.summary = `${error.message}`;
125
+ }
112
126
  }
113
- }
127
+ }));
128
+ await Promise.all(processingPromises);
114
129
  await db.writeDB();
130
+ hexo.log.info(`[ShokaX Summary AI] \u6240\u6709\u6587\u7AE0\u6458\u8981\u5904\u7406\u5B8C\u6210\uFF0C\u5DF2\u4FDD\u5B58\u5230\u6570\u636E\u5E93`);
115
131
  });
@@ -5,7 +5,7 @@
5
5
  width: $sidebar-desktop;
6
6
  margin: 0;
7
7
  padding: 0;
8
- position: fixed;
8
+ position: sticky;
9
9
  bottom: .125rem;
10
10
 
11
11
  li {
@@ -1,5 +1,6 @@
1
1
  #sidebar {
2
2
  position: static;
3
+ overflow: scroll;
3
4
  width: $sidebar-desktop;
4
5
  top: 0;
5
6
  bottom: 0;