mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-19 19:22:28 +02:00
refactor(content-docs): move isCategoriesShorthand to utils (#5962)
This commit is contained in:
parent
ac1df888ae
commit
2f7d6fea1e
18 changed files with 39 additions and 29 deletions
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import type {SidebarOptions} from '../types';
|
||||
import {
|
||||
import type {
|
||||
NormalizedSidebarItem,
|
||||
NormalizedSidebar,
|
||||
NormalizedSidebars,
|
||||
|
@ -15,9 +15,9 @@ import {
|
|||
SidebarItemConfig,
|
||||
SidebarConfig,
|
||||
SidebarsConfig,
|
||||
isCategoriesShorthand,
|
||||
} from './types';
|
||||
import {mapValues} from 'lodash';
|
||||
import {isCategoriesShorthand} from './utils';
|
||||
|
||||
function normalizeCategoriesShorthand(
|
||||
sidebar: SidebarCategoriesShorthand,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {Optional} from 'utility-types';
|
||||
import type {Optional} from 'utility-types';
|
||||
import type {
|
||||
DocMetadataBase,
|
||||
VersionMetadata,
|
||||
|
@ -56,12 +56,6 @@ export type SidebarCategoriesShorthand = {
|
|||
[sidebarCategory: string]: SidebarItemConfig[];
|
||||
};
|
||||
|
||||
export function isCategoriesShorthand(
|
||||
item: SidebarItemConfig,
|
||||
): item is SidebarCategoriesShorthand {
|
||||
return typeof item !== 'string' && !item.type;
|
||||
}
|
||||
|
||||
export type SidebarItemConfig =
|
||||
| SidebarItemDoc
|
||||
| SidebarItemLink
|
||||
|
|
|
@ -13,10 +13,18 @@ import type {
|
|||
SidebarItemLink,
|
||||
SidebarItemDoc,
|
||||
SidebarItemType,
|
||||
SidebarCategoriesShorthand,
|
||||
SidebarItemConfig,
|
||||
} from './types';
|
||||
import {mapValues, difference} from 'lodash';
|
||||
import {getElementsAround, toMessageRelativeFilePath} from '@docusaurus/utils';
|
||||
|
||||
export function isCategoriesShorthand(
|
||||
item: SidebarItemConfig,
|
||||
): item is SidebarCategoriesShorthand {
|
||||
return typeof item !== 'string' && !item.type;
|
||||
}
|
||||
|
||||
export function transformSidebarItems(
|
||||
sidebar: Sidebar,
|
||||
updateFn: (item: SidebarItem) => SidebarItem,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import {Joi, URISchema} from '@docusaurus/utils-validation';
|
||||
import {
|
||||
import type {
|
||||
SidebarItemConfig,
|
||||
SidebarCategoriesShorthand,
|
||||
SidebarItemBase,
|
||||
|
@ -15,8 +15,8 @@ import {
|
|||
SidebarItemLink,
|
||||
SidebarItemCategoryConfig,
|
||||
SidebarsConfig,
|
||||
isCategoriesShorthand,
|
||||
} from './types';
|
||||
import {isCategoriesShorthand} from './utils';
|
||||
|
||||
const sidebarItemBaseSchema = Joi.object<SidebarItemBase>({
|
||||
className: Joi.string(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue