Hugo-theme-stack/layouts/partials/sidebar/right.html
WaterLemons2k 188e49ef41
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
2024-02-23 23:00:39 +01:00

16 lines
650 B
HTML

{{- $scope := default "homepage" .Scope -}}
{{- $context := .Context -}}
{{- with (index .Context.Site.Params.widgets $scope) -}}
<aside class="sidebar right-sidebar sticky">
{{ range $widget := . }}
{{ if templates.Exists (printf "partials/widget/%s.html" .type) }}
<!-- 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 }}
{{ end }}
</aside>
{{ end }}