From 78f4cdbe109308fa33cb87387952aef5a528ebbe Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Sat, 19 Aug 2023 23:40:02 +0000
Subject: [PATCH] avoid 404 on icon for spa navigations with anchors
---
quartz/components/pages/TagContent.tsx | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/quartz/components/pages/TagContent.tsx b/quartz/components/pages/TagContent.tsx
index 2a9dfca..7b3a582 100644
--- a/quartz/components/pages/TagContent.tsx
+++ b/quartz/components/pages/TagContent.tsx
@@ -3,7 +3,7 @@
import { toJsxRuntime } from "hast-util-to-jsx-runtime"
import style from "../styles/listPage.scss"
import { PageList } from "../PageList"
-import { ServerSlug, canonicalizeServer, getAllSegmentPrefixes } from "../../path"
+import { FullSlug, getAllSegmentPrefixes, simplifySlug } from "../../util/path"
import { QuartzPluginData } from "../../plugins/vfile"
const numPages = 10
@@ -11,11 +11,11 @@
const { tree, fileData, allFiles } = props
const slug = fileData.slug
- if (!slug?.startsWith("tags/")) {
+ if (!(slug?.startsWith("tags/") || slug === "tags")) {
throw new Error(`Component "TagContent" tried to render a non-tag page: ${slug}`)
}
- const tag = canonicalizeServer(slug.slice("tags/".length) as ServerSlug)
+ const tag = simplifySlug(slug.slice("tags/".length) as FullSlug)
const allPagesWithTag = (tag: string) =>
allFiles.filter((file) =>
(file.frontmatter?.tags ?? []).flatMap(getAllSegmentPrefixes).includes(tag),
@@ -44,11 +44,14 @@
return (
<div>
<h2>
- <a class="internal tag-link" href={`./tags/${tag}`}>
+ <a class="internal tag-link" href={`./${tag}`}>
#{tag}
</a>
</h2>
- <p>{pages.length} items with this tag. {pages.length > numPages && `Showing first ${numPages}.`}</p>
+ <p>
+ {pages.length} items with this tag.{" "}
+ {pages.length > numPages && `Showing first ${numPages}.`}
+ </p>
<PageList limit={numPages} {...listProps} />
</div>
)
--
Gitblit v1.10.0