From 021a9a90fd5415262074fad37d569a4da01c7aef Mon Sep 17 00:00:00 2001 From: Eltrac Date: Wed, 21 May 2025 21:18:38 +0800 Subject: fix: showing unwanted image in RSS feed The original method of adding an "external" icon is to append an `` tag to `` tags, but if the reader is viewing the content from a reader where the CSS style does not work, the image is displayed in an unwanted way. The workaround is to remove the `` tag and implement this feature with only CSS pseudo-element. --- assets/css/components/_markdown.scss | 11 +++++++++++ layouts/_default/_markup/render-link.html | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/assets/css/components/_markdown.scss b/assets/css/components/_markdown.scss index 50f7735c..ac4e28bd 100644 --- a/assets/css/components/_markdown.scss +++ b/assets/css/components/_markdown.scss @@ -28,6 +28,17 @@ $em-text-color: #889E73; a { text-decoration: underline; color: $link-color; + &.external-link::after { + content: ''; + display: inline-block; + width: 0.9em; + height: 0.9em; + background-image: url('/img/external-link.svg'); + background-size: cover; + @media (prefers-color-scheme: dark) { + filter: invert(1); + } + } } blockquote { diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index 16c201cd..2e8d32f7 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -1,6 +1,6 @@ {{ $url := .Destination | safeURL }} {{ if or (strings.HasPrefix $url "http://") (strings.HasPrefix $url "https://") }} - {{ .Text }} + {{ .Text }} {{ else }} {{ .Text }} {{ end }} -- cgit v1.2.3