refactor(content-docs): clean up sidebars logic; validate generator returns (#6596)

* refactor(content-docs): clean up sidebars logic; validate generator returns

* remove another TODO

* fix types

* refactors

* refactor...
This commit is contained in:
Joshua Chen 2022-02-04 09:46:25 +08:00 committed by GitHub
parent d6bdf7e804
commit e3fd3e74ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 750 additions and 615 deletions

View file

@ -16,7 +16,7 @@ import type {
PathOptions,
SidebarOptions,
} from '@docusaurus/plugin-content-docs';
import {loadSidebarsFile, resolveSidebarPathOption} from './sidebars';
import {loadSidebarsFileUnsafe, resolveSidebarPathOption} from './sidebars';
import {DEFAULT_PLUGIN_ID} from '@docusaurus/utils';
import logger from '@docusaurus/logger';
@ -34,7 +34,8 @@ async function createVersionedSidebarFile({
// Load current sidebar and create a new versioned sidebars file (if needed).
// Note: we don't need the sidebars file to be normalized: it's ok to let
// plugin option changes to impact older, versioned sidebars
const sidebars = await loadSidebarsFile(sidebarPath);
// We don't validate here, assuming the user has already built the version
const sidebars = await loadSidebarsFileUnsafe(sidebarPath);
// Do not create a useless versioned sidebars file if sidebars file is empty
// or sidebars are disabled/false)