From d0f67d993507219cfa0824db8a3e59286f0ebf09 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Mon, 21 Aug 2023 01:41:37 +0000
Subject: [PATCH] move wss server start after http
---
quartz/plugins/transformers/links.ts | 29 ++++++++++++++++++++---------
1 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/quartz/plugins/transformers/links.ts b/quartz/plugins/transformers/links.ts
index d867039..d9c9c7c 100644
--- a/quartz/plugins/transformers/links.ts
+++ b/quartz/plugins/transformers/links.ts
@@ -1,11 +1,12 @@
import { QuartzTransformerPlugin } from "../types"
import {
- CanonicalSlug,
+ FullSlug,
RelativeURL,
+ SimpleSlug,
TransformOptions,
_stripSlashes,
- canonicalizeServer,
joinSegments,
+ simplifySlug,
splitAnchor,
transformLink,
} from "../../util/path"
@@ -33,8 +34,8 @@
return [
() => {
return (tree, file) => {
- const curSlug = canonicalizeServer(file.data.slug!)
- const outgoing: Set<CanonicalSlug> = new Set()
+ const curSlug = simplifySlug(file.data.slug!)
+ const outgoing: Set<SimpleSlug> = new Set()
const transformOptions: TransformOptions = {
strategy: opts.markdownLinkResolution,
@@ -54,10 +55,16 @@
// don't process external links or intra-document anchors
if (!(isAbsoluteUrl(dest) || dest.startsWith("#"))) {
- dest = node.properties.href = transformLink(curSlug, dest, transformOptions)
- const canonicalDest = path.posix.normalize(joinSegments(curSlug, dest))
+ dest = node.properties.href = transformLink(
+ file.data.slug!,
+ dest,
+ transformOptions,
+ )
+ const url = new URL(dest, `https://base.com/${curSlug}`)
+ const canonicalDest = url.pathname
const [destCanonical, _destAnchor] = splitAnchor(canonicalDest)
- outgoing.add(destCanonical as CanonicalSlug)
+ const simple = simplifySlug(destCanonical as FullSlug)
+ outgoing.add(simple)
}
// rewrite link internals if prettylinks is on
@@ -79,7 +86,11 @@
) {
if (!isAbsoluteUrl(node.properties.src)) {
let dest = node.properties.src as RelativeURL
- dest = node.properties.src = transformLink(curSlug, dest, transformOptions)
+ dest = node.properties.src = transformLink(
+ file.data.slug!,
+ dest,
+ transformOptions,
+ )
node.properties.src = dest
}
}
@@ -95,6 +106,6 @@
declare module "vfile" {
interface DataMap {
- links: CanonicalSlug[]
+ links: SimpleSlug[]
}
}
--
Gitblit v1.10.0