-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
feat(blog): allow processing blog posts through a processBlogPosts function #9886
Conversation
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
Size Change: 0 B Total Size: 992 kB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost looks good
That would also be nice to have an extra test in index.test.ts
to cover the fact that the processBlogPost
option has an impact on the plugin loadContent result.
For example, take a simple site with 10 blog posts, page size = 3, and provide a processBlogPosts
that only take the 4 first blog posts in the list: the resulting number of pages should be 2 instead of 4.
This kind of test ensures the plugin works overall, and covers the fact that applyProcessBlogPosts
is called before blogPosts.filter(shouldBeListed)
, which is important otherwise we would have a bug.
packages/docusaurus-plugin-content-blog/src/__tests__/blogUtils.test.ts
Outdated
Show resolved
Hide resolved
packages/docusaurus-plugin-content-blog/src/__tests__/blogUtils.test.ts
Outdated
Show resolved
Hide resolved
packages/docusaurus-plugin-content-blog/src/__tests__/blogUtils.test.ts
Outdated
Show resolved
Hide resolved
packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts
Outdated
Show resolved
Hide resolved
packages/docusaurus-plugin-content-blog/src/__tests__/index.test.ts
Outdated
Show resolved
Hide resolved
packages/docusaurus-plugin-content-blog/src/__tests__/__snapshots__/index.test.ts.snap
Outdated
Show resolved
Hide resolved
… of in nodejs code (#9868) Co-authored-by: OzakIOne <[email protected]> Co-authored-by: sebastien <[email protected]>
This reverts commit 062569f.
packages/docusaurus-plugin-content-blog/src/__tests__/blogUtils.test.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost good 👍
Motivation
This new option
processBlogPost
allow the user to modifyBlogPost
array used in archive page and blog page.For example the user can filter to only list blogs that were created after year 2020 or sort
BlogPost
by alphabetical order.#9840 (review)
Test Plan
yarn jest docusaurus-plugin-content-blog --watch
Test links
Blog page
Archive page
processBlogPosts documentation
Related issues/PRs
Supersed #9840
Fix #9831
Fix #9827