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

My bad needed a more in depth fix #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

versecafe
Copy link
Contributor

was originally sorting off unknown fetch order, which appears to have been the URL path string, now it reorders the data off the version in:

const { data } = await useAsyncData("feed", () =>
  queryContent("/posts").find()
);
const sorted_data = data.value.sort((a, b) => {
  const a_version = a.version.split('.').map(Number);
  const b_version = b.version.split('.').map(Number);
  const max_length = Math.max(a_version.length, b_version.length);
  for (let i = 0; i < max_length; i++) {
    const a_part = a_version[i] || 0;
    const b_part = b_version[i] || 0;
    if (a_part < b_part) {
      return 1;
    } else if (a_part > b_part) {
      return -1;
    }
  }
  return 0;
});

Example Image

image

I did test that this works as you continue up in versions, it will not work for things like .10 but sorting by date does not

Copy link

vercel bot commented Nov 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
logspot ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2023 4:12am

Copy link

netlify bot commented Nov 27, 2023

Deploy Preview for logspot ready!

Name Link
🔨 Latest commit 8a1aadb
🔍 Latest deploy log https://app.netlify.com/sites/logspot/deploys/65641705b3f46a000858576a
😎 Deploy Preview https://deploy-preview-3--logspot.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@versecafe
Copy link
Contributor Author

finally proper support for every weird x.y.z combo such as 3.0.21, 3.0.4, 0.19.0, 0.1.4

Copy link

@Solyxnh Solyxnh left a comment

Choose a reason for hiding this comment

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

Looks good, I could deploy it and it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants