From fdf1e2a41d079c4f2d1f3df7c297fa0d92a18cc9 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Thu, 03 Aug 2023 06:29:28 +0000
Subject: [PATCH] use checkout for pulling updates
---
quartz/plugins/transformers/links.ts | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/quartz/plugins/transformers/links.ts b/quartz/plugins/transformers/links.ts
index 96c5f58..0765062 100644
--- a/quartz/plugins/transformers/links.ts
+++ b/quartz/plugins/transformers/links.ts
@@ -29,7 +29,7 @@
const opts = { ...defaultOptions, ...userOpts }
return {
name: "LinkProcessing",
- htmlPlugins() {
+ htmlPlugins(ctx) {
return [
() => {
return (tree, file) => {
@@ -40,16 +40,14 @@
if (opts.markdownLinkResolution === "relative") {
return targetSlug as RelativeURL
} else if (opts.markdownLinkResolution === "shortest") {
- // https://forum.obsidian.md/t/settings-new-link-format-what-is-shortest-path-when-possible/6748/5
- const allSlugs = file.data.allSlugs!
-
// if the file name is unique, then it's just the filename
- const matchingFileNames = allSlugs.filter((slug) => {
+ const matchingFileNames = ctx.allSlugs.filter((slug) => {
const parts = slug.split(path.posix.sep)
const fileName = parts.at(-1)
return targetCanonical === fileName
})
+ // only match, just use it
if (matchingFileNames.length === 1) {
const targetSlug = canonicalizeServer(matchingFileNames[0])
return (resolveRelative(curSlug, targetSlug) + targetAnchor) as RelativeURL
@@ -72,12 +70,13 @@
typeof node.properties.href === "string"
) {
let dest = node.properties.href as RelativeURL
- node.properties.className = isAbsoluteUrl(dest) ? "external" : "internal"
+ node.properties.className ??= []
+ node.properties.className.push(isAbsoluteUrl(dest) ? "external" : "internal")
// don't process external links or intra-document anchors
if (!(isAbsoluteUrl(dest) || dest.startsWith("#"))) {
dest = node.properties.href = transformLink(dest)
- const canonicalDest = path.normalize(joinSegments(curSlug, dest))
+ const canonicalDest = path.posix.normalize(joinSegments(curSlug, dest))
const [destCanonical, _destAnchor] = splitAnchor(canonicalDest)
outgoing.add(destCanonical as CanonicalSlug)
}
@@ -101,7 +100,7 @@
if (!isAbsoluteUrl(node.properties.src)) {
const ext = path.extname(node.properties.src)
node.properties.src =
- transformLink(path.join("assets", node.properties.src)) + ext
+ transformLink(joinSegments("assets", node.properties.src)) + ext
}
}
})
--
Gitblit v1.10.0