fix(content-blog): filter unlisted posts from author pages#11559
Conversation
|
Hi @pyrytakala! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
slorber
left a comment
There was a problem hiding this comment.
LGTM, thanks for catching this bug!
This part of the codebase is not well-tested nor easy to test, I'll try to improve this in another PR.
Pre-flight checklist
I have read the Contributing Guidelines on pull requests.
If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.
Motivation
Fixes a bug where author pages were displaying unlisted blog posts. Author pages should only show listed posts, consistent with tag pages, archive pages, and the main blog list.
Root Cause: The
createAuthorPaginatedRoutefunction was using unfilteredauthorBlogPostsinstead of filtering out unlisted posts before pagination. Unlike tag pages, archive pages, and the main blog list (which all uselistedBlogPosts), author pages were missing the filtering step.Note: The
isUnlisted()function only returnstruein production mode (or withSIMULATE_PRODUCTION_VISIBILITY=true). In development mode, unlisted posts appear as listed, but this is expected behavior - the fix works correctly in production builds.Test Plan
Manual Testing
/blog/authors/slorber)Consistency Check
packages/docusaurus-plugin-content-blog/src/blogUtils.ts:141-152viagetTagVisibility()listedBlogPostsatpackages/docusaurus-plugin-content-blog/src/routes.ts:92,163listedBlogPostsatpackages/docusaurus-plugin-content-blog/src/index.ts:259,295listedAuthorBlogPosts.filter(shouldBeListed)atpackages/docusaurus-plugin-content-blog/src/routes.ts:321,306Testing with Production Flag
Tested with
SIMULATE_PRODUCTION_VISIBILITY=trueto verify unlisted posts are correctly filtered in production mode.Commands Run
Test links
Deploy preview:
https://deploy-preview-11559--docusaurus-2.netlify.app/
Related issues/PRs
None - this is a bug fix identified during code review. The bug report analysis showed that author pages were the only blog route type not filtering unlisted posts, while tag pages, archive pages, and the main blog list all correctly filter them.