Skip to content

Commit 068cf2b

Browse files
committed
fix(content-blog): filter unlisted posts from author pages
1 parent 05acc90 commit 068cf2b

File tree

1 file changed

+13
-7
lines changed
  • packages/docusaurus-plugin-content-blog/src

1 file changed

+13
-7
lines changed

packages/docusaurus-plugin-content-blog/src/routes.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,14 @@ export async function buildAllRoutes({
294294
sidebar: sidebarModulePath,
295295
},
296296
props: {
297-
authors: authors.map((author) =>
298-
toAuthorItemProp({
297+
authors: authors.map((author) => {
298+
const authorPosts = blogPostsByAuthorKey[author.key] ?? [];
299+
const listedAuthorPosts = authorPosts.filter(shouldBeListed);
300+
return toAuthorItemProp({
299301
author,
300-
count: blogPostsByAuthorKey[author.key]?.length ?? 0,
301-
}),
302-
),
302+
count: listedAuthorPosts.length,
303+
});
304+
}),
303305
},
304306
context: {
305307
blogMetadata: blogMetadataModulePath,
@@ -309,12 +311,13 @@ export async function buildAllRoutes({
309311

310312
function createAuthorPaginatedRoute(author: AuthorWithKey): RouteConfig[] {
311313
const authorBlogPosts = blogPostsByAuthorKey[author.key] ?? [];
314+
const listedAuthorBlogPosts = authorBlogPosts.filter(shouldBeListed);
312315
if (!author.page) {
313316
return [];
314317
}
315318

316319
const pages = paginateBlogPosts({
317-
blogPosts: authorBlogPosts,
320+
blogPosts: listedAuthorBlogPosts,
318321
basePageUrl: author.page.permalink,
319322
blogDescription,
320323
blogTitle,
@@ -332,7 +335,10 @@ export async function buildAllRoutes({
332335
sidebar: sidebarModulePath,
333336
},
334337
props: {
335-
author: toAuthorItemProp({author, count: authorBlogPosts.length}),
338+
author: toAuthorItemProp({
339+
author,
340+
count: listedAuthorBlogPosts.length,
341+
}),
336342
listMetadata: metadata,
337343
},
338344
context: {

0 commit comments

Comments
 (0)