diff options
author | Paul <paul@brainspark.nl> | 2020-04-01 23:37:01 +0300 |
---|---|---|
committer | Paul <paul@brainspark.nl> | 2020-04-01 23:37:01 +0300 |
commit | 214c53d253e90840cd15c279acbda91d1966ff1f (patch) | |
tree | 126c2f33828a890f96b87af17a5361abe2120845 | |
parent | 1616ecc6edee967a6ad2f66188139f19938023cd (diff) |
Add filtering for shown pages in the simple homeType
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | layouts/partials/homes/simple.html | 22 |
2 files changed, 8 insertions, 16 deletions
@@ -45,6 +45,8 @@ The following home page styles are included for **content/_index.md**: * `simple`, just a plain bootstrap row and col-8. * `no_row`, just a bootstrap container, giving you full flexibility to fill the container. +In the `simple` home page style a list of Regular Pages (not the generated pages) is shown. You can disable this autogenerated list by specifying `showGeneratedList` to `false` in the Site or Page parameters. By setting `homeSections` in the Site parameters you can specify which sections should be shown on the home page. E.g. `homeSections = [ "posts" ]` will only show pages from the *posts* section. If `homeSections` is not specified, all RegularPages are shown. + ### Supported page header styles The following page header styles are included: diff --git a/layouts/partials/homes/simple.html b/layouts/partials/homes/simple.html index 045dcf4..ef5eb30 100644 --- a/layouts/partials/homes/simple.html +++ b/layouts/partials/homes/simple.html @@ -1,5 +1,9 @@ {{- $showGeneratedList := $.Params.showGeneratedList | default $.Site.Params.showGeneratedList | default true }} {{- $showItemMeta := $.Params.showItemMeta | default $.Site.Params.showItemMeta | default true }} +{{- $pages := $.Site.RegularPages -}} +{{- if $.Site.Params.homeSections -}} + {{- $pages = where $.Site.RegularPages "Section" "in" .Site.Params.homeSections -}} +{{- end -}} <div class="container" role="main"> {{- with .Content }} <article> @@ -11,24 +15,10 @@ </article> {{- end }} {{ if eq $showGeneratedList true -}} - {{ with .Sections }} - <div class="row justify-content-center"> - <div class="col-lg-8"> - <ul class="list-group"> - {{ range . }} - <li class="list-group-item d-flex justify-content-between align-items-center"> - <a href="{{.Permalink}}">{{ .Title }}</a> - <span class="badge badge-pill badge-primary">{{ len .Pages }}</span> - </li> - {{ end }} - </ul> - </div> - </div> - {{ end }} - <div class="row justify-content-center mt-3"> <div class="col-lg-8 posts-list"> - {{ range .Paginator.Pages }} + {{ $pag := .Paginate $pages }} + {{ range $pag.Pages }} <article class="list-preview"> <a href="{{ .Permalink }}"> <h2 class="item-title">{{ .Title }}</h2> |