Skip to content

feat(content-blog): allow sorting posts in ascending order#5787

Merged
slorber merged 4 commits intofacebook:mainfrom
cerkiewny:feature/custom_blog_order
Nov 9, 2021
Merged

feat(content-blog): allow sorting posts in ascending order#5787
slorber merged 4 commits intofacebook:mainfrom
cerkiewny:feature/custom_blog_order

Conversation

@cerkiewny
Copy link
Contributor

@cerkiewny cerkiewny commented Oct 25, 2021

Motivation

Fix #5692

Have you read the Contributing Guidelines on pull requests?

Yes.

Test Plan

Regression tests for older relevant tests.
Created new test that sorts posts in reverse creation order and compare it to default option.

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Oct 25, 2021
@cerkiewny cerkiewny force-pushed the feature/custom_blog_order branch from e6baf77 to f5595d5 Compare October 25, 2021 21:55
@netlify
Copy link

netlify bot commented Oct 25, 2021

✔️ [V2]
Built without sensitive environment variables

🔨 Explore the source changes: e6baf77

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/6177269237c261000741f929

😎 Browse the preview: https://deploy-preview-5787--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Oct 25, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 76
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-5787--docusaurus-2.netlify.app/

@netlify
Copy link

netlify bot commented Oct 25, 2021

✔️ [V2]
Built without sensitive environment variables

🔨 Explore the source changes: f5595d5

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/617727b6c80df900076f3595

😎 Browse the preview: https://deploy-preview-5787--docusaurus-2.netlify.app

@netlify
Copy link

netlify bot commented Oct 25, 2021

✔️ [V2]
Built without sensitive environment variables

🔨 Explore the source changes: f3f14f9

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/618a437801d89a000797e8c7

😎 Browse the preview: https://deploy-preview-5787--docusaurus-2.netlify.app

Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

For now we should just provide a way to sort by date desc or asc

see #5692

@cerkiewny
Copy link
Contributor Author

Sure, sounds good I'll resubmit PR at the end or just after weekend

@Josh-Cena
Copy link
Collaborator

Sure, sounds good I'll resubmit PR at the end or just after weekend

No need to close the current one, just change the current one

@cerkiewny
Copy link
Contributor Author

Sure, sounds good I'll resubmit PR at the end or just after weekend

No need to close the current one, just change the current one
I meant I will resubmit this one :p

@Josh-Cena Josh-Cena changed the title Feature/custom blog order feat(content-blog): allow sorting posts in ascending order Oct 30, 2021
@Josh-Cena Josh-Cena added the pr: new feature This PR adds a new API or behavior. label Oct 30, 2021
@cerkiewny cerkiewny force-pushed the feature/custom_blog_order branch from d5104eb to f28279e Compare November 8, 2021 11:11
@cerkiewny cerkiewny requested a review from slorber November 8, 2021 11:12
Copy link
Collaborator

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it mostly looks good in terms of implementation. In terms of whether we want this API or not... not sure🤔

Several API design suggestions:

  • postSortDirection => sortPosts (we can have other options in the future)
  • 'desc' => 'descending' (it's better to be explicit IMO)

@cerkiewny cerkiewny force-pushed the feature/custom_blog_order branch from b52ff03 to dfc615c Compare November 8, 2021 14:45
@cerkiewny cerkiewny requested a review from Josh-Cena November 9, 2021 09:35
| `feedOptions.description` | `string` | <code>\`${siteConfig.title} Blog\`</code> | Description of the feed. |
| `feedOptions.copyright` | `string` | `undefined` | Copyright message. |
| `feedOptions.language` | `string` (See [documentation](http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes) for possible values) | `undefined` | Language metadata of the feed. |
| `postSorting` | <code>'descending' \| 'ascending' </code> | `'descending'` | Governs the direction of blog post sorting. |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| `postSorting` | <code>'descending' \| 'ascending' </code> | `'descending'` | Governs the direction of blog post sorting. |
| `sortPosts` | <code>'descending' \| 'ascending' </code> | `'descending'` | Governs the direction of blog post sorting. |

Copy link
Collaborator

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Looking for @slorber

@slorber
Copy link
Collaborator

slorber commented Nov 9, 2021

LGTM

sortPosts is nice, gives the opportunity to eventually use a fn later if we change our mind

@slorber
Copy link
Collaborator

slorber commented Feb 9, 2024

Just curious, are you using this feature @cerkiewny?

Do you expect the RSS feed to be in ascending order too? 🤔

Asking for #9827 (comment)

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

Labels

CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blog posts page: custom sorting logic

4 participants