feat(v2): presets (#1401)

* feat(v2): presets

* misc: add newline

* misc: add tests

* misc: fix path
This commit is contained in:
Yangshun Tay 2019-04-27 10:47:56 -07:00 committed by GitHub
parent 7ebcf10478
commit 361986515c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 394 additions and 89 deletions

View file

@ -15,15 +15,15 @@ describe('loadDocs', () => {
const {env, siteDir, siteConfig} = await loadSetup('simple');
const sidebarPath = path.join(siteDir, 'sidebars.json');
const plugin = new DocusaurusPluginContentDocs(
{
path: '../docs',
sidebarPath,
},
{
env,
siteDir,
siteConfig,
},
{
path: '../docs',
sidebarPath,
},
);
const {docs: docsMetadata} = await plugin.loadContent();
const docsDir = plugin.contentPath;
@ -62,15 +62,15 @@ describe('loadDocs', () => {
const {env, siteDir, siteConfig} = await loadSetup('versioned');
const sidebarPath = path.join(siteDir, 'sidebars.json');
const plugin = new DocusaurusPluginContentDocs(
{
path: '../docs',
sidebarPath,
},
{
env,
siteDir,
siteConfig,
},
{
path: '../docs',
sidebarPath,
},
);
const {docs: docsMetadata, versionedDir} = await plugin.loadContent();
const docsDir = plugin.contentPath;
@ -109,15 +109,15 @@ describe('loadDocs', () => {
const {env, siteDir, siteConfig} = await loadSetup('transversioned');
const sidebarPath = path.join(siteDir, 'sidebars.json');
const plugin = new DocusaurusPluginContentDocs(
{
path: '../docs',
sidebarPath,
},
{
env,
siteDir,
siteConfig,
},
{
path: '../docs',
sidebarPath,
},
);
const {
docs: docsMetadata,
@ -177,15 +177,15 @@ describe('loadDocs', () => {
const {env, siteDir, siteConfig} = await loadSetup('translated');
const sidebarPath = path.join(siteDir, 'sidebars.json');
const plugin = new DocusaurusPluginContentDocs(
{
path: '../docs',
sidebarPath,
},
{
env,
siteDir,
siteConfig,
},
{
path: '../docs',
sidebarPath,
},
);
const {docs: docsMetadata, translatedDir} = await plugin.loadContent();
const docsDir = plugin.contentPath;
@ -227,16 +227,16 @@ describe('loadDocs', () => {
const {env, siteDir, siteConfig} = await loadSetup('versioned');
const sidebarPath = path.join(siteDir, 'sidebars.json');
const plugin = new DocusaurusPluginContentDocs(
{
path: '../docs',
sidebarPath,
skipNextRelease: true,
},
{
env,
siteDir,
siteConfig,
},
{
path: '../docs',
sidebarPath,
skipNextRelease: true,
},
);
const {docs: docsMetadata, versionedDir} = await plugin.loadContent();

View file

@ -32,7 +32,7 @@ const DEFAULT_OPTIONS = {
};
class DocusaurusPluginContentDocs {
constructor(opts, context) {
constructor(context, opts) {
this.options = {...DEFAULT_OPTIONS, ...opts};
this.context = context;
this.contentPath = path.resolve(this.context.siteDir, this.options.path);