Jacky Zhao
2023-07-24 e82ba97a396e4e9d77486b48e6ee8b1dfd1c1b4c
quartz/plugins/transformers/links.ts
@@ -29,7 +29,7 @@
  const opts = { ...defaultOptions, ...userOpts }
  return {
    name: "LinkProcessing",
    htmlPlugins() {
    htmlPlugins(ctx) {
      return [
        () => {
          return (tree, file) => {
@@ -40,11 +40,8 @@
              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
@@ -72,7 +69,8 @@
                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("#"))) {