layouts: allow lists to be overwritten

- Replace fixed spacing by the pico variable, and improve the horizontal
  spacing of lists of posts (sections).
- Place the list of last posts of the home page on a separate partial.
  Thus, this partial is easier to overwrite in the user layout
  directory.

Co-Authored-by: iGor milhit <igor@milhit.ch>
dev
iGor milhit 2024-12-08 08:55:51 +01:00
parent 83f45fefff
commit 264fc3480e
Signed by: igor
GPG Key ID: 692D97C3D0228A99
4 changed files with 21 additions and 18 deletions

View File

@ -8,11 +8,13 @@
.posts-list {
display: flex;
flex-direction: column;
margin-bottom: .5em;
margin-bottom: var(--pico-spacing);
> article {
padding-bottom: .5rem;
padding-bottom: var(--pico-spacing);
padding-left: var(--pico-spacing);
}
}
/* List of last posts, on the home page*/

View File

@ -1,20 +1,7 @@
{{ define "main" }}
<!-- List the 5 last posts if the home_post_list parameters is set to true -->
{{ if .Site.Params.home_post_list }}
<section class="home-posts-list">
<h2>{{ i18n "lastPosts" }}</h2>
<!--
Ranges regular pages by the publish date, in reverse order, to display the
post titles of the section from most recent to older, and the category.
-->
{{ range first 5 .Site.RegularPages.ByPublishDate.Reverse }}
<article>
<a href="{{ .Permalink }}">
{{- .Title -}}
</a>
</article>
{{ end }}
</section>
{{ partial "home_post_list" . }}
{{ end }}
<section class="home-content">
<!-- Content for home.html, as a sort of list page,

View File

@ -12,11 +12,11 @@
<!--
Ranges pages by the publish date, in reverse order, to display the
post titles of the section from most recent to older. It adds to
the title the date and categories (from lists-footer.html)
the title the date and categories (from lists-footer.html).
-->
{{ range .Pages.ByPublishDate.Reverse }}
<article>
<a href="{{ .Permalink }}">
<a href="{{ .Permalink }}">
{{.Title}}
</a>
{{ partial "lists-footer.html" . }}

View File

@ -0,0 +1,14 @@
<section class="home-posts-list">
<h2>{{ i18n "lastPosts" }}</h2>
<!--
Ranges regular pages by the publish date, in reverse order, to display the
post titles of the section from most recent to older, and the category.
-->
{{ range first 5 .Site.RegularPages.ByPublishDate.Reverse }}
<article>
<a href="{{ .Permalink }}">
{{- .Title -}}
</a>
</article>
{{ end }}
</section>