mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 21:34:06 -06:00
Have external links open in a new tab
Usually when linking to outside sources, I find myself wanting to do so in a new tab. Internal links will continue to route in the current tab.
This commit is contained in:
parent
ed9a8efd1f
commit
2c6f847d4a
@ -2,7 +2,7 @@
|
|||||||
{{$dashedurl := replace $trimmed "%20" "-" }}
|
{{$dashedurl := replace $trimmed "%20" "-" }}
|
||||||
{{$external := strings.HasPrefix $dashedurl "http" }}
|
{{$external := strings.HasPrefix $dashedurl "http" }}
|
||||||
{{- if $external -}}
|
{{- if $external -}}
|
||||||
<a href="{{ $dashedurl }}" rel="noopener">{{ .Text | safeHTML }}</a>
|
<a target="_blank" href="{{ $dashedurl }}" rel="noopener">{{ .Text | safeHTML }}</a>
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
{{$spacedurl := replace $trimmed "%20" " " }}
|
{{$spacedurl := replace $trimmed "%20" " " }}
|
||||||
{{$fixedUrl := (cond (hasPrefix $spacedurl "/") $spacedurl (print "/" $spacedurl)) | urlize}}
|
{{$fixedUrl := (cond (hasPrefix $spacedurl "/") $spacedurl (print "/" $spacedurl)) | urlize}}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user