From ea92ed4f45e6e863a432447a977c33c6319423bc Mon Sep 17 00:00:00 2001
From: Cao Mingjun <me@caomingjun.com>
Date: Wed, 10 Jul 2024 00:42:33 +0000
Subject: [PATCH] feat: Allow custom sorting of FolderPage and TagPage (#1250)

---
 quartz/components/PageList.tsx |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/quartz/components/PageList.tsx b/quartz/components/PageList.tsx
index 1e5d232..2512b62 100644
--- a/quartz/components/PageList.tsx
+++ b/quartz/components/PageList.tsx
@@ -27,10 +27,12 @@
 
 type Props = {
   limit?: number
+  sort?: (f1: QuartzPluginData, f2: QuartzPluginData) => number
 } & QuartzComponentProps
 
-export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit }: Props) => {
-  let list = allFiles.sort(byDateAndAlphabetical(cfg))
+export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit, sort }: Props) => {
+  const sorter = sort ?? byDateAndAlphabetical(cfg)
+  let list = allFiles.sort(sorter)
   if (limit) {
     list = list.slice(0, limit)
   }

--
Gitblit v1.10.0