From 3ff97adbcd156d42e41f1cd5bfb4a579cd95e7dd Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Wed, 13 Jul 2022 12:03:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20sidebar=20=E6=94=AF=E6=8C=81=E7=9B=B8?= =?UTF-8?q?=E5=AF=B9=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vuepress/markdown/createSidebar.js | 11 +++++++++-- docs/tutorial/_sidebar.md | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/.vuepress/markdown/createSidebar.js b/docs/.vuepress/markdown/createSidebar.js index a572ae890..d414f44c4 100644 --- a/docs/.vuepress/markdown/createSidebar.js +++ b/docs/.vuepress/markdown/createSidebar.js @@ -7,7 +7,7 @@ const createSiteMap = require('./createSiteMap'); const links = [] -function parseBar(file, options) { +function parseBar(tab, file, options) { const textName = options.text || 'text' const linkName = options.link || 'link' const contents = [] @@ -39,6 +39,13 @@ function parseBar(file, options) { }) if (link && !isExternal(link)) { + if (!link.startsWith('/')) { + const linkFirstItem = link.split('/')[0] + if (tab.indexOf(linkFirstItem) === -1) { + link = `${tab}${link}` + } + } + link = path.join('/', link.replace(/\.md\b/, '') .replace(/\bREADME\b/, '') .replace(/\/index/, '/') @@ -64,7 +71,7 @@ module.exports = function (tabs = []) { const sidebar = {} tabs.forEach(tab => { - sidebar[tab] = parseBar(path.join(__dirname, '../../', tab, '_sidebar.md'), { + sidebar[tab] = parseBar(tab, path.join(__dirname, '../../', tab, '_sidebar.md'), { text: 'title', link: 'path' }) diff --git a/docs/tutorial/_sidebar.md b/docs/tutorial/_sidebar.md index a8b3f6747..ecea99119 100644 --- a/docs/tutorial/_sidebar.md +++ b/docs/tutorial/_sidebar.md @@ -112,7 +112,7 @@ * [小程序插件](/tutorial/mp-weixin-plugin.md) * [一键上传微信平台](/tutorial/build/publish-mp-weixin-cli.md) * 运行和调试 - * [概述](tutorial/run-and-debug.md) + * [概述](run-and-debug.md) * [web平台:内置浏览器运行调试](tutorial/debug/debug-web-via-hx.md) * [web平台:debug](tutorial/debug/debug-web-via-chrome.md) * [App平台:真机运行常见问题](tutorial/run/PhoneDebugging.md) -- GitLab