mirror of
https://github.com/falsycat/ar.falsy.cat.git
synced 2024-11-15 07:54:52 +00:00
97607c3ca5
Removed strings.TrimRight "/" in line 10 to keep the trailing slash at the end of URLs in regular links. This avoids having every single internal link being a 301 redirect.
17 lines
745 B
HTML
17 lines
745 B
HTML
{{$trimmed := strings.TrimSuffix ".md" (.Destination | safeURL)}}
|
|
{{$dashedurl := replace $trimmed "%20" "-" }}
|
|
{{$external := strings.HasPrefix $dashedurl "http" }}
|
|
{{- if $external -}}
|
|
<a href="{{ $dashedurl }}" rel="noopener">{{ .Text | safeHTML }}</a>
|
|
{{- else -}}
|
|
{{$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 -}}
|