From 2d7793062bef0eeedb360267278f75f16f65a764 Mon Sep 17 00:00:00 2001 From: Aaron Pham Date: Fri, 30 Jan 2026 02:32:37 -0500 Subject: [PATCH] fix: type error Signed-off-by: Aaron Pham --- quartz/components/BaseViewSelector.tsx | 8 ++++---- quartz/components/pages/BaseContent.tsx | 4 +--- .../scripts/base-view-selector.inline.ts | 15 ++++++++++----- quartz/components/styles/baseViewSelector.scss | 4 +++- quartz/processors/parse.ts | 4 +++- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/quartz/components/BaseViewSelector.tsx b/quartz/components/BaseViewSelector.tsx index ab1b11ee3..6a54363d7 100644 --- a/quartz/components/BaseViewSelector.tsx +++ b/quartz/components/BaseViewSelector.tsx @@ -1,3 +1,4 @@ +import { JSX } from "preact" import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types" import { classNames } from "../util/lang" import { resolveRelative } from "../util/path" @@ -5,7 +6,7 @@ import { resolveRelative } from "../util/path" import script from "./scripts/base-view-selector.inline" import baseViewSelectorStyle from "./styles/baseViewSelector.scss" -const icons = { +const icons: Record = { table: ( = { +const viewTypeIcons: Record = { table: icons.table, list: icons.list, gallery: icons.card, @@ -147,8 +148,7 @@ const BaseViewSelector: QuartzComponent = ({ fileData, displayClass }: QuartzCom const currentViewName = baseMeta.currentView const allViews = baseMeta.allViews const currentIcon = - viewTypeIcons[allViews.find((view) => view.name === currentViewName)?.type ?? ""] ?? - icons.table + viewTypeIcons[allViews.find((view) => view.name === currentViewName)?.type ?? ""] ?? icons.table return (
diff --git a/quartz/components/pages/BaseContent.tsx b/quartz/components/pages/BaseContent.tsx index d42687732..644be3138 100644 --- a/quartz/components/pages/BaseContent.tsx +++ b/quartz/components/pages/BaseContent.tsx @@ -8,9 +8,7 @@ export default (() => { return (
-
+
{htmlToJsx(fileData.filePath!, fileData.basesRenderedTree ?? tree)}
diff --git a/quartz/components/scripts/base-view-selector.inline.ts b/quartz/components/scripts/base-view-selector.inline.ts index eddeb57c6..1c81c67ac 100644 --- a/quartz/components/scripts/base-view-selector.inline.ts +++ b/quartz/components/scripts/base-view-selector.inline.ts @@ -28,12 +28,17 @@ function setupBaseViewSelector() { if (selector.hasAttribute("data-initialized")) return selector.setAttribute("data-initialized", "true") - const trigger = selector.querySelector(".text-icon-button") as HTMLElement | null - const searchInput = selector.querySelector("[data-search-input]") as HTMLInputElement | null - const clearButton = selector.querySelector("[data-clear-search]") as HTMLElement | null - const viewList = selector.querySelector("[data-view-list]") as HTMLElement | null + const triggerEl = selector.querySelector(".text-icon-button") as HTMLElement | null + const searchInputEl = selector.querySelector("[data-search-input]") as HTMLInputElement | null + const clearButtonEl = selector.querySelector("[data-clear-search]") as HTMLElement | null + const viewListEl = selector.querySelector("[data-view-list]") as HTMLElement | null - if (!trigger || !searchInput || !clearButton || !viewList) return + if (!triggerEl || !searchInputEl || !clearButtonEl || !viewListEl) return + + const trigger = triggerEl + const searchInput = searchInputEl + const clearButton = clearButtonEl + const viewList = viewListEl function toggleDropdown() { if (trigger.getAttribute("aria-expanded") === "true") { diff --git a/quartz/components/styles/baseViewSelector.scss b/quartz/components/styles/baseViewSelector.scss index 2cb0ee265..d8f3cc668 100644 --- a/quartz/components/styles/baseViewSelector.scss +++ b/quartz/components/styles/baseViewSelector.scss @@ -73,7 +73,9 @@ background: var(--light); border: 1px solid var(--lightgray); border-radius: 8px; - box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); + box-shadow: + 0 4px 6px -1px rgb(0 0 0 / 0.1), + 0 2px 4px -2px rgb(0 0 0 / 0.1); overflow: hidden; min-width: 280px; display: none; diff --git a/quartz/processors/parse.ts b/quartz/processors/parse.ts index 2070bdd94..a1eab7e54 100644 --- a/quartz/processors/parse.ts +++ b/quartz/processors/parse.ts @@ -111,7 +111,9 @@ export function createFileParser(ctx: BuildCtx, fps: FilePath[]) { res.push([newAst, file]) if (argv.verbose) { - console.log(`[${isBaseFile ? "base" : "markdown"}] ${fp} -> ${file.data.slug} (${perf.timeSince()})`) + console.log( + `[${isBaseFile ? "base" : "markdown"}] ${fp} -> ${file.data.slug} (${perf.timeSince()})`, + ) } } catch (err) { trace(`\nFailed to process markdown \`${fp}\``, err as Error)