Skip to content

Commit a80efd9

Browse files
authored
fix(recentUpdates): path parsing error (#380)
1 parent 5a3b558 commit a80efd9

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

packages/vitepress-plugin-index/src/vitepress/recentUpdates.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export function createRecentUpdatesLoader(options?: RecentUpdatesContentLoaderOp
168168

169169
return {
170170
async load() {
171-
const files = await glob(join(opts.dir, '**/*.md'), {
171+
const files = await glob(join(opts.dir, '**/*.md').replaceAll('\\', '/'), {
172172
absolute: true,
173173
cwd: cwd(),
174174
ignore: opts.ignores,
@@ -215,24 +215,27 @@ export function createRecentUpdatesLoader(options?: RecentUpdatesContentLoaderOp
215215
}
216216
}
217217

218-
let url = relative(cwd(), file)
219-
if (url.endsWith('.md')) {
220-
if (url.endsWith('index.md')) {
221-
url = url.replace(/index\.md$/, 'index.html')
218+
let url = ''
219+
const fileRelativePath = relative(cwd(), file)
220+
221+
if (fileRelativePath.endsWith('.md')) {
222+
if (fileRelativePath.endsWith('index.md')) {
223+
url = fileRelativePath.replace(/index\.md$/, 'index.html')
222224
}
223225
else {
224-
url = url.replace(/\.md$/, '.html')
226+
url = fileRelativePath.replace(/\.md$/, '.html')
225227
}
226228
}
227229

228230
for (const rewrite of opts.rewrites) {
229231
url = url.replace(rewrite.from, rewrite.to)
230232
}
233+
url = `/${url}`
231234

232235
const entry = {
233236
title,
234237
lastUpdated: lastUpdatedTimestamp,
235-
filePath: relative(cwd(), file),
238+
filePath: fileRelativePath,
236239
category: '',
237240
url,
238241
}

0 commit comments

Comments
 (0)