mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
link: make resolution reporting configurable #774
This commit is contained in:
parent
0b9fae5d63
commit
b77a8ff114
4 changed files with 41 additions and 4 deletions
|
@ -312,6 +312,16 @@ highlightWrap = true
|
||||||
# Images
|
# Images
|
||||||
# These options configure how images are displayed.
|
# These options configure how images are displayed.
|
||||||
|
|
||||||
|
# What to do when local image link is not resolved.
|
||||||
|
# Default: ""
|
||||||
|
# You can control what should happen if a local image can not be resolved to as
|
||||||
|
# a resource. If not set, the unresolved link is written as given into the resulting
|
||||||
|
# output. If set to `warning` the same happens and an additional warning is
|
||||||
|
# printed. If set to `error` an error message is printed and the build is
|
||||||
|
# aborted.
|
||||||
|
# Please note that this can not resolve files inside of your `static` directory.
|
||||||
|
image.errorlevel = "warning"
|
||||||
|
|
||||||
# Image effects.
|
# Image effects.
|
||||||
# See the documentation for how you can even add your own arbitrary effects to
|
# See the documentation for how you can even add your own arbitrary effects to
|
||||||
# the list.
|
# the list.
|
||||||
|
@ -329,6 +339,17 @@ imageEffects.shadow = false
|
||||||
# Links
|
# Links
|
||||||
# These options configure how links are displayed.
|
# These options configure how links are displayed.
|
||||||
|
|
||||||
|
# What to do when local page link is not resolved.
|
||||||
|
# Default: ""
|
||||||
|
# You can control what should happen if a local link can not be resolved to a
|
||||||
|
# page. If not set, the unresolved link is written as given into the resulting
|
||||||
|
# output. If set to `warning` the same happens and an additional warning is
|
||||||
|
# printed. If set to `error` an error message is printed and the build is
|
||||||
|
# aborted.
|
||||||
|
# Please note that with Hugo < 0.123.0 + `uglyURLs=true` this can lead to false
|
||||||
|
# negatives.
|
||||||
|
link.errorlevel = "warning"
|
||||||
|
|
||||||
# How to open external links.
|
# How to open external links.
|
||||||
# Default: "_blank"
|
# Default: "_blank"
|
||||||
# For external links you can define how they are opened in your browser. All
|
# For external links you can define how they are opened in your browser. All
|
||||||
|
|
|
@ -18,6 +18,16 @@ This document shows you what's new in the latest release and flags it with one o
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 5.24.1 (2024-02-17) {#5241}
|
||||||
|
|
||||||
|
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} If the theme can not resolve a link to a page or image, you can now generate warnings or errors during build by setting `link.errorlevel` or `image.errorlevel` to either `warning` or `error` in your `hugo.toml` respectively. By default this condition is silently ignored and the link is written as-is.
|
||||||
|
|
||||||
|
Please note that a page link will generate false negatives if `uglyURLs=true` and it references an ordinary page before {{% badge color="fuchsia" icon="fab fa-hackerrank" title=" " %}}0.123.0{{% /badge %}}.
|
||||||
|
|
||||||
|
Please note that an image link will generate false negatives if the file resides in your `static` directory.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 5.24.0 (2024-02-17) {#5240}
|
## 5.24.0 (2024-02-17) {#5240}
|
||||||
|
|
||||||
- {{% badge color="fuchsia" icon="fab fa-hackerrank" title=" " %}}0.112.4{{% /badge %}} This release requires a newer Hugo version.
|
- {{% badge color="fuchsia" icon="fab fa-hackerrank" title=" " %}}0.112.4{{% /badge %}} This release requires a newer Hugo version.
|
||||||
|
|
|
@ -30,9 +30,11 @@
|
||||||
{{- $url = printf "%s?%s" $url $dest_url.RawQuery }}
|
{{- $url = printf "%s?%s" $url $dest_url.RawQuery }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if not $image }}
|
{{- if and (not $image) (not $dest_url.IsAbs) }}
|
||||||
{{- if and ($page.Site.Params.render_hooks.errorlevel "warning") (not (or (strings.HasPrefix .url "http://") (strings.HasPrefix .url "https://") )) }}
|
{{- if eq $page.Site.Params.image.errorlevel "warning" }}
|
||||||
{{- warnf "%q: Image %s is not a resource but linked anyways." $page.File.Filename .url }}
|
{{- warnf "%q: image '%s' is not a resource but linked anyways" $page.File.Filename .url }}
|
||||||
|
{{- else if eq $page.Site.Params.image.errorlevel "error" }}
|
||||||
|
{{- errorf "%q: image '%s' is not a resource" $page.File.Filename .url }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $dest_url.RawQuery }}
|
{{- if $dest_url.RawQuery }}
|
||||||
|
|
|
@ -59,7 +59,11 @@
|
||||||
{{- $href = printf "%s#%s" $href . }}
|
{{- $href = printf "%s#%s" $href . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- warnf "%q: no page was found for link '%s'" $page.File.Filename $u.Path }}
|
{{- if eq $page.Site.Params.link.errorlevel "warning" }}
|
||||||
|
{{- warnf "%q: link '%s' is not a page but linked anyways" $page.File.Filename $u.Path }}
|
||||||
|
{{- else if eq $page.Site.Params.link.errorlevel "error" }}
|
||||||
|
{{- errorf "%q: link '%s' is not a page" $page.File.Filename $u.Path }}
|
||||||
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- $attributes = $attributes | merge (dict "href" $href) -}}
|
{{- $attributes = $attributes | merge (dict "href" $href) -}}
|
||||||
|
|
Loading…
Reference in a new issue