-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed
Labels
featureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Description
🚀 Feature
Let's be less opinionated and let users decide on the sorting logic.
Have you read the Contributing Guidelines on issues?
Yes
Has this been requested on Canny?
Requested on Discord
Motivation
Sorting by descending time works in almost all cases, but we shouldn't assume that all users use the blog for time-based information. E.g., sort by alphabetical order? Sort by tags?
API Design
A new comparePosts plugin option, which accepts a function that is passed to the sorting algorithm:
docusaurus/packages/docusaurus-plugin-content-blog/src/blogUtils.ts
Lines 345 to 347 in b40e459
| blogPosts.sort( | |
| (a, b) => b.metadata.date.getTime() - a.metadata.date.getTime(), | |
| ); |
And yes, it will receive the entire blog post, with all of its metadata and content.
Have you tried building it?
No; should be trivial
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.This is not a bug or issue with Docusausus, per se. It is a feature request for the future.