Jacky Zhao
2023-08-07 028bcec62c3ca019a96783f17eaee1ecce6e092b
quartz/plugins/transformers/links.ts
@@ -2,6 +2,7 @@
import {
  CanonicalSlug,
  RelativeURL,
  _stripSlashes,
  canonicalizeServer,
  joinSegments,
  pathToRoot,
@@ -35,7 +36,7 @@
          return (tree, file) => {
            const curSlug = canonicalizeServer(file.data.slug!)
            const transformLink = (target: string): RelativeURL => {
              const targetSlug = transformInternalLink(target).slice("./".length)
              const targetSlug = _stripSlashes(transformInternalLink(target).slice(".".length))
              let [targetCanonical, targetAnchor] = splitAnchor(targetSlug)
              if (opts.markdownLinkResolution === "relative") {
                return targetSlug as RelativeURL
@@ -76,7 +77,7 @@
                // 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)
                }