Skip to content

Commit

Permalink
fix md-loader vue setup component
Browse files Browse the repository at this point in the history
  • Loading branch information
notbucai committed Nov 24, 2021
1 parent 52b9e30 commit 35bff16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions website/md-loader/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ config
.end()
.plugin('anchor').use(anchorPlugin, [
{
level: 2,
level: 1,
slugify: slugify,
// permalink: true,
// permalinkSymbol: '🔗',
permalink: true,
permalinkSymbol: '#',
permalinkBefore: true,
},
]).end()
Expand Down
5 changes: 3 additions & 2 deletions website/md-loader/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ function genInlineComponentText (template, script, id) {
`
// todo: 这里采用了硬编码有待改进
script = script.trim()

if (script) {
script = script
.replace(/export\s+default/, 'const democomponentExport =')
Expand All @@ -81,7 +80,9 @@ function genInlineComponentText (template, script, id) {
s1 = s1.replace(/ as /g, ':')
return `const ${s1} = Vue`
})
.replace('createVNode:_createVNode', '')
.replace(/createVNode:_createVNode,?/, '')
.replace(/createTextVNode:_createTextVNode,?/, '')
.replace(/resolveComponent:_resolveComponent,?/, '')
.replace(/import (.*) from ['"](.*)['"]/g, (s, s1, s2) => `const ${s1} = require('${s2}')`)
.replace(/import ({.*}) from ['"]element-plus['"]/g, (s, s1) => `const ${s1} = require('element-plus')`)
} else {
Expand Down

0 comments on commit 35bff16

Please sign in to comment.