From 8d6029b7b844044d06fe17de89db6881954a8fec Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Thu, 07 Sep 2023 04:02:21 +0000
Subject: [PATCH] feat: 404 page emitter
---
quartz/plugins/transformers/links.ts | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/quartz/plugins/transformers/links.ts b/quartz/plugins/transformers/links.ts
index f8da36c..475a5e9 100644
--- a/quartz/plugins/transformers/links.ts
+++ b/quartz/plugins/transformers/links.ts
@@ -54,7 +54,8 @@
node.properties.className.push(isAbsoluteUrl(dest) ? "external" : "internal")
// don't process external links or intra-document anchors
- if (!(isAbsoluteUrl(dest) || dest.startsWith("#"))) {
+ const isInternal = !(isAbsoluteUrl(dest) || dest.startsWith("#"))
+ if (isInternal) {
dest = node.properties.href = transformLink(
file.data.slug!,
dest,
@@ -63,7 +64,7 @@
// url.resolve is considered legacy
// WHATWG equivalent https://nodejs.dev/en/api/v18/url/#urlresolvefrom-to
- const url = new URL(dest, `resolve://${curSlug}`)
+ const url = new URL(dest, `https://base.com/${curSlug}`)
const canonicalDest = url.pathname
const [destCanonical, _destAnchor] = splitAnchor(canonicalDest)
@@ -77,6 +78,7 @@
// rewrite link internals if prettylinks is on
if (
opts.prettyLinks &&
+ isInternal &&
node.children.length === 1 &&
node.children[0].type === "text" &&
!node.children[0].value.startsWith("#")
--
Gitblit v1.10.0