Skip to content

Commit 790885a

Browse files
committed
Don't add arrow to external image links
1 parent ac90759 commit 790885a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/plugins/rehype/external-links.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
import rehypeExternalLinks, { type Options } from "rehype-external-links";
22

33
export const rehypeExternalLinksOptions = {
4-
content: {
5-
type: "text",
6-
value: " ↗",
4+
content: (element) => {
5+
if (
6+
element.children.length === 1 &&
7+
element.children[0].type === "element" &&
8+
element.children[0].tagName === "img"
9+
) {
10+
return;
11+
}
12+
13+
return {
14+
type: "text",
15+
value: " ↗",
16+
};
717
},
818
contentProperties: {
919
class: "external-link",

0 commit comments

Comments
 (0)