Skip to content

Commit

Permalink
fix: baseUrl passed to sortConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
semoal committed Oct 29, 2021
1 parent d4114c7 commit e0db05a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/docusaurus/src/server/plugins/index.ts
Expand Up @@ -26,15 +26,18 @@ import {chain} from 'lodash';
import {localizePluginTranslationFile} from '../translations/translations';
import applyRouteTrailingSlash from './applyRouteTrailingSlash';

export function sortConfig(routeConfigs: RouteConfig[]): void {
export function sortConfig(
routeConfigs: RouteConfig[],
baseUrl: string = '/',
): void {
// Sort the route config. This ensures that route with nested
// routes is always placed last.
routeConfigs.sort((a, b) => {
// Root route should get placed last.
if (a.path === '/' && b.path !== '/') {
if (a.path === baseUrl && b.path !== baseUrl) {
return 1;
}
if (a.path !== '/' && b.path === '/') {
if (a.path !== baseUrl && b.path === baseUrl) {
return -1;
}

Expand Down Expand Up @@ -221,7 +224,7 @@ export async function loadPlugins({

// Sort the route config. This ensures that route with nested
// routes are always placed last.
sortConfig(pluginsRouteConfigs);
sortConfig(pluginsRouteConfigs, context.siteConfig.baseUrl);

// Apply each plugin one after the other to translate the theme config
function translateThemeConfig(
Expand Down

0 comments on commit e0db05a

Please sign in to comment.