diff --git a/quartz/components/ContentMeta.tsx b/quartz/components/ContentMeta.tsx index e378bccee..a091a3f2c 100644 --- a/quartz/components/ContentMeta.tsx +++ b/quartz/components/ContentMeta.tsx @@ -29,8 +29,9 @@ export default ((opts?: Partial) => { if (text) { const segments: (string | JSX.Element)[] = [] - if (fileData.dates) { - segments.push() + const date = getDate(cfg, fileData) + if (date) { + segments.push() } // Display reading time if enabled diff --git a/quartz/components/PageList.tsx b/quartz/components/PageList.tsx index 33bd8d730..58b2a1c04 100644 --- a/quartz/components/PageList.tsx +++ b/quartz/components/PageList.tsx @@ -8,13 +8,15 @@ export type SortFn = (f1: QuartzPluginData, f2: QuartzPluginData) => number export function byDateAndAlphabetical(cfg: GlobalConfiguration): SortFn { return (f1, f2) => { - if (f1.dates && f2.dates) { + const f1Date = getDate(cfg, f1) + const f2Date = getDate(cfg, f2) + if (f1Date && f2Date) { // sort descending - return getDate(cfg, f2)!.toMillis() - getDate(cfg, f1)!.toMillis() - } else if (f1.dates && !f2.dates) { + return f2Date.toMillis() - f1Date.toMillis() + } else if (f1Date && !f2Date) { // prioritize files with dates return -1 - } else if (!f1.dates && f2.dates) { + } else if (!f1Date && f2Date) { return 1 } @@ -32,23 +34,19 @@ type Props = { 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) - } + const list = allFiles.toSorted(sorter).slice(0, limit ?? allFiles.length) return (