From 351872d109d1bea3a3904224b193689f51742a77 Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Wed, 22 Jun 2022 15:14:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=5Fsidebar=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=8D=95=E7=8B=AC=E4=B9=A6=E5=86=99=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vuepress/markdown/createSidebar.js | 27 ++++++++++++++++++++++-- docs/uniCloud/_sidebar.md | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/docs/.vuepress/markdown/createSidebar.js b/docs/.vuepress/markdown/createSidebar.js index 749638a60..30629a94d 100644 --- a/docs/.vuepress/markdown/createSidebar.js +++ b/docs/.vuepress/markdown/createSidebar.js @@ -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 }) } }) diff --git a/docs/uniCloud/_sidebar.md b/docs/uniCloud/_sidebar.md index f1f0d7d85..7f96669a0 100644 --- a/docs/uniCloud/_sidebar.md +++ b/docs/uniCloud/_sidebar.md @@ -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) -- GitLab