mirror of
https://gitlab.com/MisterBiggs/brain-quartz.git
synced 2025-07-23 23:01:22 +00:00
.github
assets
content
data
layouts
_default
_markup
render-image.html
render-link.html
baseof.html
section.html
single.html
taxonomy.html
term.html
partials
404.html
index.html
static
.gitignore
.hugo_build.lock
.prettierrc
CODE_OF_CONDUCT.md
LICENSE.txt
Makefile
README.md
config.toml
screenshot.png
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 -}}
|