The Trans Directory
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: openLinksInNewTab option for link transformer

+7
+1
quartz/components/scripts/spa.inline.ts
··· 20 20 21 21 const getOpts = ({ target }: Event): { url: URL; scroll?: boolean } | undefined => { 22 22 if (!isElement(target)) return 23 + if (target.attributes.getNamedItem("target")?.value === "_blank") return 23 24 const a = target.closest("a") 24 25 if (!a) return 25 26 if ("routerIgnore" in a.dataset) return
+6
quartz/plugins/transformers/links.ts
··· 18 18 markdownLinkResolution: TransformOptions["strategy"] 19 19 /** Strips folders from a link so that it looks nice */ 20 20 prettyLinks: boolean 21 + openLinksInNewTab: boolean 21 22 } 22 23 23 24 const defaultOptions: Options = { 24 25 markdownLinkResolution: "absolute", 25 26 prettyLinks: true, 27 + openLinksInNewTab: false, 26 28 } 27 29 28 30 export const CrawlLinks: QuartzTransformerPlugin<Partial<Options> | undefined> = (userOpts) => { ··· 51 53 let dest = node.properties.href as RelativeURL 52 54 node.properties.className ??= [] 53 55 node.properties.className.push(isAbsoluteUrl(dest) ? "external" : "internal") 56 + 57 + if (opts.openLinksInNewTab) { 58 + node.properties.target = "_blank" 59 + } 54 60 55 61 // don't process external links or intra-document anchors 56 62 const isInternal = !(isAbsoluteUrl(dest) || dest.startsWith("#"))