diff --git a/packages/docusaurus/src/server/plugins/index.ts b/packages/docusaurus/src/server/plugins/index.ts index 9ae40e38ecbb0..8dd25771e027c 100644 --- a/packages/docusaurus/src/server/plugins/index.ts +++ b/packages/docusaurus/src/server/plugins/index.ts @@ -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; } @@ -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(