From d006adfc205972e0874ccb63b441a921b1cc9e62 Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Mon, 8 Jan 2024 13:15:58 +0100 Subject: [PATCH 1/3] css: add icons utility Adds an .icon utility class to set ligature text via via a data-icon attribute on the element. This is a workaround to prevent crawlers from picking up the font ligature innertext in html directly. Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com> --- assets/css/icons.css | 19 +++++++++++++++++++ assets/css/styles.css | 1 + 2 files changed, 20 insertions(+) create mode 100644 assets/css/icons.css diff --git a/assets/css/icons.css b/assets/css/icons.css new file mode 100644 index 0000000000..73155e8af6 --- /dev/null +++ b/assets/css/icons.css @@ -0,0 +1,19 @@ +@layer utilities { + .icon { + font-family: "Material Symbols Rounded"; + font-weight: normal; + font-style: normal; + font-size: 24px; /* Preferred icon size */ + display: inline-block; + line-height: 1; + text-transform: none; + letter-spacing: normal; + word-wrap: normal; + white-space: nowrap; + direction: ltr; + } + + .icon:after { + content: attr(data-icon); + } +} diff --git a/assets/css/styles.css b/assets/css/styles.css index 0ab8a14e0d..28c30294e8 100644 --- a/assets/css/styles.css +++ b/assets/css/styles.css @@ -14,3 +14,4 @@ @import "tailwindcss/utilities"; @import "/assets/css/syntax-light"; @import "/assets/css/syntax-dark"; +@import "/assets/css/icons"; From a13ad08101a1eedfcdab388dfda52e4f73d82a7b Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Mon, 8 Jan 2024 13:17:26 +0100 Subject: [PATCH 2/3] css: add external-link utility class Adds an .external-link utility class, to be used together with the existing .link utility, for adding the correct styles to the open_in_new icon without having to duplicate the markup each time. Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com> --- assets/css/global.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/assets/css/global.css b/assets/css/global.css index 5f336ca857..5ceb76c5b9 100644 --- a/assets/css/global.css +++ b/assets/css/global.css @@ -18,6 +18,12 @@ @apply text-blue-light underline underline-offset-2 dark:text-blue-dark; } + .external-link { + .icon:after { + @apply text-base ml-1; + } + } + .invertible { @apply dark:hue-rotate-180 dark:invert dark:filter; } From 04a5ee0915fef0bca42ee7da3be8907d273931b4 Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Mon, 8 Jan 2024 13:25:03 +0100 Subject: [PATCH 3/3] hugo: use icon utility class for external links Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com> --- layouts/_default/_markup/render-link.html | 8 ++------ layouts/partials/github-links.html | 8 ++++---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index 843f84175c..4775116a6b 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -2,16 +2,12 @@ {{- if (strings.HasPrefix $url "http") -}} {{/* external link, add icon */}} {{ .Text | safeHTML }}open_in_new + class="icon" data-icon="open_in_new"> {{- else if (strings.HasPrefix $url "/") -}} {{/* absolute link, use url as-is */}} {{ .Text | safeHTML }} diff --git a/layouts/partials/github-links.html b/layouts/partials/github-links.html index 662cc64d4b..b981d2514a 100644 --- a/layouts/partials/github-links.html +++ b/layouts/partials/github-links.html @@ -3,18 +3,18 @@ {{ if not (in .Filename "/_vendor/") }}

edit - {{ T "editPage" }} - open_in_new +

{{ end }} {{ end }}

done - {{ T "requestChanges" }} - open_in_new +

{{ end }}