Skip to content

Commit

Permalink
feat: refine markdown api (#1337)
Browse files Browse the repository at this point in the history
1. support env.loader
2. refine link behavior, every token is an instance of `Token`. its prototype should not be removed
  • Loading branch information
shigma authored and ulivz committed Feb 24, 2019
1 parent 98086c7 commit b79768c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/@vuepress/markdown-loader/index.js
Expand Up @@ -21,6 +21,7 @@ module.exports = function (src) {
const isProd = process.env.NODE_ENV === 'production'
const isServer = this.target === 'node'
const options = getOptions(this)
const loader = Object.create(this)
const { sourceDir } = options
let { markdown } = options
if (!markdown) {
Expand Down Expand Up @@ -71,6 +72,7 @@ module.exports = function (src) {
data: { hoistedTags, links },
dataBlockString
} = markdown.render(content, {
loader,
frontmatter: frontmatter.data,
relPath: path.relative(sourceDir, file)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/@vuepress/markdown/lib/link.js
Expand Up @@ -66,8 +66,8 @@ module.exports = (md, externalAttrs) => {
const routerLinks = md.$data.routerLinks || (md.$data.routerLinks = [])
routerLinks.push(to)

return Object.assign({}, token, {
tag: 'router-link'
return Object.create(token, {
tag: { value: 'router-link' }
})
}

Expand Down

0 comments on commit b79768c

Please sign in to comment.