refactor(v2): plugins lifecycle (#1299)

* refactor(v2): plugins lifecycle

* dont allow duplicate plugin & fix typo
This commit is contained in:
Endilie Yacop Sucipto 2019-03-24 06:08:36 +07:00 committed by Yangshun Tay
parent 3a7a253db7
commit 73b89658cc
10 changed files with 127 additions and 136 deletions

View file

@ -41,7 +41,7 @@ class DocusaurusPluginContentBlog {
}
// Fetches blog contents and returns metadata for the contents.
async loadContents() {
async loadContent() {
const {pageCount, include, routeBasePath} = this.options;
const {env, siteConfig} = this.context;
const blogDir = this.contentPath;
@ -109,10 +109,10 @@ class DocusaurusPluginContentBlog {
return blogMetadata;
}
async generateRoutes({metadata, actions}) {
async contentLoaded({content, actions}) {
const {blogPageComponent, blogPostComponent} = this.options;
const {addRoute} = actions;
metadata.forEach(metadataItem => {
content.forEach(metadataItem => {
const {isBlogPage, permalink} = metadataItem;
if (isBlogPage) {
addRoute({