fix(v2): handle non existent blog, docs, pages (#1459)

* fix(v2): handle non existent blog, docs, pages

* nits
This commit is contained in:
Endi 2019-05-15 13:55:07 +07:00 committed by GitHub
parent f84abfe2d1
commit 55d7920825
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 12 deletions

View file

@ -7,6 +7,7 @@
const globby = require('globby');
const path = require('path');
const fs = require('fs');
const {encodePath, fileToPath, docuHash} = require('@docusaurus/utils');
const DEFAULT_OPTIONS = {
@ -39,6 +40,10 @@ class DocusaurusPluginContentPages {
const {siteConfig} = this.context;
const pagesDir = this.contentPath;
if (!fs.existsSync(pagesDir)) {
return null;
}
const {baseUrl} = siteConfig;
const pagesFiles = await globby(include, {
cwd: pagesDir,
@ -64,6 +69,10 @@ class DocusaurusPluginContentPages {
}
async contentLoaded({content, actions}) {
if (!content) {
return;
}
const {addRoute, createData} = actions;
await Promise.all(