提交 351872d1 编写于 作者: D DCloud_LXH

feat: _sidebar 支持单独书写配置

上级 2f0b2b75
......@@ -16,7 +16,29 @@ function parseBar(file, options) {
.parse(fs.readFileSync(file, { encoding: 'utf-8' }))
.forEach(token => {
if (token.type === 'inline') {
let [_, text, link] = token.content.match(/\[(.+?)\]\((.+?)\)/) || token.content.match(/(.+)/)
let text
let link
let config = {}
token.children.forEach(child => {
switch (child.type) {
case 'text':
text = child.content
break;
case 'link_open':
child.attrs.forEach(attr => {
if (attr[0] === 'href') link = attr[1]
})
break;
case 'code_inline':
try {
config = JSON.parse(child.content)
} catch (error) { }
break;
default:
break;
}
})
if (link && !isExternal(link)) {
link = path.join('/', link.replace(/\.md\b/, '')
......@@ -31,7 +53,8 @@ function parseBar(file, options) {
contents.push({
level: token.level,
[textName]: text,
[linkName]: link
[linkName]: link,
...config
})
}
})
......
......@@ -48,7 +48,7 @@
* [开发文档](uniCloud/redis.md)
* [日志输出](uniCloud/cf-logger.md)
* [客户端API](uniCloud/client-sdk.md)
* 重要开源库
* 重要开源库```{"collapsable": false}```
* [uni-config-center 配置中心](uniCloud/uni-config-center.md)
* [uni-starter](uniCloud/uni-starter.md)
* [uni-admin](uniCloud/admin.md)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册