Skip to content

Commit c6ce6cf

Browse files
billyyyyy3320ulivz
authored andcommitted
feat($shared-utils): resolve regularPath when getting permalink (#1786)
1 parent f913fea commit c6ce6cf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/@vuepress/shared-utils/src/getPermalink.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ interface PermalinkOption {
99
localePath: string;
1010
}
1111

12+
function removeLeadingSlash (path: string) {
13+
return path.replace(/^\//, '')
14+
}
1215
// e.g.
1316
// filename: docs/_posts/evan you.md
1417
// content: # yyx 990803
@@ -39,8 +42,7 @@ export = function getPermalink ({
3942
const month = iMonth < 10 ? `0${iMonth}` : iMonth
4043
const day = iDay < 10 ? `0${iDay}` : iDay
4144

42-
// Remove leading slash
43-
pattern = pattern.replace(/^\//, '')
45+
pattern = removeLeadingSlash(pattern)
4446

4547
const link =
4648
localePath +
@@ -53,7 +55,7 @@ export = function getPermalink ({
5355
.replace(/:minutes/, String(minutes))
5456
.replace(/:seconds/, String(seconds))
5557
.replace(/:slug/, slug)
56-
.replace(/:regular/, regularPath)
58+
.replace(/:regular/, removeLeadingSlash(regularPath))
5759

5860
return ensureLeadingSlash(ensureEndingSlash(link))
5961
}

0 commit comments

Comments
 (0)