mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-27 04:03:48 +01:00
fix(widgets): ensure params
is not nil (#943)
* fix(partials): ensure params always exist If the `params` key is not defined in the config file, accessing `params` results in a `nil pointer evaluating interface {}` error because `params` does not exist. This can be fixed by ensuring that params is always a map. * style(widgets): `default` no pipes required
This commit is contained in:
parent
76dc61f0d5
commit
188e49ef41
1 changed files with 4 additions and 1 deletions
|
@ -4,7 +4,10 @@
|
|||
<aside class="sidebar right-sidebar sticky">
|
||||
{{ range $widget := . }}
|
||||
{{ if templates.Exists (printf "partials/widget/%s.html" .type) }}
|
||||
{{ partial (printf "widget/%s" .type) (dict "Context" $context "Params" .params) }}
|
||||
<!-- Ensure that the `params` is not nil -->
|
||||
{{- $params := default dict .params -}}
|
||||
|
||||
{{ partial (printf "widget/%s" .type) (dict "Context" $context "Params" $params) }}
|
||||
{{ else }}
|
||||
{{ warnf "Widget %s not found" .type }}
|
||||
{{ end }}
|
||||
|
|
Loading…
Reference in a new issue