diff --git a/layouts/index.rss.xml b/layouts/_default/list.rss.xml similarity index 53% rename from layouts/index.rss.xml rename to layouts/_default/list.rss.xml index 460c4d30e..ac364a122 100644 --- a/layouts/index.rss.xml +++ b/layouts/_default/list.rss.xml @@ -13,42 +13,9 @@ {{ printf "" .Permalink .MediaType | safeHTML }} {{- end }} - {{- $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 }} - {{- $summary := printf - "Hugo %s was released on %s. See [release notes](%s) for details." - .tag_name - (.published_at | time.AsTime | time.Format "2 Jan 2006") - .html_url - }} - {{- $ctx := dict - "PublishDate" (.published_at | time.AsTime) - "Title" (printf "Release %s" .name) - "Permalink" .html_url - "Section" "news" - "Summary" ($summary | $.Page.RenderString) - }} - {{- $news_items = $news_items | append $ctx }} - {{- end }} + {{ $news_items := partial "news/get-news-items.html" . }} - {{- /* Get content pages from news section. */}} - {{- range where site.RegularPages "Section" "news" }} - {{- $ctx := dict - "PublishDate" .PublishDate - "Title" .Title - "RelPermalink" .RelPermalink - "Section" "news" - "Summary" .Summary - "Params" (dict "description" .Description) - }} - {{- $news_items = $news_items | append $ctx }} - {{- end }} {{- /* Sort, limit, and render lastBuildDate. */}} {{- $limit := cond (gt site.Config.Services.RSS.Limit 1) site.Config.Services.RSS.Limit 999 }} {{- $news_items = sort $news_items "PublishDate" "desc" | first $limit }} diff --git a/layouts/partials/news/get-news-items.html b/layouts/partials/news/get-news-items.html index cb1a930d3..fbf1bc720 100644 --- a/layouts/partials/news/get-news-items.html +++ b/layouts/partials/news/get-news-items.html @@ -15,31 +15,33 @@ {{ $ctx := dict "Date" $publishDate - "Title" (printf "Release %s" .name) "LinkTitle" (printf "Release %s" .name) "Permalink" .html_url - "RelPermalink" .html_url + "PublishDate" $publishDate + "Permalink" .html_url "Section" "news" "Summary" "" + "Title" (printf "Release %s" .name) }} {{ $news_items = $news_items | append $ctx }} {{ end }} {{/* Get content pages from news section. */}} -{{ range .Pages }} +{{ range where site.RegularPages "Section" "news" }} {{ $ctx := dict "Date" .Date - "Title" .Title "LinkTitle" .Title - "RelPermalink" .RelPermalink + "Params" (dict "description" .Description) + "PublishDate" .PublishDate + "Permalink" .Permalink "Section" "news" "Summary" .Summary - "Params" (dict "description" .Description) + "Title" .Title }} {{ $news_items = $news_items | append $ctx }} {{ end }} -{{/* Sort by date (descending) and render. */}} +{{/* Sort by date in descending order. */}} {{ $news_items = sort $news_items "Date" "desc" }} {{ return $news_items }}