From 16d33fb77193710bede887d6a177d2144b78fb67 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Wed, 20 Sep 2023 23:08:54 +0000
Subject: [PATCH] feat: display name for folders, expand explorer a little bit (#489)
---
quartz/components/Explorer.tsx | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/quartz/components/Explorer.tsx b/quartz/components/Explorer.tsx
index 346bd75..73c620f 100644
--- a/quartz/components/Explorer.tsx
+++ b/quartz/components/Explorer.tsx
@@ -6,15 +6,15 @@
import { ExplorerNode, FileNode, Options } from "./ExplorerNode"
// Options interface defined in `ExplorerNode` to avoid circular dependency
-const defaultOptions = (): Options => ({
+const defaultOptions = {
title: "Explorer",
folderClickBehavior: "collapse",
folderDefaultState: "collapsed",
useSavedState: true,
- // Sort order: folders first, then files. Sort folders and files alphabetically
sortFn: (a, b) => {
+ // Sort order: folders first, then files. Sort folders and files alphabetically
if ((!a.file && !b.file) || (a.file && b.file)) {
- return a.name.localeCompare(b.name)
+ return a.displayName.localeCompare(b.displayName)
}
if (a.file && !b.file) {
return 1
@@ -22,12 +22,14 @@
return -1
}
},
+ filterFn: (node) => node.name !== "tags",
order: ["filter", "map", "sort"],
-})
+} satisfies Options
+
export default ((userOpts?: Partial<Options>) => {
function Explorer({ allFiles, displayClass, fileData }: QuartzComponentProps) {
// Parse config
- const opts: Options = { ...defaultOptions(), ...userOpts }
+ const opts: Options = { ...defaultOptions, ...userOpts }
// Construct tree from allFiles
const fileTree = new FileNode("")
@@ -78,7 +80,7 @@
data-savestate={opts.useSavedState}
data-tree={jsonTree}
>
- <h3>{opts.title}</h3>
+ <h1>{opts.title}</h1>
<svg
xmlns="http://www.w3.org/2000/svg"
width="14"
@@ -95,8 +97,9 @@
</svg>
</button>
<div id="explorer-content">
- <ul class="overflow">
+ <ul class="overflow" id="explorer-ul">
<ExplorerNode node={fileTree} opts={opts} fileData={fileData} />
+ <li id="explorer-end" />
</ul>
</div>
</div>
--
Gitblit v1.10.0