Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$markdown: use relativePath instead of relPath #1485

Merged
merged 3 commits into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/@vuepress/core/lib/node/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ module.exports = class Page {
if (excerpt) {
const { html } = markdown.render(excerpt, {
frontmatter: this.frontmatter,
relPath: this.relativePath
relativePath: this.relativePath
})
this.excerpt = html
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/markdown-loader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ module.exports = function (src) {
} = markdown.render(content, {
loader,
frontmatter: data,
relPath: path.relative(sourceDir, file).replace(/\\/g, '/')
relativePath: path.relative(sourceDir, file).replace(/\\/g, '/')
})

// check if relative links are valid
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ module.exports = (markdown = {}) => {
const parse = md.parse
const cache = new LRUCache({ max: 1000 })
md.parse = (src, env) => {
const key = hash(src + env.relPath)
const key = hash(src + env.relativePath)
const cached = cache.get(key)
if (cached) {
return cached
Expand Down
10 changes: 5 additions & 5 deletions packages/@vuepress/markdown/lib/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = (md, externalAttrs) => {
let hasOpenExternalLink = false

md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
const { relPath } = env
const { relativePath } = env
const token = tokens[idx]
const hrefIndex = token.attrIndex('href')
if (hrefIndex >= 0) {
Expand All @@ -28,13 +28,13 @@ module.exports = (md, externalAttrs) => {
}
} else if (isSourceLink) {
hasOpenRouterLink = true
tokens[idx] = toRouterLink(token, link, relPath)
tokens[idx] = toRouterLink(token, link, relativePath)
}
}
return self.renderToken(tokens, idx, options)
}

function toRouterLink (token, link, relPath) {
function toRouterLink (token, link, relativePath) {
link[0] = 'to'
let to = link[1]

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

// relative path usage.
if (!to.startsWith('/')) {
to = relPath
? url.resolve('/' + relPath, to)
to = relativePath
? url.resolve('/' + relativePath, to)
: ensureBeginningDotSlash(to)
}

Expand Down