Cao Mingjun
2024-07-10 ea92ed4f45e6e863a432447a977c33c6319423bc
quartz/components/PageList.tsx
@@ -1,7 +1,7 @@
import { FullSlug, resolveRelative } from "../util/path"
import { QuartzPluginData } from "../plugins/vfile"
import { Date, getDate } from "./Date"
import { QuartzComponentProps } from "./types"
import { QuartzComponent, QuartzComponentProps } from "./types"
import { GlobalConfiguration } from "../cfg"
export function byDateAndAlphabetical(
@@ -27,10 +27,12 @@
type Props = {
  limit?: number
  sort?: (f1: QuartzPluginData, f2: QuartzPluginData) => number
} & QuartzComponentProps
export function PageList({ 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)
  }
@@ -63,7 +65,7 @@
                      class="internal tag-link"
                      href={resolveRelative(fileData.slug!, `tags/${tag}` as FullSlug)}
                    >
                      #{tag}
                      {tag}
                    </a>
                  </li>
                ))}