From 790885a586c115ca34ba078023079dddaa3f2a88 Mon Sep 17 00:00:00 2001 From: Greg Brimble Date: Thu, 20 Mar 2025 15:18:41 -0400 Subject: [PATCH] Don't add arrow to external image links --- src/plugins/rehype/external-links.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/plugins/rehype/external-links.ts b/src/plugins/rehype/external-links.ts index 68039f18f0fc919..8f143717620c8b2 100644 --- a/src/plugins/rehype/external-links.ts +++ b/src/plugins/rehype/external-links.ts @@ -1,9 +1,19 @@ import rehypeExternalLinks, { type Options } from "rehype-external-links"; export const rehypeExternalLinksOptions = { - content: { - type: "text", - value: " ↗", + content: (element) => { + if ( + element.children.length === 1 && + element.children[0].type === "element" && + element.children[0].tagName === "img" + ) { + return; + } + + return { + type: "text", + value: " ↗", + }; }, contentProperties: { class: "external-link",