mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-09 23:27:28 +02:00
feat: docs plugin options sidebarCollapsible + sidebarCollapsed (#5203)
* Add prop Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Add `collapsible` option to sidebar item Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Add eslint-ignore Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Move new page Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Allow in autogenerated Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Fix tests Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Move config options to plugin-docs Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Make non-collapsible items always expanded Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * docs versioning cli should receive a single options object * Update cli.test.ts * revert validateCategoryMetadataFile change * remove theme usage of themeConfig.sidebarCollapsible * better handling of sidebar item category inconsistencies + add warning message * Update snapshot Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Handle plugin option inconsistencies * improve doc for new sidebarCollapsible doc options * remove warning in fixSidebarItemInconsistencies as it will be annoyed for versioned sites, as "collapsed" is already persisted in sidebar json files Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
b38c35a36d
commit
24156efcfb
27 changed files with 487 additions and 109 deletions
|
@ -16,6 +16,7 @@ import {
|
|||
PathOptions,
|
||||
UnprocessedSidebarItem,
|
||||
UnprocessedSidebars,
|
||||
SidebarOptions,
|
||||
} from './types';
|
||||
import {loadSidebars, resolveSidebarPathOption} from './sidebars';
|
||||
import {DEFAULT_PLUGIN_ID} from '@docusaurus/core/lib/constants';
|
||||
|
@ -25,14 +26,16 @@ function createVersionedSidebarFile({
|
|||
pluginId,
|
||||
sidebarPath,
|
||||
version,
|
||||
options,
|
||||
}: {
|
||||
siteDir: string;
|
||||
pluginId: string;
|
||||
sidebarPath: string | false | undefined;
|
||||
version: string;
|
||||
options: SidebarOptions;
|
||||
}) {
|
||||
// Load current sidebar and create a new versioned sidebars file (if needed).
|
||||
const loadedSidebars = loadSidebars(sidebarPath);
|
||||
const loadedSidebars = loadSidebars(sidebarPath, options);
|
||||
|
||||
// Do not create a useless versioned sidebars file if sidebars file is empty or sidebars are disabled/false)
|
||||
const shouldCreateVersionedSidebarFile =
|
||||
|
@ -87,7 +90,7 @@ export function cliDocsVersionCommand(
|
|||
version: string | null | undefined,
|
||||
siteDir: string,
|
||||
pluginId: string,
|
||||
options: PathOptions,
|
||||
options: PathOptions & SidebarOptions,
|
||||
): void {
|
||||
// It wouldn't be very user-friendly to show a [default] log prefix,
|
||||
// so we use [docs] instead of [default]
|
||||
|
@ -159,6 +162,7 @@ export function cliDocsVersionCommand(
|
|||
pluginId,
|
||||
version,
|
||||
sidebarPath: resolveSidebarPathOption(siteDir, sidebarPath),
|
||||
options,
|
||||
});
|
||||
|
||||
// Update versions.json file.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue