feat(v2): allow plugins to specify paths to watch (#1272)

This commit is contained in:
Yangshun Tay 2019-03-09 13:00:44 -08:00 committed by GitHub
parent 8629abf73a
commit cefee2dec1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 14 deletions

View file

@ -34,14 +34,19 @@ class DocusaurusContentBlogPlugin {
constructor(opts, context) {
this.options = {...DEFAULT_OPTIONS, ...opts};
this.context = context;
this.contentPath = path.resolve(this.context.siteDir, this.options.path);
}
getName() {
return 'docusaurus-plugin-content-blog';
}
async loadContents() {
const {pageCount, path: filePath, include, routeBasePath} = this.options;
const {env, siteConfig, siteDir} = this.context;
const blogDir = path.resolve(siteDir, filePath);
const {baseUrl} = siteConfig;
const {pageCount, include, routeBasePath} = this.options;
const {env, siteConfig} = this.context;
const blogDir = this.contentPath;
const {baseUrl} = siteConfig;
const blogFiles = await globby(include, {
cwd: blogDir,
});
@ -127,6 +132,10 @@ class DocusaurusContentBlogPlugin {
});
});
}
getPathsToWatch() {
return [this.contentPath];
}
}
module.exports = DocusaurusContentBlogPlugin;