Home page: homePosts setting, 15 sample news posts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YDRjtmAiNpo5mK5N3d7QwZ
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{{/* dict "page" <post> "width" <px> -> URL of the post banner, resized when it is a bundle image */}}
|
||||
{{/* dict "page" <post> "width" <px> -> URL of the post banner (`banner:`, or `image:`), resized when it is a bundle image */}}
|
||||
{{- $url := "" -}}
|
||||
{{- with .page.Params.banner -}}
|
||||
{{- with (.page.Params.banner | default .page.Params.image) -}}
|
||||
{{- with $.page.Resources.GetMatch . -}}
|
||||
{{- if and (eq .MediaType.MainType "image") (ne .MediaType.SubType "svg") -}}
|
||||
{{- $url = (.Resize (printf "%dx" $.width)).RelPermalink -}}
|
||||
|
||||
+3
-2
@@ -3,12 +3,13 @@
|
||||
<div class="content">{{ .Content }}</div>
|
||||
{{ with site.GetPage "/post" }}
|
||||
{{ $posts := .RegularPages.ByDate.Reverse }}
|
||||
{{ $max := site.Params.homePosts | default 5 }}
|
||||
{{ if $posts }}
|
||||
<h2>{{ .Title }}</h2>
|
||||
<div class="posts">
|
||||
{{ range first 5 $posts }}{{ partial "post-summary.html" . }}{{ end }}
|
||||
{{ range first $max $posts }}{{ partial "post-summary.html" . }}{{ end }}
|
||||
</div>
|
||||
{{ if gt (len $posts) 5 }}<p><a href="{{ .RelPermalink }}">All posts →</a></p>{{ end }}
|
||||
{{ if gt (len $posts) $max }}<p><a href="{{ .RelPermalink }}">All posts →</a></p>{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<h2>Sections</h2>
|
||||
|
||||
Reference in New Issue
Block a user