From 64ff853cc32a8f9a9dbd5b5cc76238ba78d1b700 Mon Sep 17 00:00:00 2001 From: Shigma <1700011071@pku.edu.cn> Date: Sun, 24 Feb 2019 14:42:43 +0800 Subject: [PATCH] refine markdown api --- packages/@vuepress/markdown-loader/index.js | 2 ++ packages/@vuepress/markdown/lib/link.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) 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' } }) }