mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
refactor(core): reorganize files (#7042)
* refactor(core): reorganize files * fix types
This commit is contained in:
parent
85a79fd9b9
commit
5fb09a2946
61 changed files with 1089 additions and 1028 deletions
|
@ -168,7 +168,7 @@ describe('simple site', () => {
|
|||
loadSiteOptions: {options: Partial<PluginOptions>} = {options: {}},
|
||||
) {
|
||||
const siteDir = path.join(fixtureDir, 'simple-site');
|
||||
const context = await loadContext(siteDir);
|
||||
const context = await loadContext({siteDir});
|
||||
const options = {
|
||||
id: DEFAULT_PLUGIN_ID,
|
||||
...DEFAULT_OPTIONS,
|
||||
|
@ -523,7 +523,8 @@ describe('versioned site', () => {
|
|||
},
|
||||
) {
|
||||
const siteDir = path.join(fixtureDir, 'versioned-site');
|
||||
const context = await loadContext(siteDir, {
|
||||
const context = await loadContext({
|
||||
siteDir,
|
||||
locale: loadSiteOptions.locale,
|
||||
});
|
||||
const options = {
|
||||
|
|
|
@ -115,7 +115,7 @@ Entries created:
|
|||
describe('sidebar', () => {
|
||||
it('site with wrong sidebar content', async () => {
|
||||
const siteDir = path.join(__dirname, '__fixtures__', 'simple-site');
|
||||
const context = await loadContext(siteDir);
|
||||
const context = await loadContext({siteDir});
|
||||
const sidebarPath = path.join(siteDir, 'wrong-sidebars.json');
|
||||
const plugin = await pluginContentDocs(
|
||||
context,
|
||||
|
@ -131,7 +131,7 @@ describe('sidebar', () => {
|
|||
|
||||
it('site with wrong sidebar file path', async () => {
|
||||
const siteDir = path.join(__dirname, '__fixtures__', 'site-with-doc-label');
|
||||
const context = await loadContext(siteDir);
|
||||
const context = await loadContext({siteDir});
|
||||
|
||||
await expect(async () => {
|
||||
const plugin = await pluginContentDocs(
|
||||
|
@ -155,7 +155,7 @@ describe('sidebar', () => {
|
|||
|
||||
it('site with undefined sidebar', async () => {
|
||||
const siteDir = path.join(__dirname, '__fixtures__', 'site-with-doc-label');
|
||||
const context = await loadContext(siteDir);
|
||||
const context = await loadContext({siteDir});
|
||||
const plugin = await pluginContentDocs(
|
||||
context,
|
||||
validateOptions({
|
||||
|
@ -173,7 +173,7 @@ describe('sidebar', () => {
|
|||
|
||||
it('site with disabled sidebar', async () => {
|
||||
const siteDir = path.join(__dirname, '__fixtures__', 'site-with-doc-label');
|
||||
const context = await loadContext(siteDir);
|
||||
const context = await loadContext({siteDir});
|
||||
const plugin = await pluginContentDocs(
|
||||
context,
|
||||
validateOptions({
|
||||
|
@ -194,7 +194,7 @@ describe('empty/no docs website', () => {
|
|||
const siteDir = path.join(__dirname, '__fixtures__', 'empty-site');
|
||||
|
||||
it('no files in docs folder', async () => {
|
||||
const context = await loadContext(siteDir);
|
||||
const context = await loadContext({siteDir});
|
||||
await fs.ensureDir(path.join(siteDir, 'docs'));
|
||||
const plugin = await pluginContentDocs(
|
||||
context,
|
||||
|
@ -208,7 +208,7 @@ describe('empty/no docs website', () => {
|
|||
});
|
||||
|
||||
it('docs folder does not exist', async () => {
|
||||
const context = await loadContext(siteDir);
|
||||
const context = await loadContext({siteDir});
|
||||
await expect(
|
||||
pluginContentDocs(
|
||||
context,
|
||||
|
@ -228,7 +228,7 @@ describe('empty/no docs website', () => {
|
|||
describe('simple website', () => {
|
||||
async function loadSite() {
|
||||
const siteDir = path.join(__dirname, '__fixtures__', 'simple-site');
|
||||
const context = await loadContext(siteDir);
|
||||
const context = await loadContext({siteDir});
|
||||
const sidebarPath = path.join(siteDir, 'sidebars.json');
|
||||
const plugin = await pluginContentDocs(
|
||||
context,
|
||||
|
@ -341,7 +341,7 @@ describe('simple website', () => {
|
|||
describe('versioned website', () => {
|
||||
async function loadSite() {
|
||||
const siteDir = path.join(__dirname, '__fixtures__', 'versioned-site');
|
||||
const context = await loadContext(siteDir);
|
||||
const context = await loadContext({siteDir});
|
||||
const sidebarPath = path.join(siteDir, 'sidebars.json');
|
||||
const routeBasePath = 'docs';
|
||||
const plugin = await pluginContentDocs(
|
||||
|
@ -470,7 +470,7 @@ describe('versioned website', () => {
|
|||
describe('versioned website (community)', () => {
|
||||
async function loadSite() {
|
||||
const siteDir = path.join(__dirname, '__fixtures__', 'versioned-site');
|
||||
const context = await loadContext(siteDir);
|
||||
const context = await loadContext({siteDir});
|
||||
const sidebarPath = path.join(siteDir, 'community_sidebars.json');
|
||||
const routeBasePath = 'community';
|
||||
const pluginId = 'community';
|
||||
|
@ -578,7 +578,7 @@ describe('versioned website (community)', () => {
|
|||
describe('site with doc label', () => {
|
||||
async function loadSite() {
|
||||
const siteDir = path.join(__dirname, '__fixtures__', 'site-with-doc-label');
|
||||
const context = await loadContext(siteDir);
|
||||
const context = await loadContext({siteDir});
|
||||
const sidebarPath = path.join(siteDir, 'sidebars.json');
|
||||
const plugin = await pluginContentDocs(
|
||||
context,
|
||||
|
@ -620,7 +620,7 @@ describe('site with full autogenerated sidebar', () => {
|
|||
'__fixtures__',
|
||||
'site-with-autogenerated-sidebar',
|
||||
);
|
||||
const context = await loadContext(siteDir);
|
||||
const context = await loadContext({siteDir});
|
||||
const plugin = await pluginContentDocs(
|
||||
context,
|
||||
validateOptions({
|
||||
|
@ -675,7 +675,7 @@ describe('site with partial autogenerated sidebars', () => {
|
|||
'__fixtures__',
|
||||
'site-with-autogenerated-sidebar',
|
||||
);
|
||||
const context = await loadContext(siteDir, {});
|
||||
const context = await loadContext({siteDir});
|
||||
const plugin = await pluginContentDocs(
|
||||
context,
|
||||
validateOptions({
|
||||
|
@ -731,7 +731,7 @@ describe('site with partial autogenerated sidebars 2 (fix #4638)', () => {
|
|||
'__fixtures__',
|
||||
'site-with-autogenerated-sidebar',
|
||||
);
|
||||
const context = await loadContext(siteDir, {});
|
||||
const context = await loadContext({siteDir});
|
||||
const plugin = await pluginContentDocs(
|
||||
context,
|
||||
validateOptions({
|
||||
|
@ -768,7 +768,7 @@ describe('site with custom sidebar items generator', () => {
|
|||
'__fixtures__',
|
||||
'site-with-autogenerated-sidebar',
|
||||
);
|
||||
const context = await loadContext(siteDir);
|
||||
const context = await loadContext({siteDir});
|
||||
const plugin = await pluginContentDocs(
|
||||
context,
|
||||
validateOptions({
|
||||
|
|
|
@ -22,7 +22,6 @@ import {
|
|||
import type {
|
||||
TranslationFileContent,
|
||||
TranslationFile,
|
||||
TranslationFiles,
|
||||
TranslationMessage,
|
||||
} from '@docusaurus/types';
|
||||
import {mergeTranslations} from '@docusaurus/utils';
|
||||
|
@ -242,7 +241,7 @@ function translateSidebars(
|
|||
);
|
||||
}
|
||||
|
||||
function getVersionTranslationFiles(version: LoadedVersion): TranslationFiles {
|
||||
function getVersionTranslationFiles(version: LoadedVersion): TranslationFile[] {
|
||||
const versionTranslations: TranslationFileContent = {
|
||||
'version.label': {
|
||||
message: version.label,
|
||||
|
@ -283,7 +282,7 @@ function translateVersion(
|
|||
|
||||
function getVersionsTranslationFiles(
|
||||
versions: LoadedVersion[],
|
||||
): TranslationFiles {
|
||||
): TranslationFile[] {
|
||||
return versions.flatMap(getVersionTranslationFiles);
|
||||
}
|
||||
function translateVersions(
|
||||
|
@ -295,7 +294,7 @@ function translateVersions(
|
|||
|
||||
export function getLoadedContentTranslationFiles(
|
||||
loadedContent: LoadedContent,
|
||||
): TranslationFiles {
|
||||
): TranslationFile[] {
|
||||
return getVersionsTranslationFiles(loadedContent.loadedVersions);
|
||||
}
|
||||
export function translateLoadedContent(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue