Hi Hugo community
I’m working on a feature to support recurring events on a Hugo page. To do so, my approach is as follows: in the Front Matter, I add recurrence: (which can be set to weekly or monthly) and recurrence_end to define until when the recurrence has to be taken into account.
Then on the page I go through all events and add “new” events. My approach to add these “new” events is to copy the current event and then modify the dates accordingly.
{{ $events := .Pages }}
{{ range sort $events ".Params.date" "asc" }}
{{ if (and .Params.recurrence .Params.recurrence_end) }}
{{ if eq .Params.recurrence "monthly" }}
{{ $event := . }}
{{ $date := $.Param "date" }}
{{ $date := $date.AddDate 0 1 0 }}
{{ $event.date := $date }}
{{ $events = $events | append $event }}
{{ else if eq .Params.recurrence "weekly" }}
{{/* {{ $events = $events | append . }} */}}
{{ $event := . }}
{{ $date := $.Param "date" }}
{{ $date := $date.AddDate 0 0 7 }}
{{ $event.date := $date }}
{{ $events = $events | append $event }}
{{ end }}
{{ end }}
{{ end }}
But Hugo complains about {{ $event.date := $date }} with unexpected ":=" in operand. My question is now, how can I modify the date (and other params in the Front Matter) of a copy of an event?