Skip to content

Commit cc193d5

Browse files
shigmaulivz
authored andcommitted
refactor($markdown): use relativePath instead of relPath (#1485)
1 parent d7b8daf commit cc193d5

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

packages/@vuepress/core/lib/node/Page.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ module.exports = class Page {
124124
if (excerpt) {
125125
const { html } = markdown.render(excerpt, {
126126
frontmatter: this.frontmatter,
127-
relPath: this.relativePath
127+
relativePath: this.relativePath
128128
})
129129
this.excerpt = html
130130
}

packages/@vuepress/markdown-loader/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module.exports = function (src) {
6565
} = markdown.render(content, {
6666
loader,
6767
frontmatter: data,
68-
relPath: path.relative(sourceDir, file).replace(/\\/g, '/')
68+
relativePath: path.relative(sourceDir, file).replace(/\\/g, '/')
6969
})
7070

7171
// check if relative links are valid

packages/@vuepress/markdown/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ module.exports = (markdown = {}) => {
123123
const parse = md.parse
124124
const cache = new LRUCache({ max: 1000 })
125125
md.parse = (src, env) => {
126-
const key = hash(src + env.relPath)
126+
const key = hash(src + env.relativePath)
127127
const cached = cache.get(key)
128128
if (cached) {
129129
return cached

packages/@vuepress/markdown/lib/link.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = (md, externalAttrs) => {
1111
let hasOpenExternalLink = false
1212

1313
md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
14-
const { relPath } = env
14+
const { relativePath } = env
1515
const token = tokens[idx]
1616
const hrefIndex = token.attrIndex('href')
1717
if (hrefIndex >= 0) {
@@ -28,13 +28,13 @@ module.exports = (md, externalAttrs) => {
2828
}
2929
} else if (isSourceLink) {
3030
hasOpenRouterLink = true
31-
tokens[idx] = toRouterLink(token, link, relPath)
31+
tokens[idx] = toRouterLink(token, link, relativePath)
3232
}
3333
}
3434
return self.renderToken(tokens, idx, options)
3535
}
3636

37-
function toRouterLink (token, link, relPath) {
37+
function toRouterLink (token, link, relativePath) {
3838
link[0] = 'to'
3939
let to = link[1]
4040

@@ -44,8 +44,8 @@ module.exports = (md, externalAttrs) => {
4444

4545
// relative path usage.
4646
if (!to.startsWith('/')) {
47-
to = relPath
48-
? url.resolve('/' + relPath, to)
47+
to = relativePath
48+
? url.resolve('/' + relativePath, to)
4949
: ensureBeginningDotSlash(to)
5050
}
5151

0 commit comments

Comments
 (0)