diff --git a/packages/@vuepress/markdown-loader/index.js b/packages/@vuepress/markdown-loader/index.js index 1598b4caa1..e4e7750429 100644 --- a/packages/@vuepress/markdown-loader/index.js +++ b/packages/@vuepress/markdown-loader/index.js @@ -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) { @@ -71,6 +72,7 @@ module.exports = function (src) { data: { hoistedTags, links }, dataBlockString } = markdown.render(content, { + loader, frontmatter: frontmatter.data, relPath: path.relative(sourceDir, file) }) diff --git a/packages/@vuepress/markdown/lib/link.js b/packages/@vuepress/markdown/lib/link.js index 900ca3603e..6e8d2a0445 100644 --- a/packages/@vuepress/markdown/lib/link.js +++ b/packages/@vuepress/markdown/lib/link.js @@ -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' } }) }