{{ $news_items := slice }}

{{/* Get releases from GitHub. */}}
{{ $u := "https://api.github.com/repos/gohugoio/hugo/releases" }}
{{ $releases := partial "helpers/funcs/get-remote-data.html" $u }}
{{ $releases = where $releases "draft" false }}
{{ $releases = where $releases "prerelease" false }}
{{ range $releases | first 20 }}
  {{ $publishDate := .published_at | time.AsTime }}

  {{/* Correct the v0.138.0 release date. See https://github.com/gohugoio/hugo/issues/13066. */}}
  {{ if eq .name "v0.138.0" }}
    {{ $publishDate = "2024-11-06T11:22:34Z" | time.AsTime }}
  {{ end }}

  {{ $ctx := dict
    "Date" $publishDate
    "Title" (printf "Release %s" .name)
    "LinkTitle" (printf "Release %s" .name)
    "Permalink" .html_url
    "RelPermalink" .html_url
    "Section" "news"
    "Summary" ""
  }}
  {{ $news_items = $news_items | append $ctx }}
{{ end }}

{{/* Get content pages from news section. */}}
{{ range .Pages }}
  {{ $ctx := dict
    "Date" .Date
    "Title" .Title
    "LinkTitle" .Title
    "RelPermalink" .RelPermalink
    "Section" "news"
    "Summary" .Summary
    "Params" (dict "description" .Description)
  }}
  {{ $news_items = $news_items | append $ctx }}
{{ end }}

{{/* Sort by date (descending) and render. */}}
{{ $news_items = sort $news_items "Date" "desc" }}

{{ return $news_items }}
