Support configuration of internal links validation

This commit is contained in:
Mark Dumay
2024-10-18 06:52:47 +02:00
parent ede04405d1
commit 7989dd17d4
3 changed files with 8 additions and 3 deletions

View File

@@ -10,6 +10,8 @@
footerBelowFold = false footerBelowFold = false
loading = "lazy" loading = "lazy"
breakpoint = "md" breakpoint = "md"
[main.internalLinks]
validate = true
[main.externalLinks] [main.externalLinks]
cue = false cue = false
tab = false tab = false

View File

@@ -8,6 +8,8 @@
footerBelowFold = false footerBelowFold = false
loading = "lazy" loading = "lazy"
breakpoint = "md" breakpoint = "md"
[main.internalLinks]
validate = true
[main.externalLinks] [main.externalLinks]
cue = true cue = true
tab = true tab = true

View File

@@ -52,11 +52,12 @@
{{- $page := "" }} {{- $page := "" }}
{{- if .path }} {{- if .path }}
{{ $page = partial "utilities/GetPage.html" (dict "url" .path "page" page) }} {{ $page = partial "utilities/GetPage.html" (dict "url" .path "page" page) }}
{{- if not $page }} {{ $validate := site.Params.main.internalLinks.validate | default true }}
{{- if and $validate (not $page) }}
{{ if page.File }} {{ if page.File }}
{{- errorf "partial [assets/card.html] - Cannot find target page '%s', see '%s'" .path page.File.Path -}} {{- warnf "partial [assets/card.html] - Cannot find target page '%s', see '%s'" .path page.File.Path -}}
{{ else }} {{ else }}
{{- errorf "partial [assets/card.html] - Cannot find target page '%s'" .path -}} {{- warnf "partial [assets/card.html] - Cannot find target page '%s'" .path -}}
{{ end }} {{ end }}
{{- end }} {{- end }}
{{- end }} {{- end }}