refactor(v2): load sidebars from docs plugin (#1328)

* refactor(v2): load sidebars from docs plugin

* fix(v2): update tests

* fix(v2): change to sidebarPath
This commit is contained in:
Yangshun Tay 2019-04-01 19:42:14 -07:00 committed by GitHub
parent 8dd6bc1082
commit 029aa636a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 71 additions and 42 deletions

View file

@ -11,11 +11,13 @@ import loadSetup from '../../docusaurus/test/loadSetup';
import DocusaurusPluginContentDocs from '../index';
describe('loadDocs', () => {
test.only('simple website', async () => {
test('simple website', async () => {
const {env, siteDir, siteConfig} = await loadSetup('simple');
const sidebarPath = path.join(siteDir, 'sidebars.json');
const plugin = new DocusaurusPluginContentDocs(
{
path: '../docs',
sidebarPath,
},
{
env,
@ -60,9 +62,11 @@ describe('loadDocs', () => {
const {env, siteDir, siteConfig, versionedDir} = await loadSetup(
'versioned',
);
const sidebarPath = path.join(siteDir, 'sidebars.json');
const plugin = new DocusaurusPluginContentDocs(
{
path: '../docs',
sidebarPath,
},
{
env,
@ -111,9 +115,11 @@ describe('loadDocs', () => {
translatedDir,
versionedDir,
} = await loadSetup('transversioned');
const sidebarPath = path.join(siteDir, 'sidebars.json');
const plugin = new DocusaurusPluginContentDocs(
{
path: '../docs',
sidebarPath,
},
{
env,
@ -175,9 +181,11 @@ describe('loadDocs', () => {
const {env, siteDir, siteConfig, translatedDir} = await loadSetup(
'translated',
);
const sidebarPath = path.join(siteDir, 'sidebars.json');
const plugin = new DocusaurusPluginContentDocs(
{
path: '../docs',
sidebarPath,
},
{
env,
@ -225,15 +233,19 @@ describe('loadDocs', () => {
const {env, siteDir, siteConfig, versionedDir} = await loadSetup(
'versioned',
);
const sidebarPath = path.join(siteDir, 'sidebars.json');
const plugin = new DocusaurusPluginContentDocs(
{
path: '../docs',
sidebarPath,
},
{
cliOptions: {
skipNextRelease: true,
},
env,
siteDir,
siteConfig,
cliOptions: {skipNextRelease: true},
},
);
const {docs: docsMetadata} = await plugin.loadContent();