Skip to content

feat(blog): allow processing blog posts through a processBlogPosts function#9886

Merged
slorber merged 18 commits intomainfrom
ozaki/processBlogPosts
Mar 5, 2024
Merged

feat(blog): allow processing blog posts through a processBlogPosts function#9886
slorber merged 18 commits intomainfrom
ozaki/processBlogPosts

Conversation

@OzakIOne
Copy link
Contributor

@OzakIOne OzakIOne commented Feb 23, 2024

Motivation

This new option processBlogPost allow the user to modify BlogPost 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)

blog: {
  path: 'blog',
  processBlogPosts: async ({blogPosts}) =>
      blogPosts.filter(
        (blog) => blog.metadata.date.getFullYear() > 2020,
      ),
}
blog: {
  path: 'blog',
  processBlogPosts: async ({blogPosts}) =>
      blogPosts.sort((a, b) =>
        a.metadata.title.localeCompare(b.metadata.title),
      ),
}

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

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Argos Add this label to run UI visual regression tests. See argos.yml GH action. CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior. to backport This PR is planned to be backported to a stable version of Docusaurus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance support for posts related to events in the past Add sortSidebarByLastUpdate to blogs to change the order in the sidebar

3 participants