feat: Allow custom sorting of FolderPage and TagPage ()

This commit is contained in:
Cao Mingjun 2024-07-10 08:42:33 +08:00 committed by GitHub
parent 596e06ab0e
commit ea92ed4f45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 116 additions and 105 deletions
quartz/components

View file

@ -27,10 +27,12 @@ export function byDateAndAlphabetical(
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)
}