Add news posts with banner summaries on the home page
Posts live in content/post/; the five latest are summarised on the home page. Builds for check/deploy go to build/ so they do not collide with a running hugo server writing to public/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YDRjtmAiNpo5mK5N3d7QwZ
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
{{/* dict "page" <post> "width" <px> -> URL of the post banner, resized when it is a bundle image */}}
|
||||
{{- $url := "" -}}
|
||||
{{- with .page.Params.banner -}}
|
||||
{{- with $.page.Resources.GetMatch . -}}
|
||||
{{- if and (eq .MediaType.MainType "image") (ne .MediaType.SubType "svg") -}}
|
||||
{{- $url = (.Resize (printf "%dx" $.width)).RelPermalink -}}
|
||||
{{- else -}}
|
||||
{{- $url = .RelPermalink -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $url = . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- return $url -}}
|
||||
@@ -0,0 +1,11 @@
|
||||
<article class="post-summary">
|
||||
{{ with partial "banner.html" (dict "page" . "width" 640) }}
|
||||
<a class="banner" href="{{ $.RelPermalink }}"><img src="{{ . }}" alt="" loading="lazy"></a>
|
||||
{{ end }}
|
||||
<div>
|
||||
<h3><a href="{{ .RelPermalink }}">{{ .Title }}</a></h3>
|
||||
<p class="meta">{{ if not .Date.IsZero }}<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2 January 2006" }}</time>{{ end }}{{ with .Params.author }}{{ if not $.Date.IsZero }} · {{ end }}{{ . }}{{ end }}</p>
|
||||
<div class="summary">{{ .Summary }}</div>
|
||||
{{ if .Truncated }}<p><a href="{{ .RelPermalink }}">Read more →</a></p>{{ end }}
|
||||
</div>
|
||||
</article>
|
||||
+13
-2
@@ -1,14 +1,25 @@
|
||||
{{ define "main" }}
|
||||
<h1>{{ .Title }}</h1>
|
||||
<div class="content">{{ .Content }}</div>
|
||||
{{ with site.GetPage "/post" }}
|
||||
{{ $posts := .RegularPages.ByDate.Reverse }}
|
||||
{{ if $posts }}
|
||||
<h2>{{ .Title }}</h2>
|
||||
<div class="posts">
|
||||
{{ range first 5 $posts }}{{ partial "post-summary.html" . }}{{ end }}
|
||||
</div>
|
||||
{{ if gt (len $posts) 5 }}<p><a href="{{ .RelPermalink }}">All posts →</a></p>{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<h2>Sections</h2>
|
||||
<div class="cards">
|
||||
{{ range site.Menus.main }}
|
||||
{{ with .Page }}
|
||||
{{ with .Page }}{{ if ne .Section "post" }}
|
||||
<a class="card" href="{{ .RelPermalink }}">
|
||||
<strong>{{ .Title }}</strong>
|
||||
<span>{{ len .RegularPages }} {{ if eq (len .RegularPages) 1 }}page{{ else }}pages{{ end }}</span>
|
||||
</a>
|
||||
{{ end }}
|
||||
{{ end }}{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
<h2>Browse the museum</h2>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{{ define "main" }}
|
||||
<h1>{{ .Title }}</h1>
|
||||
<div class="content">{{ .Content }}</div>
|
||||
<div class="posts">
|
||||
{{ range .RegularPages.ByDate.Reverse }}{{ partial "post-summary.html" . }}{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
@@ -0,0 +1,13 @@
|
||||
{{ define "main" }}
|
||||
<article class="post">
|
||||
<p class="crumbs"><a href="{{ .Parent.RelPermalink }}">{{ .Parent.Title }}</a></p>
|
||||
<h1>{{ .Title }}</h1>
|
||||
<p class="meta">{{ if not .Date.IsZero }}<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2 January 2006" }}</time>{{ end }}{{ with .Params.author }}{{ if not $.Date.IsZero }} · {{ end }}{{ . }}{{ end }}</p>
|
||||
{{ with partial "banner.html" (dict "page" . "width" 1000) }}<img class="post-banner" src="{{ . }}" alt="">{{ end }}
|
||||
<div class="content">{{ .Content }}</div>
|
||||
<nav class="prev-next">
|
||||
{{ with .PrevInSection }}<a href="{{ .RelPermalink }}">← {{ .Title }}</a>{{ end }}
|
||||
{{ with .NextInSection }}<a href="{{ .RelPermalink }}">{{ .Title }} →</a>{{ end }}
|
||||
</nav>
|
||||
</article>
|
||||
{{ end }}
|
||||
Reference in New Issue
Block a user