-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
I tried below code to sort the Explorer items by markdown file modified date. But the sorting is still by default alphabetical order.
To Reproduce
Steps to reproduce the behavior:
- Go to
quartz.layout.ts - Add below code to
Component.Explorer({})block to sort the markdown files by file modified date.
Component.Explorer({
sortFn: (a, b) => {
// 1. Sort folders before files
if (a.isFolder && !b.isFolder) return -1;
if (!a.isFolder && b.isFolder) return 1;
// 2. Sort by date if both are files
if (a.data?.frontmatter?.date && b.data?.frontmatter?.date) {
const dateA = new Date(a.data.frontmatter.date);
const dateB = new Date(b.data.frontmatter.date);
// Use (dateB - dateA) for newest first, or (dateA - dateB) for oldest first
return dateB.getTime() - dateA.getTime();
}
const d1 = new Date(a.dates?.created ?? 0).getTime()
const d2 = new Date(a.dates?.created ?? 0).getTime()
return d2 - d1
// 3. Fallback to alphabetical if date is missing or items are folders
return a.displayName.localeCompare(b.displayName, undefined, {
numeric: true,
sensitivity: "base",
});
},
}),- Have similar
frontmatterin the posts
---
title: My Post Title
date: 2025-12-10 11:58:47 +00:00
tags:
- tech
---
What to expect
Build the website and see if Explorer shows the items in the expected order.
What is happening
The markdown files still shows in Explorer in alphabetical order.
Desktop (please complete the following information):
- Quartz Version: v4.1.2
nodeVersion: v24.10.0npmversion: 11.6.0- OS: macOS
- Browser: chrome, safari, brave, firefox
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working