Skip to content
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(content-blog): allow sorting posts in ascending order #5787

Merged
merged 4 commits into from
Nov 9, 2021

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.)

@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
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)

website/docs/api/plugins/plugin-content-blog.md Outdated Show resolved Hide resolved
packages/docusaurus-plugin-content-blog/src/types.ts Outdated Show resolved Hide resolved
@@ -59,6 +59,7 @@ Accepted fields:
| `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