Don't open hero social link if href is local

In case link for a social icon in the hero image is set to local link
(e.g., "#contact"), don't open it in a new tab. It's useful if you don't
want to publish a link to your e-mail in clear text, and rather redirect
user to the contact form.

Signed-off-by: Marek Pikuła <marek@serenitycode.dev>
This commit is contained in:
Marek Pikuła
2024-06-02 00:47:34 +02:00
parent 4687d53336
commit 0a95ffa08a
+9 -3
View File
@@ -1,7 +1,10 @@
<span>
{{ range .Site.Params.hero.socialLinks.fontAwesomeIcons }}
<span class="px-1">
<a href="{{ .url }}" target="_blank" class="btn social-icon">
<a href="{{ .url }}"
{{ if not (hasPrefix .url "#") }} target="_blank" {{ end }}
class="btn social-icon"
>
<i class="{{ .icon }}"></i>
</a>
</span>
@@ -9,9 +12,12 @@
{{ range .Site.Params.hero.socialLinks.customIcons }}
<span class="px-1">
<a href="{{ .url }}" target="_blank" class="btn social-icon">
<a href="{{ .url }}"
{{ if not (hasPrefix .url "#") }} target="_blank" {{ end }}
class="btn social-icon"
>
<img src="{{ .icon }}">
</a>
</span>
{{ end }}
</span>
</span>