From 4c336b5fe9af6d467d32a6a9d505c204fa16140a Mon Sep 17 00:00:00 2001 From: top <37973461+zelestis@users.noreply.github.com> Date: Thu, 26 Dec 2024 15:17:41 +0800 Subject: [PATCH] Add https://github.com/jackyzha0/quartz/pull/1471 --- quartz.config.ts | 2 +- quartz.layout.ts | 4 +- quartz/components/Explorer.tsx | 50 ++++-- quartz/components/scripts/explorer.inline.ts | 152 ++++++++++++----- quartz/components/styles/explorer.scss | 165 +++++++++++++++++-- 5 files changed, 308 insertions(+), 65 deletions(-) diff --git a/quartz.config.ts b/quartz.config.ts index 8ee10564..dd067e32 100644 --- a/quartz.config.ts +++ b/quartz.config.ts @@ -8,7 +8,7 @@ import * as Plugin from "./quartz/plugins" */ const config: QuartzConfig = { configuration: { - pageTitle: "zelestis", + pageTitle: "zelestis 🟪", pageTitleSuffix: "", enableSPA: true, enablePopovers: true, diff --git a/quartz.layout.ts b/quartz.layout.ts index 4a78256a..f45da0c9 100644 --- a/quartz.layout.ts +++ b/quartz.layout.ts @@ -27,7 +27,7 @@ export const defaultContentPageLayout: PageLayout = { Component.MobileOnly(Component.Spacer()), Component.Search(), Component.Darkmode(), - Component.DesktopOnly(Component.Explorer()), + Component.Explorer(), ], right: [ Component.Graph(), @@ -44,7 +44,7 @@ export const defaultListPageLayout: PageLayout = { Component.MobileOnly(Component.Spacer()), Component.Search(), Component.Darkmode(), - Component.DesktopOnly(Component.Explorer()), + Component.Explorer(), ], right: [], } diff --git a/quartz/components/Explorer.tsx b/quartz/components/Explorer.tsx index ec7c48ef..b71a0966 100644 --- a/quartz/components/Explorer.tsx +++ b/quartz/components/Explorer.tsx @@ -46,7 +46,7 @@ export default ((userOpts?: Partial) => { let jsonTree: string let lastBuildId: string = "" - function constructFileTree(allFiles: QuartzPluginData[]) { + function constructFileTree(allFiles: QuartzPluginData[], currentFilePath: string) { // Construct tree from allFiles fileTree = new FileNode("") allFiles.forEach((file) => fileTree.add(file)) @@ -73,28 +73,56 @@ export default ((userOpts?: Partial) => { } const Explorer: QuartzComponent = ({ - ctx, - cfg, - allFiles, - displayClass, - fileData, - }: QuartzComponentProps) => { + ctx, + cfg, + allFiles, + displayClass, + fileData, + }: QuartzComponentProps) => { if (ctx.buildId !== lastBuildId) { lastBuildId = ctx.buildId - constructFileTree(allFiles) + constructFileTree(allFiles, (fileData.filePath ?? "").replaceAll(" ", "-")) } - return (
+