Skip to content

Commit

Permalink
fix(plugin-blog): blog archive should hide unlisted blog posts (#9437)
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Oct 23, 2023
1 parent 2bb4fd0 commit aa958f0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/docusaurus-plugin-content-blog/src/index.ts
Expand Up @@ -191,6 +191,8 @@ export default async function pluginContentBlog(
blogTagsListPath,
} = blogContents;

const listedBlogPosts = blogPosts.filter(shouldBeListed);

const blogItemsToMetadata: {[postId: string]: BlogPostMetadata} = {};

const sidebarBlogPosts =
Expand All @@ -213,7 +215,7 @@ export default async function pluginContentBlog(
});
}

if (archiveBasePath && blogPosts.length) {
if (archiveBasePath && listedBlogPosts.length) {
const archiveUrl = normalizeUrl([
baseUrl,
routeBasePath,
Expand All @@ -222,7 +224,7 @@ export default async function pluginContentBlog(
// Create a blog archive route
const archiveProp = await createData(
`${docuHash(archiveUrl)}.json`,
JSON.stringify({blogPosts}, null, 2),
JSON.stringify({blogPosts: listedBlogPosts}, null, 2),
);
addRoute({
path: archiveUrl,
Expand Down

0 comments on commit aa958f0

Please sign in to comment.