jamestagal / edtechdesigner

A professional blog site of Benjamin Waller
https://edtechdesigner.io
0 stars 1 forks source link

Sort Posts (Projects) alphabetically by name #25

Closed jamestagal closed 2 years ago

jamestagal commented 2 years ago

Hello @roobyz

I have a question about sorting my Posts (your Projects) alphabetically. Actually at present I am a little confused about how this grouping is shorted...it doesn't seem to be either by date or alphabetically. See Posts page.
I think it would make sense to sort the groupings by name alphabetically because when there are a number of different posts in this grouping they would have different dates.

And I can see that the list of posts on the home page, is sorted by date, newest first which is fine and makes sense.

In projs.svelte below it looks to be sorted alphabetical by name how can I sort the project alphabetically instead of sorting the posts within the projects alphabetically ?

    // What: sort the posts within the projects
    if (projsSort == "Date") {
      // Sort projects posts alphabetically by name
      group.sort((a, b) => {
        return a.path.localeCompare(b.path);
      });
    } else {
      // Sort projects posts by newest first
      group.sort((a, b) => {
        return new Date(b.modified) - new Date(a.modified);
      });
    }

I hope that I am making sense. Regards, Ben

roobyz commented 2 years ago

Hi @jamestagal

I added a new key to index.json, so that the sort approach is configurable:

    "projsSort": "Date",
    "projsSortValues": "Date, Name",

This value is read by the projs.svelte component. Which then:

  1. creates a list of "postsGroup"
  2. then sorts the postsGroup
  3. then sorts the posts within the postsGroup.

The default value is set to "Date", which sorts the postsGroup by most recently updated post in a postsGroup. Then it sorts the posts within the postsGroup by name, since they are logically related in my case.

If you set it to "Name", then it should sort the postsGroup alphabetically by name and then sort the posts within a postsGroup by date. That way the most recent posts will be first within a group.

Cheers, Roberto

jamestagal commented 2 years ago

Hi @roobyz Thank you for that clear explanation. It worked as expected; changing the value to 'Name' for "projsSort" in index.json did the trick! It sorted the postsGroup alphabetically by name and then the posts within it by date! You are a champion.

I appreciate your help with this Roberto. 👍

Best regards, Ben

roobyz commented 2 years ago

hi @jamestagal

FYI, I pushed a large commit on the theme. It includes some big changes including some refactors, and bug fixes. In addition, it has a complete README file that hopefully you'll find helpful. I would recommend you pull that update, even though you'll likely need to make adjustments to your site. The key updates are the bug fixes for some HTML5 layout and WAI-ARIA issues.

That said, after this update the only other big thing I'm planning to do is the DailyUI theme refactor, which you could pass on if you are happy where you land.

Cheers, Roberto

roobyz commented 2 years ago

hi @jamestagal ... Jim caught a pagination bug, which I just fixed. Did a refactor on baseurl to make it obvious what is going on.

Cheers, Roberto

jamestagal commented 2 years ago

Hi @roobyz Thanks for the heads up. I have pulled your latest commit and working through refactoring it now.

One observation looking at your package.json file is that it lists your blog "Quantified Leap" instead of "Compendium Theme" with a different version number. When I copy over the content of this file, can i just ignore the "name" and "version" ?

Cheers, Ben

roobyz commented 2 years ago

Thanks for catching that @jamestagal ... it should be "compendium-theme". I do update the version number as I get closer to completion. That said, it shouldn't impact you other than you may need to refactor on major changes. ;-)

jamestagal commented 2 years ago

No worries...Yes I have 38 more files to look through!! But there are a few files i can ignore and just commit because I haven't modified but unfortunately I have modified quite a few files now so the refactoring is not straight forward. But in saying that I am getting heaps of practice modifying and updating my code and pushing and pulling to git etc...sounds like fun!!

I do appreciate your constant work on your theme as it just makes it better and better...BTW I really like your readme file...I do see some of the advanced stuff such as Cloudflare Functions I need to understand more but slowly but surely I will get there.. Cheers, Ben

roobyz commented 2 years ago

@jamestagal ... thanks for keeping up the sense of humor. ;-) Please let me know if there is anything that sounds confusing or is missing on the REAME. It often is the case that when you are really close to something the little things get missed.

Cheers, Roberto