Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin-blog): blog archive should hide unlisted blog posts #9437

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/docusaurus-plugin-content-blog/src/index.ts
Original file line number Diff line number Diff line change
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
Loading