Simplify and align detection of remote links
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{{- $destination := .Destination -}}
|
{{- $destination := .Destination -}}
|
||||||
{{- $url := urls.Parse .Destination -}}
|
{{- $url := urls.Parse .Destination -}}
|
||||||
|
|
||||||
{{- $isRemote := gt (len $url.Host) 0 -}}
|
{{- $isRemote := $url.IsAbs -}}
|
||||||
{{- $isFragment := strings.HasPrefix .Destination "#" -}}
|
{{- $isFragment := strings.HasPrefix .Destination "#" -}}
|
||||||
|
|
||||||
{{- if and (not $isRemote) (not $isFragment) -}}
|
{{- if and (not $isRemote) (not $isFragment) -}}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{{- $destination := .Destination -}}
|
{{- $destination := .Destination -}}
|
||||||
{{- $url := urls.Parse .Destination -}}
|
{{- $url := urls.Parse .Destination -}}
|
||||||
|
|
||||||
{{- $isRemote := gt (len $url.Host) 0 -}}
|
{{- $isRemote := $url.IsAbs -}}
|
||||||
{{- $isFragment := strings.HasPrefix .Destination "#" -}}
|
{{- $isFragment := strings.HasPrefix .Destination "#" -}}
|
||||||
|
|
||||||
{{- if and (not $isRemote) (not $isFragment) -}}
|
{{- if and (not $isRemote) (not $isFragment) -}}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
{{- $class = $class | append "active" -}}
|
{{- $class = $class | append "active" -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
<li>
|
<li>
|
||||||
{{- $isRemote := not (or (.Page) (strings.HasPrefix .URL "/")) -}}
|
{{- $isRemote := (urls.Parse .URL).IsAbs -}}
|
||||||
<a href="{{ .URL }}"
|
<a href="{{ .URL }}"
|
||||||
{{- with $class }}class="{{ delimit . " " }}"{{ end -}}
|
{{- with $class }}class="{{ delimit . " " }}"{{ end -}}
|
||||||
{{- with .Title }}title="{{ . }}"{{ end -}}
|
{{- with .Title }}title="{{ . }}"{{ end -}}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{{ $href := partial "docs/links/portable-link" (dict "Page" .Page "Destination" (.Get "href")) -}}
|
{{- $href := partial "docs/links/portable-link" (dict "Page" .Page "Destination" (.Get "href")) -}}
|
||||||
{{ $isRemote := (urls.Parse $href).Scheme}}
|
{{- $isRemote := (urls.Parse $href).IsAbs -}}
|
||||||
<a {{ with $href }}href="{{ $href }}"{{ end }} {{ with $isRemote }}target="_blank" rel="noopener"{{ end }} class="book-btn{{ with .Get "class" }} {{ . }}{{ end }}">
|
<a {{ with $href }}href="{{ $href }}"{{ end }} {{ with $isRemote }}target="_blank" rel="noopener"{{ end }} class="book-btn{{ with .Get "class" }} {{ . }}{{ end }}">
|
||||||
{{- .InnerDeindent -}}
|
{{- .InnerDeindent -}}
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user