Skip to content

Commit

Permalink
feat($shared-utils): resolve regularPath when getting permalink (#1786)
Browse files Browse the repository at this point in the history
  • Loading branch information
billyyyyy3320 authored and ulivz committed Sep 22, 2019
1 parent f913fea commit c6ce6cf
Showing 1 changed file with 5 additions and 3 deletions.
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))
}

0 comments on commit c6ce6cf

Please sign in to comment.