Skip to content

Conversation

@KianNH
Copy link
Member

@KianNH KianNH commented Mar 20, 2025

Summary

Only show external link arrow if element has no image children

@KianNH KianNH marked this pull request as ready for review March 20, 2025 19:01
import rehypeExternalLinks, { type Options } from "rehype-external-links";
import type { Element } from "hast";

function hasImgChild(node: Element): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to imagine ever intentionally linking over more than just a single image child, but I guess in those cases you also probably don't want . Fair enough!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I admittedly stole it from rehype-external-links themselves - they have it in their tests: https://github.com/rehypejs/rehype-external-links/blob/b0ada86b178e135d55368ffa47b915db17219716/test.js#L388-L398

@github-actions
Copy link
Contributor

@KianNH KianNH merged commit 46b2713 into production Mar 20, 2025
9 checks passed
@KianNH KianNH deleted the kian/PCX-16499 branch March 20, 2025 20:02
RebeccaTamachiro pushed a commit that referenced this pull request Apr 21, 2025
…ldren (#20998)

* [Docs Site] Only show external link arrow if element has no image children

* unused import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants