fix(v2): allow relative sidebar path resolution in docs:version command (#4861)

* fix(v2): allow relative sidebar path resolution in docs:version command

* factorize sidebarPath option resolution logic + dogfood

Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
Alexey Pyltsyn 2021-06-02 19:21:45 +03:00 committed by GitHub
parent 65cf8dacee
commit 35bdde3409
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 6 deletions

View file

@ -24,6 +24,7 @@ import {DEFAULT_PLUGIN_ID} from '@docusaurus/core/lib/constants';
import {LoadContext} from '@docusaurus/types';
import {getPluginI18nPath, normalizeUrl, posixPath} from '@docusaurus/utils';
import {difference} from 'lodash';
import {resolveSidebarPathOption} from './sidebars';
// retro-compatibility: no prefix for the default plugin id
function addPluginIdPrefix(fileOrDir: string, pluginId: string): string {
@ -184,9 +185,7 @@ function getVersionMetadataPaths({
function getSidebarFilePath() {
if (isCurrentVersion) {
return options.sidebarPath
? path.resolve(context.siteDir, options.sidebarPath)
: options.sidebarPath;
return resolveSidebarPathOption(context.siteDir, options.sidebarPath);
} else {
return path.join(
getVersionedSidebarsDirPath(context.siteDir, options.id),