summaryrefslogtreecommitdiffstats
path: root/docs/_vendor/github.com/gohugoio/gohugoioTheme/layouts/news/list.html
blob: 5165c8a13e23e70507754814365598168de51e39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{{ define "main" }}
<div class="w-100 ph4 ph5-ns pb5 pb6-ns pt1 pt3-ns ">

  <article class="cf pa3 pa4-m pa4-l nested-copy-line-height nested-img">
    <h1 class="primary-color-dark">
      {{ .Title }}
    </h1>
    <div class="nested-copy-line-height">
      {{ .Content }}
    </div>
  </article>

  <div class="flex flex-wrap">
    {{ $interior_classes := $.Site.Params.flex_box_interior_classes }}
    <section class="flex-ns flex-wrap justify-between w-100 w-80-nsTK v-top">

      {{ $news_items := slice }}

      {{/* Get releases from GitHub. */}}
      {{ $u := "https://api.github.com/repos/gohugoio/hugo/releases" }}
      {{ $releases := partial "inline/get-remote-data.html" $u }}
      {{ $releases = where $releases "draft" false }}
      {{ $releases = where $releases "prerelease" false }}
      {{ range $releases | first 20 }}
        {{ $ctx := dict
          "Date" (.published_at | time.AsTime)
          "Title" (printf "Release %s" .name)
          "Permalink" .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
          "RelPermalink" .RelPermalink
          "Section" "news"
          "Summary" .Summary
          "Params" (dict "description" .Description)
        }}
        {{ $news_items = $news_items | append $ctx }}
      {{ end }}

      {{/* Sort by date (descending) and render. */}}
      {{ range sort $news_items "Date" "desc" }}
        {{ partial "boxes-section-summaries.html" (dict "context" . "classes" $interior_classes "fullcontent" false) }}
      {{ end }}

    </section>
  </div>

</div>
{{ end }}

{{ define "partials/inline/get-remote-data.html" }}
  {{ $u := . }}
  {{ $r := "" }}
  {{ with $r = resources.GetRemote $u }}
    {{ with .Err }}
      {{ errorf "%s" . }}
    {{ end }}
  {{ else }}
    {{ errorf "Unable to get remote resource %q" $u }}
  {{ end }}
  {{ return ($r | transform.Unmarshal) }}
{{ end }}