fix(v2): fix navbar items issue on Windows? (#3922)

* attempt to fix navbar items issue on Windows?

* attempt to fix alias ordering issue on Windows
This commit is contained in:
Sébastien Lorber 2020-12-14 20:52:20 +01:00 committed by GitHub
parent b79568fff9
commit 6703f8420e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,7 @@ import fs from 'fs-extra';
import path from 'path';
import {fileToPath, posixPath, normalizeUrl} from '@docusaurus/utils';
import {ThemeAlias} from '@docusaurus/types';
import {sortBy} from 'lodash';
export default function themeAlias(
themePath: string,
@ -23,9 +24,15 @@ export default function themeAlias(
cwd: themePath,
});
// See https://github.com/facebook/docusaurus/pull/3922
// ensure @theme/NavbarItem alias is created after @theme/NavbarItem/LocaleDropdown
const sortedThemeComponentFiles = sortBy(themeComponentFiles, (file) =>
file.endsWith('/index.js'),
);
const aliases: ThemeAlias = {};
themeComponentFiles.forEach((relativeSource) => {
sortedThemeComponentFiles.forEach((relativeSource) => {
const filePath = path.join(themePath, relativeSource);
const fileName = fileToPath(relativeSource);