fix: use relURL only for link starts with slash (#54)

This commit is contained in:
Xin 2023-09-13 05:40:00 -04:00 committed by GitHub
parent 76ac694542
commit a184cfd41e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,11 +11,11 @@
{{- end -}} {{- end -}}
{{- $external := strings.HasPrefix $link "http" -}} {{- $external := strings.HasPrefix $link "http" -}}
{{- $href := cond (strings.HasPrefix $link "/") ($link | relURL) $link -}}
<a <a
class="hextra-card group flex flex-col justify-start overflow-hidden rounded-lg border border-gray-200 text-current no-underline dark:shadow-none hover:shadow-gray-100 dark:hover:shadow-none shadow-gray-100 active:shadow-sm active:shadow-gray-200 transition-all duration-200 {{ $linkClass }}" class="hextra-card group flex flex-col justify-start overflow-hidden rounded-lg border border-gray-200 text-current no-underline dark:shadow-none hover:shadow-gray-100 dark:hover:shadow-none shadow-gray-100 active:shadow-sm active:shadow-gray-200 transition-all duration-200 {{ $linkClass }}"
href="{{ $link | relURL }}" href="{{ $href }}"
{{- if $external }} {{- if $external }}
target="_blank" rel="noreferrer" target="_blank" rel="noreferrer"
{{- end -}} {{- end -}}