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/pages/FolderContent.tsx | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/quartz/components/pages/FolderContent.tsx b/quartz/components/pages/FolderContent.tsx
index d3f28dd..e01496c 100644
--- a/quartz/components/pages/FolderContent.tsx
+++ b/quartz/components/pages/FolderContent.tsx
@@ -1,4 +1,4 @@
-import { QuartzComponentConstructor, QuartzComponentProps } from "../types"
+import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "../types"
import path from "path"
import style from "../styles/listPage.scss"
@@ -7,12 +7,14 @@
import { Root } from "hast"
import { htmlToJsx } from "../../util/jsx"
import { i18n } from "../../i18n"
+import { QuartzPluginData } from "../../plugins/vfile"
interface FolderContentOptions {
/**
* Whether to display number of folders
*/
showFolderCount: boolean
+ sort?: (f1: QuartzPluginData, f2: QuartzPluginData) => number
}
const defaultOptions: FolderContentOptions = {
@@ -22,7 +24,7 @@
export default ((opts?: Partial<FolderContentOptions>) => {
const options: FolderContentOptions = { ...defaultOptions, ...opts }
- function FolderContent(props: QuartzComponentProps) {
+ const FolderContent: QuartzComponent = (props: QuartzComponentProps) => {
const { tree, fileData, allFiles, cfg } = props
const folderSlug = stripSlashes(simplifySlug(fileData.slug!))
const allPagesInFolder = allFiles.filter((file) => {
@@ -37,6 +39,7 @@
const classes = ["popover-hint", ...cssClasses].join(" ")
const listProps = {
...props,
+ sort: options.sort,
allFiles: allPagesInFolder,
}
@@ -47,9 +50,7 @@
return (
<div class={classes}>
- <article>
- <p>{content}</p>
- </article>
+ <article>{content}</article>
<div class="page-listing">
{options.showFolderCount && (
<p>
--
Gitblit v1.10.0