Skip to content

Commit

Permalink
fix(v2): include base url in 404 route
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 committed Jan 21, 2020
1 parent f2137bb commit 613b543
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/docusaurus/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export async function load(siteDir: string): Promise<Props> {
routesChunkNames,
routesConfig,
routesPaths,
} = await loadRoutes(pluginsRouteConfigs);
} = await loadRoutes(pluginsRouteConfigs, baseUrl);

const genRegistry = generate(
generatedFilesDir,
Expand Down
9 changes: 6 additions & 3 deletions packages/docusaurus/src/server/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import {genChunkName} from '@docusaurus/utils';
import {genChunkName, normalizeUrl} from '@docusaurus/utils';
import _ from 'lodash';
import {stringify} from 'querystring';
import {
Expand Down Expand Up @@ -38,15 +38,18 @@ function getModulePath(target: Module): string {
return `${target.path}${queryStr}`;
}

export async function loadRoutes(pluginsRouteConfigs: RouteConfig[]) {
export async function loadRoutes(
pluginsRouteConfigs: RouteConfig[],
baseUrl: string,
) {
const routesImports = [
`import React from 'react';`,
`import ComponentCreator from '@docusaurus/ComponentCreator';`,
];
const registry: {
[chunkName: string]: ChunkRegistry;
} = {};
const routesPaths: string[] = ['404.html'];
const routesPaths: string[] = [normalizeUrl([baseUrl, '404.html'])];
const routesChunkNames: {
[routePath: string]: ChunkNames;
} = {};
Expand Down

0 comments on commit 613b543

Please sign in to comment.