From aa958f0cc1b766b2f492fa2eb09dabdc13072f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Mon, 23 Oct 2023 15:27:41 +0200 Subject: [PATCH] fix(plugin-blog): blog archive should hide unlisted blog posts (#9437) --- packages/docusaurus-plugin-content-blog/src/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/docusaurus-plugin-content-blog/src/index.ts b/packages/docusaurus-plugin-content-blog/src/index.ts index d5ca869b4a1d..4605877ed75b 100644 --- a/packages/docusaurus-plugin-content-blog/src/index.ts +++ b/packages/docusaurus-plugin-content-blog/src/index.ts @@ -191,6 +191,8 @@ export default async function pluginContentBlog( blogTagsListPath, } = blogContents; + const listedBlogPosts = blogPosts.filter(shouldBeListed); + const blogItemsToMetadata: {[postId: string]: BlogPostMetadata} = {}; const sidebarBlogPosts = @@ -213,7 +215,7 @@ export default async function pluginContentBlog( }); } - if (archiveBasePath && blogPosts.length) { + if (archiveBasePath && listedBlogPosts.length) { const archiveUrl = normalizeUrl([ baseUrl, routeBasePath, @@ -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,