mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-30 06:56:22 +00:00
f08a76a738
Co-authored-by: SAF <saf@saf.saf> fixes https://github.com/jackyzha0/quartz/issues/229
16 lines
749 B
HTML
16 lines
749 B
HTML
{{$dashedurl := replace .Destination "%20" "-" }}
|
|
{{$external := strings.HasPrefix $dashedurl "http" }}
|
|
{{- if $external -}}
|
|
<a href="{{ $dashedurl }}" rel="noopener">{{ .Text | safeHTML }}</a>
|
|
{{- else -}}
|
|
{{$trimmed := strings.TrimSuffix ".md" (.Destination | safeURL)}}
|
|
{{$spacedurl := replace $trimmed "%20" " " }}
|
|
{{$fixedUrl := (cond (hasPrefix $spacedurl "/") $spacedurl (print "/" $spacedurl)) | urlize}}
|
|
{{$nonexistent := eq (.Page.GetPage $spacedurl).RelPermalink ""}}
|
|
{{$rooted := default $spacedurl ((.Page.GetPage $spacedurl).RelPermalink) }}
|
|
<a
|
|
{{if not $nonexistent}}href="{{$rooted}}"{{end}}
|
|
rel="noopener" class="internal-link{{if $nonexistent}} broken{{end}}"
|
|
data-src="{{$rooted}}">{{- .Text | safeHTML -}}
|
|
</a>
|
|
{{- end -}}
|