feat: adds blog archive route (#5428)

* [feature] adds blog archive route

* Update plugin-content-blog.md

* fix TS issues + minor refactors

* remove useless css

* add translation apis

* add missing translations

Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
Gabriel Csapo 2021-09-02 08:35:13 -07:00 committed by GitHub
parent e5d9ff18a8
commit cb8718a1e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 177 additions and 4 deletions

View file

@ -225,6 +225,8 @@ export default function pluginContentBlog(
blogPostComponent,
blogTagsListComponent,
blogTagsPostsComponent,
routeBasePath,
archiveBasePath,
} = options;
const {addRoute, createData} = actions;
@ -243,6 +245,26 @@ export default function pluginContentBlog(
? blogPosts
: take(blogPosts, options.blogSidebarCount);
const archiveUrl = normalizeUrl([
baseUrl,
routeBasePath,
archiveBasePath,
]);
// creates a blog archive route
const archiveProp = await createData(
`${docuHash(archiveUrl)}.json`,
JSON.stringify({blogPosts}, null, 2),
);
addRoute({
path: archiveUrl,
component: '@theme/BlogArchivePage',
exact: true,
modules: {
archive: aliasedSource(archiveProp),
},
});
// This prop is useful to provide the blog list sidebar
const sidebarProp = await createData(
// Note that this created data path must be in sync with