Issue: Last modified sort in media library #160

Closed
opened 2026-10-05 02:30:36 +02:00 by adam · 6 comments
Owner

Change the last modified sort option and get a different list of files each time.

See the video example here: https://youtu.be/Xp7wyLXxUXk

Expected behavior

Files should sort correctly by modified date.

Desktop (please complete the following information):

  • OS: Win 11
  • Browser: Chrome
  • Version: Version 96.0.4664.45 (Official Build) (64-bit)
Change the last modified sort option and get a different list of files each time. See the video example here: https://youtu.be/Xp7wyLXxUXk **Expected behavior** Files should sort correctly by modified date. **Desktop (please complete the following information):** - OS: Win 11 - Browser: Chrome - Version: Version 96.0.4664.45 (Official Build) (64-bit) <!-- github-sync-id:1069976470 -->
adam closed this issue 2026-10-05 02:30:36 +02:00
Author
Owner

Interesting, this is based on the modified timestamp on each document. I'll check if I can reproduce it. Also saw a styling issue during your video, so will add that as a bug to the list.

Interesting, this is based on the modified timestamp on each document. I'll check if I can reproduce it. Also saw a styling issue during your video, so will add that as a bug to the list. <!-- github-comment-id:985295733 -->
Author
Owner

A fix got implemented which sorts the files with the same modified date on file name as a secondary sorting option. I tested it in my projects, @zivbk1 can you check if the experience is better on your end as well?

A fix got implemented which sorts the files with the same modified date on file name as a secondary sorting option. I tested it in my projects, @zivbk1 can you check if the experience is better on your end as well? <!-- github-comment-id:986219113 -->
Author
Owner

A fix got implemented which sorts the files with the same modified date on file name as a secondary sorting option. I tested it in my projects, @zivbk1 can you check if the experience is better on your end as well?

Sorry for not getting a chance to test it until now. I know the issue here is already closed, but I have some questions.
On my site, the filename and last modified sorts are the same now. Is there data for the files that can be used to determine the date the file was last modified or added to the repo?

> A fix got implemented which sorts the files with the same modified date on file name as a secondary sorting option. I tested it in my projects, @zivbk1 can you check if the experience is better on your end as well? Sorry for not getting a chance to test it until now. I know the issue here is already closed, but I have some questions. On my site, the filename and last modified sorts are the same now. Is there data for the files that can be used to determine the date the file was last modified or added to the repo? <!-- github-comment-id:988086130 -->
Author
Owner

@zivbk1 in that case, I think it might be because of how GitPod works. Probably it checks out the project each time you load it, meaning, the modified date will be the same for all files. This would explain the behavior.

@zivbk1 in that case, I think it might be because of how GitPod works. Probably it checks out the project each time you load it, meaning, the modified date will be the same for all files. This would explain the behavior. <!-- github-comment-id:988206326 -->
Author
Owner

@estruyf you are correct, all the dates in the files are at the day/time the file was cloned from the repo. To fix that I added the following commands to my GitPod.io startup tasks (for a Hugo site).

tasks:
  - name: Install Hugo and Dependencies
    before: brew install hugo && npm install && sudo apt install git-restore-mtime
    init: git restore-mtime --force && gpUrl=$(gp url 1313);jq --arg gpurl "$gpUrl" '.["frontMatter.preview.host"] = $gpurl' frontmatter.json > tmp.$$.json && mv tmp.$$.json frontmatter.json
    command: hugo server -D -F --baseUrl $(gp url 1313) --liveReloadPort=443 --appendPort=false --bind=0.0.0.0
ports:
  - port: 1313
    onOpen: open-browser

sudo apt install git-restore-mtime in the 'before' step, adds a utility to modify folder/file dates based on their last commit to the repo.

git restore-mtime --force in the 'init' step modifies all the files and folders based on commit history.

Now when the repo is cloned fresh into a new GitPod workspace, the modified date sorting works as expected.

@estruyf you are correct, all the dates in the files are at the day/time the file was cloned from the repo. To fix that I added the following commands to my GitPod.io startup tasks (for a Hugo site). ``` tasks: - name: Install Hugo and Dependencies before: brew install hugo && npm install && sudo apt install git-restore-mtime init: git restore-mtime --force && gpUrl=$(gp url 1313);jq --arg gpurl "$gpUrl" '.["frontMatter.preview.host"] = $gpurl' frontmatter.json > tmp.$$.json && mv tmp.$$.json frontmatter.json command: hugo server -D -F --baseUrl $(gp url 1313) --liveReloadPort=443 --appendPort=false --bind=0.0.0.0 ports: - port: 1313 onOpen: open-browser ``` ` sudo apt install git-restore-mtime` in the 'before' step, adds a utility to modify folder/file dates based on their last commit to the repo. `git restore-mtime --force` in the 'init' step modifies all the files and folders based on commit history. Now when the repo is cloned fresh into a new GitPod workspace, the modified date sorting works as expected. <!-- github-comment-id:988271655 -->
Author
Owner

Oh, nice you found a way to overcome this @zivbk1 ❤️

Oh, nice you found a way to overcome this @zivbk1 ❤️ <!-- github-comment-id:988750010 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#160