@sugarat/theme 0.5.8 → 0.5.10
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/node.js +10 -7
- package/node.mjs +12 -9
- package/package.json +8 -7
- package/src/components/BlogList.vue +5 -4
- package/src/utils/node/index.ts +2 -3
- package/src/utils/node/theme.ts +1 -1
- package/src/utils/node/vitePlugins.ts +10 -8
package/node.js
CHANGED
|
@@ -41,7 +41,7 @@ module.exports = __toCommonJS(node_exports);
|
|
|
41
41
|
// src/utils/node/mdPlugins.ts
|
|
42
42
|
var import_module = require("module");
|
|
43
43
|
|
|
44
|
-
// ../../node_modules/.pnpm/vitepress-plugin-tabs@0.2.0_vitepress@
|
|
44
|
+
// ../../node_modules/.pnpm/vitepress-plugin-tabs@0.2.0_vitepress@2.0.0-alpha.15_@types+node@24.5.2_async-validator_99dc32d207803fc3e59dad002dbf4f6a/node_modules/vitepress-plugin-tabs/dist/index.js
|
|
45
45
|
var tabsMarker = "=tabs";
|
|
46
46
|
var tabsMarkerLen = tabsMarker.length;
|
|
47
47
|
var ruleBlockTabs = (state, startLine, endLine, silent) => {
|
|
@@ -235,7 +235,7 @@ function getFirstImagURLFromMD(content, route) {
|
|
|
235
235
|
const paths = (0, import_theme_shared.joinPath)("/", route).split("/");
|
|
236
236
|
paths.splice(paths.length - 1, 1);
|
|
237
237
|
const relativePath = url.startsWith("/") ? url : import_node_path.default.join(paths.join("/") || "", url);
|
|
238
|
-
return (0, import_theme_shared.joinPath)("/", relativePath);
|
|
238
|
+
return (0, import_theme_shared.joinPath)("/", (0, import_theme_shared.normalizePath)(relativePath));
|
|
239
239
|
}
|
|
240
240
|
function debounce(func, delay = 1e3) {
|
|
241
241
|
let timeoutId;
|
|
@@ -549,12 +549,12 @@ function themeReloadPlugin() {
|
|
|
549
549
|
function getVitePlugins(cfg = {}) {
|
|
550
550
|
const plugins = [];
|
|
551
551
|
plugins.push(cacheAllGitTimestampsPlugin());
|
|
552
|
-
plugins.push(coverImgTransform());
|
|
553
552
|
if (cfg.themeColor) {
|
|
554
553
|
plugins.push(setThemeScript(cfg.themeColor));
|
|
555
554
|
}
|
|
556
555
|
plugins.push(themeReloadPlugin());
|
|
557
556
|
plugins.push(providePageData(cfg));
|
|
557
|
+
plugins.push(coverImgTransform());
|
|
558
558
|
if (cfg && cfg.search !== false) {
|
|
559
559
|
const ops = cfg.search instanceof Object ? cfg.search : {};
|
|
560
560
|
plugins.push(
|
|
@@ -638,13 +638,16 @@ function coverImgTransform() {
|
|
|
638
638
|
const value = v.meta[k];
|
|
639
639
|
if (value && typeof value === "string" && value.startsWith("/")) {
|
|
640
640
|
const absolutePath = `${vitepressConfig.srcDir}${value}`;
|
|
641
|
-
if (
|
|
642
|
-
Object.assign(v.meta, {
|
|
643
|
-
|
|
641
|
+
if (relativePathMap[absolutePath]) {
|
|
642
|
+
Object.assign(v.meta, {
|
|
643
|
+
[k]: relativeMetaMap[absolutePath][k]
|
|
644
|
+
});
|
|
644
645
|
}
|
|
645
646
|
relativePathMap[value] = absolutePath;
|
|
646
647
|
relativePathMap[absolutePath] = value;
|
|
647
|
-
relativeMeta.
|
|
648
|
+
if (!relativeMeta.includes(v.meta)) {
|
|
649
|
+
relativeMeta.push(v.meta);
|
|
650
|
+
}
|
|
648
651
|
relativeMetaMap[absolutePath] = v.meta;
|
|
649
652
|
}
|
|
650
653
|
});
|
package/node.mjs
CHANGED
|
@@ -9,7 +9,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
9
9
|
// src/utils/node/mdPlugins.ts
|
|
10
10
|
import { createRequire } from "module";
|
|
11
11
|
|
|
12
|
-
// ../../node_modules/.pnpm/vitepress-plugin-tabs@0.2.0_vitepress@
|
|
12
|
+
// ../../node_modules/.pnpm/vitepress-plugin-tabs@0.2.0_vitepress@2.0.0-alpha.15_@types+node@24.5.2_async-validator_99dc32d207803fc3e59dad002dbf4f6a/node_modules/vitepress-plugin-tabs/dist/index.js
|
|
13
13
|
var tabsMarker = "=tabs";
|
|
14
14
|
var tabsMarkerLen = tabsMarker.length;
|
|
15
15
|
var ruleBlockTabs = (state, startLine, endLine, silent) => {
|
|
@@ -179,7 +179,7 @@ import { groupIconMdPlugin } from "vitepress-plugin-group-icons";
|
|
|
179
179
|
|
|
180
180
|
// src/utils/node/index.ts
|
|
181
181
|
import path from "node:path";
|
|
182
|
-
import { joinPath } from "@sugarat/theme-shared";
|
|
182
|
+
import { joinPath, normalizePath } from "@sugarat/theme-shared";
|
|
183
183
|
function aliasObjectToArray(obj) {
|
|
184
184
|
return Object.entries(obj).map(([find, replacement]) => ({
|
|
185
185
|
find,
|
|
@@ -203,7 +203,7 @@ function getFirstImagURLFromMD(content, route) {
|
|
|
203
203
|
const paths = joinPath("/", route).split("/");
|
|
204
204
|
paths.splice(paths.length - 1, 1);
|
|
205
205
|
const relativePath = url.startsWith("/") ? url : path.join(paths.join("/") || "", url);
|
|
206
|
-
return joinPath("/", relativePath);
|
|
206
|
+
return joinPath("/", normalizePath(relativePath));
|
|
207
207
|
}
|
|
208
208
|
function debounce(func, delay = 1e3) {
|
|
209
209
|
let timeoutId;
|
|
@@ -301,7 +301,7 @@ function patchOptimizeDeps(config) {
|
|
|
301
301
|
|
|
302
302
|
// src/utils/node/theme.ts
|
|
303
303
|
import fs from "node:fs";
|
|
304
|
-
import { getDefaultTitle, getFileLastModifyTime, getTextSummary, getVitePressPages, grayMatter, normalizePath, renderDynamicMarkdown } from "@sugarat/theme-shared";
|
|
304
|
+
import { getDefaultTitle, getFileLastModifyTime, getTextSummary, getVitePressPages, grayMatter, normalizePath as normalizePath2, renderDynamicMarkdown } from "@sugarat/theme-shared";
|
|
305
305
|
|
|
306
306
|
// src/utils/client/index.ts
|
|
307
307
|
function formatDate(d, fmt = "yyyy-MM-dd hh:mm:ss") {
|
|
@@ -517,12 +517,12 @@ function themeReloadPlugin() {
|
|
|
517
517
|
function getVitePlugins(cfg = {}) {
|
|
518
518
|
const plugins = [];
|
|
519
519
|
plugins.push(cacheAllGitTimestampsPlugin());
|
|
520
|
-
plugins.push(coverImgTransform());
|
|
521
520
|
if (cfg.themeColor) {
|
|
522
521
|
plugins.push(setThemeScript(cfg.themeColor));
|
|
523
522
|
}
|
|
524
523
|
plugins.push(themeReloadPlugin());
|
|
525
524
|
plugins.push(providePageData(cfg));
|
|
525
|
+
plugins.push(coverImgTransform());
|
|
526
526
|
if (cfg && cfg.search !== false) {
|
|
527
527
|
const ops = cfg.search instanceof Object ? cfg.search : {};
|
|
528
528
|
plugins.push(
|
|
@@ -606,13 +606,16 @@ function coverImgTransform() {
|
|
|
606
606
|
const value = v.meta[k];
|
|
607
607
|
if (value && typeof value === "string" && value.startsWith("/")) {
|
|
608
608
|
const absolutePath = `${vitepressConfig.srcDir}${value}`;
|
|
609
|
-
if (
|
|
610
|
-
Object.assign(v.meta, {
|
|
611
|
-
|
|
609
|
+
if (relativePathMap[absolutePath]) {
|
|
610
|
+
Object.assign(v.meta, {
|
|
611
|
+
[k]: relativeMetaMap[absolutePath][k]
|
|
612
|
+
});
|
|
612
613
|
}
|
|
613
614
|
relativePathMap[value] = absolutePath;
|
|
614
615
|
relativePathMap[absolutePath] = value;
|
|
615
|
-
relativeMeta.
|
|
616
|
+
if (!relativeMeta.includes(v.meta)) {
|
|
617
|
+
relativeMeta.push(v.meta);
|
|
618
|
+
}
|
|
616
619
|
relativeMetaMap[absolutePath] = v.meta;
|
|
617
620
|
}
|
|
618
621
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sugarat/theme",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.10",
|
|
4
4
|
"description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
|
|
5
5
|
"author": "sugar",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,22 +53,23 @@
|
|
|
53
53
|
"vitepress-plugin-group-icons": "1.2.4",
|
|
54
54
|
"vitepress-plugin-mermaid": "2.0.13",
|
|
55
55
|
"vitepress-plugin-tabs": "0.2.0",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"vitepress-plugin-
|
|
59
|
-
"vitepress-plugin-
|
|
56
|
+
"@sugarat/theme-shared": "0.0.7",
|
|
57
|
+
"vitepress-plugin-announcement": "0.1.6",
|
|
58
|
+
"vitepress-plugin-rss": "0.4.0",
|
|
59
|
+
"vitepress-plugin-pagefind": "0.4.17"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@element-plus/icons-vue": "^2.3.1",
|
|
63
63
|
"artalk": "^2.8.5",
|
|
64
64
|
"element-plus": "^2.7.2",
|
|
65
|
+
"markdown-it-mathjax3": "^4.3.2",
|
|
65
66
|
"pagefind": "^1.3.0",
|
|
66
67
|
"sass": "^1.80.6",
|
|
67
68
|
"typescript": "^5.4.5",
|
|
68
69
|
"vite": "^5.4.9",
|
|
69
|
-
"vitepress": "
|
|
70
|
+
"vitepress": "2.0.0-alpha.15",
|
|
70
71
|
"vue": "^3.5.12",
|
|
71
|
-
"vitepress-plugin-51la": "0.1.
|
|
72
|
+
"vitepress-plugin-51la": "0.1.1"
|
|
72
73
|
},
|
|
73
74
|
"scripts": {
|
|
74
75
|
"dev": "npm run build:node && npm run dev:docs",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, watch } from 'vue'
|
|
2
|
+
import { computed, nextTick, watch } from 'vue'
|
|
3
3
|
import { ElPagination } from 'element-plus'
|
|
4
4
|
import { useData, useRoute, useRouter } from 'vitepress'
|
|
5
5
|
import {
|
|
@@ -70,7 +70,6 @@ function handleUpdatePageNum(current: number) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
const route = useRoute()
|
|
73
|
-
|
|
74
73
|
function refreshCurrentPage() {
|
|
75
74
|
if (typeof window === 'undefined')
|
|
76
75
|
return
|
|
@@ -78,7 +77,9 @@ function refreshCurrentPage() {
|
|
|
78
77
|
const searchParams = new URLSearchParams(search)
|
|
79
78
|
const pageNum = Number(searchParams.get(queryPageNumKey)) || 1
|
|
80
79
|
if (pageNum !== currentPage.value) {
|
|
81
|
-
|
|
80
|
+
nextTick(() => {
|
|
81
|
+
currentPage.value = pageNum
|
|
82
|
+
})
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
watch(route, () => {
|
|
@@ -86,7 +87,7 @@ watch(route, () => {
|
|
|
86
87
|
}, { immediate: true })
|
|
87
88
|
|
|
88
89
|
// 未覆盖的场景处理 左上回到首页
|
|
89
|
-
router.
|
|
90
|
+
router.onAfterRouteChange = () => {
|
|
90
91
|
refreshCurrentPage()
|
|
91
92
|
}
|
|
92
93
|
</script>
|
package/src/utils/node/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import { joinPath } from '@sugarat/theme-shared'
|
|
2
|
+
import { joinPath, normalizePath } from '@sugarat/theme-shared'
|
|
3
3
|
|
|
4
4
|
export function aliasObjectToArray(obj: Record<string, string>) {
|
|
5
5
|
return Object.entries(obj).map(([find, replacement]) => ({
|
|
@@ -34,8 +34,7 @@ export function getFirstImagURLFromMD(content: string, route: string) {
|
|
|
34
34
|
const paths = joinPath('/', route).split('/')
|
|
35
35
|
paths.splice(paths.length - 1, 1)
|
|
36
36
|
const relativePath = url.startsWith('/') ? url : path.join(paths.join('/') || '', url)
|
|
37
|
-
|
|
38
|
-
return joinPath('/', relativePath)
|
|
37
|
+
return joinPath('/', normalizePath(relativePath))
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
export function debounce(func: any, delay = 1000) {
|
package/src/utils/node/theme.ts
CHANGED
|
@@ -18,9 +18,6 @@ export function getVitePlugins(cfg: Partial<Theme.BlogConfig> = {}) {
|
|
|
18
18
|
// 缓存所有文章的 git 提交时间
|
|
19
19
|
plugins.push(cacheAllGitTimestampsPlugin())
|
|
20
20
|
|
|
21
|
-
// 处理 cover image 的路径(暂只支持自动识别的文章首图)
|
|
22
|
-
plugins.push(coverImgTransform())
|
|
23
|
-
|
|
24
21
|
// 处理自定义主题色
|
|
25
22
|
if (cfg.themeColor) {
|
|
26
23
|
plugins.push(setThemeScript(cfg.themeColor))
|
|
@@ -31,6 +28,8 @@ export function getVitePlugins(cfg: Partial<Theme.BlogConfig> = {}) {
|
|
|
31
28
|
// 主题 pageData生成
|
|
32
29
|
plugins.push(providePageData(cfg))
|
|
33
30
|
|
|
31
|
+
// 处理 cover image 的路径(暂只支持自动识别的文章首图)
|
|
32
|
+
plugins.push(coverImgTransform())
|
|
34
33
|
// 内置 pagefind
|
|
35
34
|
if (cfg && cfg.search !== false) {
|
|
36
35
|
const ops = cfg.search instanceof Object ? cfg.search : {}
|
|
@@ -165,15 +164,18 @@ export function coverImgTransform() {
|
|
|
165
164
|
if (value && typeof value === 'string' && value.startsWith('/')) {
|
|
166
165
|
const absolutePath = `${vitepressConfig.srcDir}${value}`
|
|
167
166
|
|
|
168
|
-
//
|
|
169
|
-
if (
|
|
170
|
-
Object.assign(v.meta, {
|
|
171
|
-
|
|
167
|
+
// 已经映射后的值
|
|
168
|
+
if (relativePathMap[absolutePath]) {
|
|
169
|
+
Object.assign(v.meta, {
|
|
170
|
+
[k]: relativeMetaMap[absolutePath][k]
|
|
171
|
+
})
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
relativePathMap[value] = absolutePath
|
|
175
175
|
relativePathMap[absolutePath] = value
|
|
176
|
-
relativeMeta.
|
|
176
|
+
if (!relativeMeta.includes(v.meta)) {
|
|
177
|
+
relativeMeta.push(v.meta)
|
|
178
|
+
}
|
|
177
179
|
relativeMetaMap[absolutePath] = v.meta
|
|
178
180
|
}
|
|
179
181
|
})
|