@sugarat/theme 0.1.20 → 0.1.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarat/theme",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -50,8 +50,9 @@
50
50
  "vue": "^3.2.45"
51
51
  },
52
52
  "scripts": {
53
- "dev": "vitepress dev demo",
54
- "dev:lib": "npm run build:node && vitepress dev demo",
53
+ "dev": "npm run build:node && npm run dev:docs",
54
+ "dev:docs": "vitepress dev demo",
55
+ "dev:node": "npx tsup src/node.ts --dts --out-dir=./ --watch",
55
56
  "build": "npm run build:node && npm run build:docs",
56
57
  "build:docs": "vitepress build demo",
57
58
  "build:node": "npx tsup src/node.ts --dts --out-dir=./",
@@ -83,10 +83,15 @@ export function useCurrentArticle() {
83
83
  const docs = computed(() => blogConfig.config?.blog?.pagesData)
84
84
  const currentArticle = computed(() => {
85
85
  const currentPath = route.path.replace(/.html$/, '')
86
- return docs.value?.find((v) =>
87
- // 兼容中文路径
88
- [currentPath, decodeURIComponent(currentPath)].includes(withBase(v.route))
89
- )
86
+ // 兼容中文路径
87
+ const okPaths = [currentPath, decodeURIComponent(currentPath)]
88
+ // 兼容 /(index.md)
89
+ if (currentPath.endsWith('/')) {
90
+ okPaths.push(
91
+ ...[`${currentPath}index`, `${decodeURIComponent(currentPath)}index`]
92
+ )
93
+ }
94
+ return docs.value?.find((v) => okPaths.includes(withBase(v.route)))
90
95
  })
91
96
 
92
97
  return currentArticle