Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/@vuepress/shared-utils/src/getPermalink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ interface PermalinkOption {
localePath: string;
}

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

// Remove leading slash
pattern = pattern.replace(/^\//, '')
pattern = removeLeadingSlash(pattern)

const link =
localePath +
Expand All @@ -53,7 +55,7 @@ export = function getPermalink ({
.replace(/:minutes/, String(minutes))
.replace(/:seconds/, String(seconds))
.replace(/:slug/, slug)
.replace(/:regular/, regularPath)
.replace(/:regular/, removeLeadingSlash(regularPath))

return ensureLeadingSlash(ensureEndingSlash(link))
}