{{- $title := .Get "title" -}}
{{- if not $title -}}
    {{- $title := "Upcoming Events" -}}
{{- end -}}

{{ $upcoming_posts := slice }}
{{ range (where (.Site.RegularPages.ByParam "eventEndDate") "Section" "post").ByDate.Reverse }}
  {{ $FormattedNow := (now.AddDate 0 0 -1) }}
  {{ if le $FormattedNow .Params.eventEndDate }}
    {{ $upcoming_posts = $upcoming_posts | append . }}
  {{ end }}
{{ end }}

{{ if ge (len $upcoming_posts) 1 }} 
  <div class="posts-title" >{{ $title }}</div>

{{- range $upcoming_posts }} 
  {{ partial "postcard" (dict "context" . "card_type" "upcoming" ) }}
{{- end }} 

<br>
<br>

{{ end }} 
