From d9e36e60d1e7a985f06fdfef152811074e7c0701 Mon Sep 17 00:00:00 2001
From: Anton Bulakh <him@necauq.ua>
Date: Mon, 30 Dec 2024 17:55:53 +0000
Subject: [PATCH] fix(search): Fix super-inconsistent preview widths in search previews (#1677)

---
 quartz/util/path.ts |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/quartz/util/path.ts b/quartz/util/path.ts
index dceb89b..a6a05f9 100644
--- a/quartz/util/path.ts
+++ b/quartz/util/path.ts
@@ -108,10 +108,10 @@
   el.setAttribute(attr, rebased.pathname + rebased.hash)
 }
 export function normalizeRelativeURLs(el: Element | Document, destination: string | URL) {
-  el.querySelectorAll('[href^="./"], [href^="../"]').forEach((item) =>
+  el.querySelectorAll('[href=""], [href^="./"], [href^="../"]').forEach((item) =>
     _rebaseHtmlElement(item, "href", destination),
   )
-  el.querySelectorAll('[src^="./"], [src^="../"]').forEach((item) =>
+  el.querySelectorAll('[src=""], [src^="./"], [src^="../"]').forEach((item) =>
     _rebaseHtmlElement(item, "src", destination),
   )
 }
@@ -168,6 +168,9 @@
 
 export function splitAnchor(link: string): [string, string] {
   let [fp, anchor] = link.split("#", 2)
+  if (fp.endsWith(".pdf")) {
+    return [fp, anchor === undefined ? "" : `#${anchor}`]
+  }
   anchor = anchor === undefined ? "" : "#" + slugAnchor(anchor)
   return [fp, anchor]
 }

--
Gitblit v1.10.0