Skip to content

Commit

Permalink
feat: add the throw_on_error parameter, default to true (#438)
Browse files Browse the repository at this point in the history
When `true`, throw an error instead of a warning if icon not found.

Closes #436
  • Loading branch information
razonyang authored Oct 22, 2024
1 parent 9e909a5 commit 7143d67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[module.hugoVersion]
min = "0.110.0"

[params.icons]
throw_on_error = true # throw an error instead of a warning if icon not found.

# [params.icons.vendors.shorthand]
# name = "full name of vendor"
6 changes: 5 additions & 1 deletion layouts/partials/icons/icon.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
{{- $res := dict "vendor" $vendor "name" $name }}
{{- $icon := partialCached "icons/functions/svg-resource" $res $res -}}
{{- if not $icon -}}
{{- warnf "[icons] %s's %s doesn't exist." $vendor $name -}}
{{- if default true site.Params.icons.throw_on_error }}
{{- errorf "[icons] %s's %s doesn't exist." $vendor $name }}
{{- else }}
{{- warnf "[icons] %s's %s doesn't exist." $vendor $name -}}
{{- end }}
{{- end -}}
{{- with $icon -}}
{{- $size := default "1em" $.size }}
Expand Down

0 comments on commit 7143d67

Please sign in to comment.