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/PageList.tsx | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/quartz/components/PageList.tsx b/quartz/components/PageList.tsx
index 8ef40c5..d7aca08 100644
--- a/quartz/components/PageList.tsx
+++ b/quartz/components/PageList.tsx
@@ -1,4 +1,4 @@
-import { CanonicalSlug, canonicalizeServer, resolveRelative } from "../path"
+import { FullSlug, resolveRelative } from "../util/path"
import { QuartzPluginData } from "../plugins/vfile"
import { Date } from "./Date"
import { QuartzComponentProps } from "./types"
@@ -20,13 +20,20 @@
return f1Title.localeCompare(f2Title)
}
-export function PageList({ fileData, allFiles }: QuartzComponentProps) {
- const slug = canonicalizeServer(fileData.slug!)
+type Props = {
+ limit?: number
+} & QuartzComponentProps
+
+export function PageList({ fileData, allFiles, limit }: Props) {
+ let list = allFiles.sort(byDateAndAlphabetical)
+ if (limit) {
+ list = list.slice(0, limit)
+ }
+
return (
<ul class="section-ul">
- {allFiles.sort(byDateAndAlphabetical).map((page) => {
+ {list.map((page) => {
const title = page.frontmatter?.title
- const pageSlug = canonicalizeServer(page.slug!)
const tags = page.frontmatter?.tags ?? []
return (
@@ -39,7 +46,7 @@
)}
<div class="desc">
<h3>
- <a href={resolveRelative(slug, pageSlug)} class="internal">
+ <a href={resolveRelative(fileData.slug!, page.slug!)} class="internal">
{title}
</a>
</h3>
@@ -49,7 +56,7 @@
<li>
<a
class="internal tag-link"
- href={resolveRelative(slug, `tags/${tag}` as CanonicalSlug)}
+ href={resolveRelative(fileData.slug!, `tags/${tag}` as FullSlug)}
>
#{tag}
</a>
--
Gitblit v1.10.0