feat(content-blog): allow disabling generating archive (#6415)

This commit is contained in:
Joshua Chen 2022-01-20 21:52:19 +08:00 committed by GitHub
parent 2a5407f6bd
commit d506bca12d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 22 deletions

View file

@ -242,25 +242,26 @@ export default async function pluginContentBlog(
? blogPosts
: blogPosts.slice(0, 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),
},
});
if (archiveBasePath) {
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(