chore(v2): normalize url properly (#1105)

* refactor(v2): normalize url properly

* nits
This commit is contained in:
Endilie Yacop Sucipto 2018-11-12 00:25:13 +08:00 committed by GitHub
parent 34dcc0c22e
commit b84754dde8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 128 additions and 11 deletions

View file

@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
const {normalizeUrl} = require('./utils');
async function genRoutesConfig({
siteConfig = {},
docsMetadatas = {},
@ -33,7 +35,7 @@ async function genRoutesConfig({
}`;
}
const rootDocsUrl = baseUrl + docsUrl;
const rootDocsUrl = normalizeUrl([baseUrl, docsUrl]);
const docsRoutes = `
{
path: '${rootDocsUrl}',
@ -133,8 +135,9 @@ async function genRoutesConfig({
`import BlogPage from '@theme/BlogPage';\n` +
`import Pages from '@theme/Pages';\n` +
`import NotFound from '@theme/NotFound';\n` +
`const routes = [${docsRoutes},
`const routes = [
${pagesMetadatas.map(genPagesRoute).join(',')},
${docsRoutes},
${blogMetadatas.map(genBlogRoute).join(',')},
${notFoundRoute}\n];\n` +
`export default routes;\n`