mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-20 12:37:01 +02:00
refactor(v2): convert blog page to be added to routes by plugin lifecycle
This commit is contained in:
parent
74d26d4f3d
commit
7475051526
4 changed files with 37 additions and 64 deletions
|
@ -105,12 +105,17 @@ class DocusaurusContentBlogPlugin {
|
|||
}
|
||||
|
||||
async generateRoutes({contents, actions}) {
|
||||
const {blogPostComponent} = this.options;
|
||||
const {blogPageComponent, blogPostComponent} = this.options;
|
||||
const {addRoute} = actions;
|
||||
contents.forEach(metadata => {
|
||||
const {permalink, source} = metadata;
|
||||
if (metadata.isBlogPage) {
|
||||
// TODO: Handle blog page.
|
||||
const {isBlogPage, permalink} = metadata;
|
||||
if (isBlogPage) {
|
||||
addRoute({
|
||||
path: permalink,
|
||||
component: blogPageComponent,
|
||||
metadata,
|
||||
modules: metadata.posts.map(post => post.source),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -118,7 +123,7 @@ class DocusaurusContentBlogPlugin {
|
|||
path: permalink,
|
||||
component: blogPostComponent,
|
||||
metadata,
|
||||
content: source,
|
||||
modules: [metadata.source],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue