mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
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:
parent
e5d9ff18a8
commit
cb8718a1e3
28 changed files with 177 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue