Skip to content

Commit

Permalink
Split files
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Oct 10, 2021
1 parent 6ed6989 commit e6c6b64
Show file tree
Hide file tree
Showing 15 changed files with 1,013 additions and 1,033 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
import {toSidebarsProp} from '../props';

import {validate} from 'webpack';
import {DefaultSidebarItemsGenerator} from '../sidebarItemsGenerator';
import {DefaultSidebarItemsGenerator} from '../sidebars/generator';
import {DisabledSidebars} from '../sidebars';

function findDocById(version: LoadedVersion, unversionedId: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import {OptionsSchema, DEFAULT_OPTIONS, validateOptions} from '../options';
import {normalizePluginOptions} from '@docusaurus/utils-validation';
import {DefaultSidebarItemsGenerator} from '../sidebarItemsGenerator';
import {DefaultSidebarItemsGenerator} from '../sidebars/generator';
import {
DefaultNumberPrefixParser,
DisabledNumberPrefixParser,
Expand Down
19 changes: 11 additions & 8 deletions packages/docusaurus-plugin-content-docs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import {
createAbsoluteFilePathMatcher,
} from '@docusaurus/utils';
import {LoadContext, Plugin, RouteConfig} from '@docusaurus/types';
import {loadSidebars, createSidebarsUtils, processSidebars} from './sidebars';
import {loadSidebars, processSidebars} from './sidebars';
import {createSidebarsUtils} from './sidebars/utils';
import {CategoryMetadataFilenamePattern} from './sidebars/generator';
import {readVersionDocs, processDocMetadata} from './docs';
import {getDocsDirPaths, readVersionsMetadata} from './versions';

Expand Down Expand Up @@ -49,7 +51,6 @@ import {
translateLoadedContent,
getLoadedContentTranslationFiles,
} from './translations';
import {CategoryMetadataFilenamePattern} from './sidebarItemsGenerator';
import chalk from 'chalk';
import {getVersionTags} from './tags';
import {PropTagsListPage} from '@docusaurus/plugin-content-docs-types';
Expand Down Expand Up @@ -191,18 +192,21 @@ export default function pluginContentDocs(
},
});

const sidebarsUtils = createSidebarsUtils(sidebars);
const {
checkSidebarsDocIds,
getDocNavigation,
getFirstDocIdOfFirstSidebar,
} = createSidebarsUtils(sidebars);

const validDocIds = Object.keys(docsBaseById);
sidebarsUtils.checkSidebarsDocIds(
checkSidebarsDocIds(
validDocIds,
versionMetadata.sidebarFilePath as string,
);

// Add sidebar/next/previous to the docs
function addNavData(doc: DocMetadataBase): DocMetadata {
const {sidebarName, previousId, nextId} =
sidebarsUtils.getDocNavigation(doc.id);
const {sidebarName, previousId, nextId} = getDocNavigation(doc.id);
const toDocNavLink = (navDocId: string): DocNavLink => {
const {title, permalink, frontMatter} = docsBaseById[navDocId];
return {
Expand Down Expand Up @@ -236,8 +240,7 @@ export default function pluginContentDocs(
(doc) =>
doc.unversionedId === options.homePageId || doc.slug === '/',
);
const firstDocIdOfFirstSidebar =
sidebarsUtils.getFirstDocIdOfFirstSidebar();
const firstDocIdOfFirstSidebar = getFirstDocIdOfFirstSidebar();
if (versionHomeDoc) {
return versionHomeDoc;
} else if (firstDocIdOfFirstSidebar) {
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-docs/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {GlobExcludeDefault} from '@docusaurus/utils';
import {OptionValidationContext, ValidationResult} from '@docusaurus/types';
import chalk from 'chalk';
import admonitions from 'remark-admonitions';
import {DefaultSidebarItemsGenerator} from './sidebarItemsGenerator';
import {DefaultSidebarItemsGenerator} from './sidebars/generator';
import {
DefaultNumberPrefixParser,
DisabledNumberPrefixParser,
Expand Down
Loading

0 comments on commit e6c6b64

Please sign in to comment.