mirror of
https://github.com/alrayyes/wiki.git
synced 2025-05-19 22:29:16 +00:00
feat: Allow custom sorting of FolderPage and TagPage (#1250)
This commit is contained in:
parent
596e06ab0e
commit
ea92ed4f45
5 changed files with 116 additions and 105 deletions
quartz/components
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue