提交 3ff97adb 编写于 作者: D DCloud_LXH

feat: sidebar 支持相对路径

上级 7d7b668f
......@@ -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'
})
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册