diff --git a/docs/.vuepress/markdown/createSidebar.js b/docs/.vuepress/markdown/createSidebar.js index 10c5654f7ef759a3fef3f9bea082c5508f18c0a5..d02dffba5544332ee3d0b1eedcea3bd5945c8b0c 100644 --- a/docs/.vuepress/markdown/createSidebar.js +++ b/docs/.vuepress/markdown/createSidebar.js @@ -46,11 +46,15 @@ function parseBar(tab, file, options) { } } - link = path.join('/', link.replace(/\.md\b/, '') - .replace(/\bREADME\b/, '') - .replace(/\/index/, '/') - .replace(/\?id=/, '#')) - .replace(/\\/g, '/') + link = path.join( + '/', + link + .replace(/(\bREADME\.md\b)|(\bREADME(?!\.))/i, 'index.html') // README.md | README | readme.md | readme -> index.html + .replace(/(\bindex\.md\b)|(index(?!\.))/, 'index.html') // /index -> /index.html + .replace(/\.md\b/, '.html') // *.md -> *.html + .replace(/\?id=/, '#') // ?id= -> # + .replace(/\\/g, '/') // \ -> / + ) links.push(link) } diff --git a/docs/.vuepress/markdown/normallizeLink.js b/docs/.vuepress/markdown/normallizeLink.js index 4511bf59d2a3de56a54501c0adc22ab9c20e5bdf..2d97c9c3f5c5ddc7d92cddf76f2f51c3a2dea5a7 100644 --- a/docs/.vuepress/markdown/normallizeLink.js +++ b/docs/.vuepress/markdown/normallizeLink.js @@ -16,17 +16,17 @@ function normalizeLink(url) { } module.exports = function (md) { - md.normalizeLink = (function (oldNormalizeLink) { - return function (url) { - url = isExternal(url) - ? url - : normalizeLink(url) - .replace(/\.md\b/, '.html') - .replace(/\bREADME\b/, 'index.html') - .replace(/\/index(?!\.)/, 'index.html') - .replace(/\?id=/, '#') - .replace(/\\/g, '/') - return oldNormalizeLink.bind(this)(url) - } - })(md.normalizeLink) + md.normalizeLink = (function (oldNormalizeLink) { + return function (url) { + url = isExternal(url) + ? url + : normalizeLink(url) + .replace(/(\bREADME\.md\b)|(\bREADME(?!\.))/i, 'index.html') // README.md | README | readme.md | readme -> index.html + .replace(/(\bindex\.md\b)|(index(?!\.))/, 'index.html') // /index -> /index.html + .replace(/\.md\b/, '.html') // *.md -> *.html + .replace(/\?id=/, '#') // ?id= -> # + .replace(/\\/g, '/') // \ -> / + return oldNormalizeLink.bind(this)(url) + } + })(md.normalizeLink) } \ No newline at end of file