mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-18 10:50:24 +00:00
theme: allow errorlevel override on page level #870
This commit is contained in:
parent
1961424436
commit
f2799f8c41
7 changed files with 71 additions and 9 deletions
|
@ -302,6 +302,7 @@ highlightWrap = true
|
|||
# for the unresolved path. 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.
|
||||
# This can be overridden in the page's frontmatter.
|
||||
include.errorlevel = "error"
|
||||
|
||||
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
@ -316,6 +317,7 @@ include.errorlevel = "error"
|
|||
# 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.
|
||||
# This can be overridden in the page's frontmatter.
|
||||
image.errorlevel = "error"
|
||||
|
||||
# Image effects.
|
||||
|
@ -358,6 +360,7 @@ useDefaultRelref = false
|
|||
# aborted.
|
||||
# Please note that with Hugo < 0.123.0 + `uglyURLs=true` this can lead to false
|
||||
# negatives.
|
||||
# This can be overridden in the page's frontmatter.
|
||||
link.errorlevel = "error"
|
||||
|
||||
# How to open external links.
|
||||
|
@ -469,4 +472,5 @@ customOpenapiURL = "" # "https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js"
|
|||
# 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.
|
||||
# This can be overridden in the page's frontmatter.
|
||||
openapi.errorlevel = "error"
|
||||
|
|
|
@ -26,6 +26,8 @@ This document shows you what's new in the latest release and flags it with one o
|
|||
|
||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The [`openapi` shortcode](shortcodes/openapi) is now able to resolve links to resources as well as to files in the file system (the old behavior). You can configure to generate warnings or errors during build by setting `openapi.errorlevel` to either `warning` or `error` in your `hugo.toml` if a path can not be resolved.
|
||||
|
||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Shortcodes supporting an `errorlevel` configuration can now have overridden values in the [frontmatter](cont/frontmatter/) section of each individual page.
|
||||
|
||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The theme now comes with its own overridden version of the `relref` shortcode.
|
||||
|
||||
While the usage of `relref` is obsolete and discouraged by Hugo for a while, existing installations may use it. In configurations using a `baseURL` with a subdirectory, the default `relref` implementation of Hugo was failing, so an overridden shortcode was necessary.
|
||||
|
|
|
@ -155,10 +155,35 @@ LastModifierEmail = ""
|
|||
# parameter to individual code blocks.
|
||||
highlightWrap = true
|
||||
|
||||
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
# Include
|
||||
# These options configure how the include shortcode works.
|
||||
|
||||
# What to do when path is not resolved.
|
||||
# Default: ""
|
||||
# You can control what should happen if a path can not be resolved to as
|
||||
# a resource or via the file system. If not set, no output will be written
|
||||
# for the unresolved path. 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.
|
||||
# If not set, the set value of your site's hugo.toml is used.
|
||||
include.errorlevel = ""
|
||||
|
||||
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
# Images
|
||||
# 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.
|
||||
# If not set, the set value of your site's hugo.toml is used.
|
||||
image.errorlevel = ""
|
||||
|
||||
# Image effects.
|
||||
# See the documentation for how you can even add your own arbitrary effects to
|
||||
# the list.
|
||||
|
@ -175,6 +200,22 @@ imageEffects.lightbox = true
|
|||
# Default: false
|
||||
imageEffects.shadow = false
|
||||
|
||||
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
# Links
|
||||
# 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.
|
||||
# If not set, the set value of your site's hugo.toml is used.
|
||||
link.errorlevel = ""
|
||||
|
||||
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
# MathJax
|
||||
# These options configure how math formulae are displayed.
|
||||
|
@ -260,3 +301,14 @@ disableOpenapi = true
|
|||
# version will be used.
|
||||
# If not set, the set value of your site's hugo.toml is used.
|
||||
customOpenapiURL = "" # "https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js"
|
||||
|
||||
# What to do when a local OpenAPI spec link is not resolved.
|
||||
# Default: ""
|
||||
# You can control what should happen if a local OpenAPI spec link can not be resolved
|
||||
# to 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.
|
||||
# If not set, the set value of your site's hugo.toml is used.
|
||||
openapi.errorlevel = ""
|
||||
|
|
|
@ -32,9 +32,10 @@
|
|||
{{- $src = printf "%s#%s" $src . }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- if eq $page.Site.Params.image.errorlevel "warning" }}
|
||||
{{- $errorlevel := or $page.Params.image.errorlevel $page.Site.Params.image.errorlevel }}
|
||||
{{- if eq $errorlevel "warning" }}
|
||||
{{- warnf "%q: image '%s' is not a resource but linked anyways" $page.File.Filename .url }}
|
||||
{{- else if eq $page.Site.Params.image.errorlevel "error" }}
|
||||
{{- else if eq $errorlevel "error" }}
|
||||
{{- errorf "%q: image '%s' is not a resource" $page.File.Filename .url }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
|
@ -17,9 +17,10 @@
|
|||
{{- if (fileExists .file) }}
|
||||
{{- $content = .file | readFile }}
|
||||
{{- else }}
|
||||
{{- if eq $page.Site.Params.include.errorlevel "warning" }}
|
||||
{{- $errorlevel := or $page.Params.include.errorlevel $page.Site.Params.include.errorlevel }}
|
||||
{{- if eq $errorlevel "warning" }}
|
||||
{{- warnf "%q: included file '%s' is not a page, resource or accessible via file system" $page.File.Filename .file }}
|
||||
{{- else if eq $page.Site.Params.include.errorlevel "error" }}
|
||||
{{- else if eq $errorlevel "error" }}
|
||||
{{- errorf "%q: included file '%s' is not a page, resource or accessible via file system" $page.File.Filename .file }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
{{- else }}
|
||||
{{- $linkPage = $page.Page }}
|
||||
{{- end }}
|
||||
{{- $errorlevel := or $page.Params.link.errorlevel $page.Site.Params.link.errorlevel }}
|
||||
{{- with $linkPage }}
|
||||
{{- $href = partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}
|
||||
{{- with $u.RawQuery }}
|
||||
|
@ -68,7 +69,7 @@
|
|||
{{- with $u.Fragment }}
|
||||
{{- $ctx := dict
|
||||
"contentPath" $page.File.Filename
|
||||
"errorLevel" $page.Site.Params.link.errorlevel
|
||||
"errorLevel" $errorlevel
|
||||
"page" $linkPage
|
||||
"parsedURL" $u
|
||||
"renderHookName" "link"
|
||||
|
@ -77,9 +78,9 @@
|
|||
{{- $href = printf "%s#%s" $href . }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- if eq $page.Site.Params.link.errorlevel "warning" }}
|
||||
{{- if eq $errorlevel "warning" }}
|
||||
{{- warnf "%q: link '%s' is not a page or a resource but linked anyways" $page.File.Filename .url }}
|
||||
{{- else if eq $page.Site.Params.link.errorlevel "error" }}
|
||||
{{- else if eq $errorlevel "error" }}
|
||||
{{- errorf "%q: link '%s' is not a page or a resource" $page.File.Filename .url }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
|
@ -16,9 +16,10 @@
|
|||
{{- $src = "" }}
|
||||
{{- $spec = .Content }}
|
||||
{{- else }}
|
||||
{{- if eq $page.Site.Params.openapi.errorlevel "warning" }}
|
||||
{{- $errorlevel := or $page.Params.openapi.errorlevel $page.Site.Params.openapi.errorlevel }}
|
||||
{{- if eq $errorlevel "warning" }}
|
||||
{{- warnf "%q: OpenAPI spec link '%s' is not a resource but linked anyways" $page.File.Filename .url }}
|
||||
{{- else if eq $page.Site.Params.openapi.errorlevel "error" }}
|
||||
{{- else if eq $errorlevel "error" }}
|
||||
{{- errorf "%q: OpenAPI spec link '%s' is not a resource" $page.File.Filename .url }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
Loading…
Reference in a new issue