Skip to content

Commit 4c807e9

Browse files
authored
open external link in new tab and add icon (#45)
1 parent 552d37a commit 4c807e9

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="#74818c"
2+
width="12" height="12">
3+
<path stroke-linecap="round" stroke-linejoin="round" d="m4.5 19.5 15-15m0 0H8.25m11.25 0v11.25" />
4+
</svg>

layouts/partials/main-menu-mobile.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33
{{ $currentPage := . }}
44
{{ range .Site.Menus.main }}
55
<li class="menu-item-{{ .Name | lower }}{{ if $currentPage.IsMenuCurrent "main" . }} active{{ end }}">
6-
<a href="{{ .URL }}">
6+
<a href="{{ .URL }}"
7+
{{ if or (strings.HasPrefix .URL "http") (strings.HasPrefix .URL "https") }}
8+
target="_blank"
9+
{{ end }}>
710
<span>{{ .Name }}</span>
11+
{{ if or (strings.HasPrefix .URL "http") (strings.HasPrefix .URL "https") }}
12+
{{ partial "arrow-up-right.html" . }}
13+
{{ end }}
814
</a>
915
</li>
1016
{{end}}

layouts/partials/main-menu.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
{{ $currentPage := . }}
44
{{ range .Site.Menus.main }}
55
<li class="menu-item-{{ .Name | lower }}{{ if $currentPage.IsMenuCurrent "main" . }} active{{ end }}">
6-
<a href="{{.URL}}">
6+
<a href="{{ .URL }}"
7+
{{ if or (strings.HasPrefix .URL "http") (strings.HasPrefix .URL "https") }}
8+
target="_blank"
9+
{{ end }}>
710
{{ .Pre }}
811
<span>{{ .Name }}</span>
12+
{{ if or (strings.HasPrefix .URL "http") (strings.HasPrefix .URL "https") }}
13+
{{ partial "arrow-up-right.html" . }}
14+
{{ end }}
915
</a>
1016
</li>
1117
{{end}}

0 commit comments

Comments
 (0)