denvergeeks introduced a theme component that adds an external link icon to links in topics and posts, using the default SVG icon compatible with light and dark themes. Early feedback from chapoi highlighted visibility issues in dark mode, which denvergeeks addressed by updating the example image to a transparent webp with a gray fill. Moin suggested using the Discourse icon component but noted difficulties with color customization.
Subsequently, patrickemin and Thomas_Köster reported that the icon incorrectly appeared on internal links, specifically those using absolute URLs matching the site domain. Lilly submitted a pull request to fix this by excluding internal relative and absolute links, as well as title links, which denvergeeks merged. Canapin shared a pure CSS alternative using SCSS, though Orioni noted the icon disappeared on hover in some cases. Don provided a JavaScript snippet to dynamically exclude the current hostname from external link detection. denvergeeks confirmed that these issues have been resolved in the latest update.
But a screenshot won’t adjust its color to the color palette. What would you suggest to present the feature in a forum where the component isn’t installed? A larger screenshot that includes the link?
I was about to suggest using the Discourse icon component, but I am unable to change the color of the icon:
Same here. The icon also appears on internal links.
If I understood the code correctly, it looks for “http*” in the URL to determine external links. Unfortunately the link tool in the editor automatically uses fully qualified (absolute) URLs starting with “https:///..”.
I assume that this causes the external icons on “internal” links.
Could the code be expanded to check for “https:///..” classifying these as internal?
In my case, I use settings for this because the component changes icons dynamically via CSS, allowing me to target those settings directly. (Adding class to links doesn’t always work very well in some cases.)
However, for your component, you can simply exclude the current hostname dynamically something like this, I think: