Skip to content

Commit b79768c

Browse files
shigmaulivz
authored andcommitted
feat: refine markdown api (#1337)
1. support env.loader 2. refine link behavior, every token is an instance of `Token`. its prototype should not be removed
1 parent 98086c7 commit b79768c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module.exports = function (src) {
2121
const isProd = process.env.NODE_ENV === 'production'
2222
const isServer = this.target === 'node'
2323
const options = getOptions(this)
24+
const loader = Object.create(this)
2425
const { sourceDir } = options
2526
let { markdown } = options
2627
if (!markdown) {
@@ -71,6 +72,7 @@ module.exports = function (src) {
7172
data: { hoistedTags, links },
7273
dataBlockString
7374
} = markdown.render(content, {
75+
loader,
7476
frontmatter: frontmatter.data,
7577
relPath: path.relative(sourceDir, file)
7678
})

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ module.exports = (md, externalAttrs) => {
6666
const routerLinks = md.$data.routerLinks || (md.$data.routerLinks = [])
6767
routerLinks.push(to)
6868

69-
return Object.assign({}, token, {
70-
tag: 'router-link'
69+
return Object.create(token, {
70+
tag: { value: 'router-link' }
7171
})
7272
}
7373

0 commit comments

Comments
 (0)