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 { .posts-list {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin-bottom: .5em; margin-bottom: var(--pico-spacing);
> article { > article {
padding-bottom: .5rem; padding-bottom: var(--pico-spacing);
padding-left: var(--pico-spacing);
} }
} }
/* List of last posts, on the home page*/ /* List of last posts, on the home page*/

View File

@ -1,20 +1,7 @@
{{ define "main" }} {{ define "main" }}
<!-- List the 5 last posts if the home_post_list parameters is set to true --> <!-- List the 5 last posts if the home_post_list parameters is set to true -->
{{ if .Site.Params.home_post_list }} {{ if .Site.Params.home_post_list }}
<section class="home-posts-list"> {{ partial "home_post_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>
{{ end }} {{ end }}
<section class="home-content"> <section class="home-content">
<!-- Content for home.html, as a sort of list page, <!-- Content for home.html, as a sort of list page,

View File

@ -12,7 +12,7 @@
<!-- <!--
Ranges pages by the publish date, in reverse order, to display the 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 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 }} {{ range .Pages.ByPublishDate.Reverse }}
<article> <article>

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>