summaryrefslogtreecommitdiffstats
path: root/docs/layouts
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-08-30 19:24:34 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-08-30 19:24:34 +0200
commitdb45dbbee8ad59c9f585db2828dcf9284220b62f (patch)
treed7cfb67244ea2558d5b6da2688f0b46ed67e8cd6 /docs/layouts
parente847a98db62872a72b9aa95933f1d7262a9d1c0b (diff)
parent77b976dd92b4f66657d83d875aef0c617df492d9 (diff)
Diffstat (limited to 'docs/layouts')
-rw-r--r--docs/layouts/news/list.html70
-rw-r--r--docs/layouts/partials/boxes-section-summaries.html19
2 files changed, 79 insertions, 10 deletions
diff --git a/docs/layouts/news/list.html b/docs/layouts/news/list.html
new file mode 100644
index 000000000..32f72a446
--- /dev/null
+++ b/docs/layouts/news/list.html
@@ -0,0 +1,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" (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 }}
diff --git a/docs/layouts/partials/boxes-section-summaries.html b/docs/layouts/partials/boxes-section-summaries.html
index 7568539e4..268336cf5 100644
--- a/docs/layouts/partials/boxes-section-summaries.html
+++ b/docs/layouts/partials/boxes-section-summaries.html
@@ -1,14 +1,16 @@
<div class="relative {{ .classes }} weight-{{ .context.Weight }}">
-
<div class="bg-white mb2 pa3 pa4-l gray">
+
+ {{ $href := .context.RelPermalink }}
{{ if eq .context.Section "news" }}
- <date class="f6 db" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
+ {{ $href = .context.Permalink }}
+ <time class="f6 db" datetime="{{ .context.Date.Format `2006-01-02T15:04:05Z07:00` }}">
{{ .context.Date.Format "January 2, 2006" }}
- </date>
+ </time>
{{ end }}
<h1 class="near-black f3">
- <a href="{{ .context.RelPermalink }}" class="link primary-color dim">
+ <a href="{{ $href }}" class="link primary-color dim">
{{- if eq .context.Section "functions" -}}
{{ .context.LinkTitle }}
{{- else -}}
@@ -27,13 +29,10 @@
{{ .context.Summary }}
{{ end }}
{{ end }}
-
- <a href="{{ .context.RelPermalink }}" class="f6 mt2 db link primary-color dim">
- Read More &raquo;
- </a>
-
+ <a href="{{ $href }}" class="f6 mt2 db link primary-color dim">
+ Read More &raquo;
+ </a>
</div>
-
</div>
</div>