Skip to content

Commit

Permalink
fix(widgets): ensure params is not nil (#943)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
WaterLemons2k authored Feb 23, 2024
1 parent 76dc61f commit 188e49e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion layouts/partials/sidebar/right.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit 188e49e

Please sign in to comment.