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:
Joshua Chen 2021-07-23 20:24:36 +08:00 committed by GitHub
parent b38c35a36d
commit 24156efcfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 487 additions and 109 deletions

View file

@ -270,6 +270,8 @@ describe('simple website', () => {
expect(mock).toHaveBeenCalledWith('1.0.0', siteDir, DEFAULT_PLUGIN_ID, {
path: 'docs',
sidebarPath,
sidebarCollapsed: true,
sidebarCollapsible: true,
});
mock.mockRestore();
});
@ -478,6 +480,8 @@ describe('versioned website', () => {
expect(mock).toHaveBeenCalledWith('2.0.0', siteDir, DEFAULT_PLUGIN_ID, {
path: routeBasePath,
sidebarPath,
sidebarCollapsed: true,
sidebarCollapsible: true,
});
mock.mockRestore();
});
@ -729,6 +733,8 @@ describe('versioned website (community)', () => {
expect(mock).toHaveBeenCalledWith('2.0.0', siteDir, pluginId, {
path: routeBasePath,
sidebarPath,
sidebarCollapsed: true,
sidebarCollapsible: true,
});
mock.mockRestore();
});
@ -907,6 +913,7 @@ describe('site with full autogenerated sidebar', () => {
type: 'category',
label: 'Guides',
collapsed: true,
collapsible: true,
items: [
{
type: 'doc',
@ -938,6 +945,7 @@ describe('site with full autogenerated sidebar', () => {
type: 'category',
label: 'API (label from _category_.json)',
collapsed: true,
collapsible: true,
items: [
{
type: 'doc',
@ -947,6 +955,7 @@ describe('site with full autogenerated sidebar', () => {
type: 'category',
label: 'Core APIs',
collapsed: true,
collapsible: true,
items: [
{
type: 'doc',
@ -963,6 +972,7 @@ describe('site with full autogenerated sidebar', () => {
type: 'category',
label: 'Extension APIs (label from _category_.yml)',
collapsed: true,
collapsible: true,
items: [
{
type: 'doc',
@ -1461,6 +1471,7 @@ describe('site with partial autogenerated sidebars', () => {
type: 'category',
label: 'Some category',
collapsed: true,
collapsible: true,
items: [
{
type: 'doc',
@ -1650,6 +1661,7 @@ describe('site with partial autogenerated sidebars 2 (fix #4638)', () => {
type: 'category',
label: 'Core APIs',
collapsed: true,
collapsible: true,
items: [
{
type: 'doc',
@ -1666,6 +1678,7 @@ describe('site with partial autogenerated sidebars 2 (fix #4638)', () => {
type: 'category',
label: 'Extension APIs (label from _category_.yml)', // Fix #4638
collapsed: true,
collapsible: true,
items: [
{
type: 'doc',
@ -1782,6 +1795,7 @@ describe('site with custom sidebar items generator', () => {
type: 'category',
label: 'API (label from _category_.json)',
collapsed: true,
collapsible: true,
items: [
{
type: 'doc',
@ -1791,6 +1805,7 @@ describe('site with custom sidebar items generator', () => {
type: 'category',
label: 'Extension APIs (label from _category_.yml)',
collapsed: true,
collapsible: true,
items: [
{
type: 'doc',
@ -1806,6 +1821,7 @@ describe('site with custom sidebar items generator', () => {
type: 'category',
label: 'Core APIs',
collapsed: true,
collapsible: true,
items: [
{
type: 'doc',
@ -1827,6 +1843,7 @@ describe('site with custom sidebar items generator', () => {
type: 'category',
label: 'Guides',
collapsed: true,
collapsible: true,
items: [
{
type: 'doc',