added extra content option for more home page like post views

This commit is contained in:
Gabriele Musco 2021-06-12 15:07:39 +02:00
parent 79bc934c75
commit 18a213cf31
No known key found for this signature in database
GPG Key ID: 8539FD3454380B83
6 changed files with 50 additions and 36 deletions

View File

@ -36,6 +36,9 @@ summaryLength = 70 # number of words for article summaries
author = "Gabriele Musco" author = "Gabriele Musco"
description = "A description for my website" # this will be added as metadata description = "A description for my website" # this will be added as metadata
posts = "posts" # content directory where to find home page posts; default searches in "posts" and "post"
extraContentDirs = [] # other content directories to render similarly to the home page
# It's best to put these icons in the "static" folder of your site # It's best to put these icons in the "static" folder of your site
logo = "/logo.svg" logo = "/logo.svg"
favicon = "/favicon.png" # 32x32 favicon = "/favicon.png" # 32x32

View File

@ -1,15 +1,8 @@
{{ define "main" }} {{ define "main" }}
<h2> {{ if in (site.Params.extraContentDirs | default (slice)) .Section }}
{{ $title := .Title }} <h1>{{ .Section | humanize }}</h1>
{{ $section := .Section | humanize }} {{- partial "home_post_list.html" (dict "Ctx" . "AllPostsList" .Pages) -}}
{{ if and (ne $section $title) (ne $section "Tags") (ne $title (printf "%ss" $section)) }} {{ else }}
{{ $section }}: {{- partial "simple_posts_list.html" . -}}
{{ end }} {{ end }}
{{ if and (eq $section "Tags") (ne $section $title) }}Tag: #{{ end }}{{ $title }}
</h2>
<ul class="list">
{{ range .Pages }}
<li><span class="date">{{ .Date.Format "2006-01-02" }}</span> <a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>
{{ end }} {{ end }}

View File

@ -2,28 +2,7 @@
{{/* get all the pages that are regular posts and not pages */}} {{/* get all the pages that are regular posts and not pages */}}
{{ $postsDir := .Site.Params.Posts | default (slice "posts" "post") }} {{ $postsDir := .Site.Params.Posts | default (slice "posts" "post") }}
{{ $allPostsList := where .Site.RegularPages "Section" "in" $postsDir }} {{ $allPostsList := where site.RegularPages "Section" "in" $postsDir }}
{{ $featuredPostsList := slice }} {{- partial "home_post_list.html" (dict "Ctx" . "AllPostsList" $allPostsList) -}}
{{ $postsList := $allPostsList }}
{{ $pagination := slice }}
{{ if .Site.Params.enableFeatured | default false }}
{{ $featuredPostsList = where $allPostsList "Params.featured" true }}
{{ $postsList = union (where $allPostsList "Params.featured" false) (where $allPostsList "Params.featured" nil) }}
{{ $pagination = (.Paginate $postsList).Pages }}
{{ if eq .Paginator.PageNumber 1 }}
{{- partial "featured_articles.html" $featuredPostsList -}}
{{ end }}
{{ else }}
{{ $pagination = (.Paginate $postsList).Pages }}
{{ end }}
{{/* pagination */}}
<div class="postlist {{ if .Site.Params.gridView }}gridView{{ end }}" id="postlist">
{{ range $pagination }}
{{- partial "article_card.html" . -}}
{{ end }}
</div>
<div id="getNextBtnContainer"></div>
{{- partial "paginator.html" . -}}
{{ end }} {{ end }}

View File

@ -19,6 +19,9 @@
<ul id="main-nav"> <ul id="main-nav">
<li><a href="/">Home</a></li> <li><a href="/">Home</a></li>
<li><a href="/posts">Posts</a></li> <li><a href="/posts">Posts</a></li>
{{ range site.Params.extraContentDirs }}
<li><a href="/{{ . }}">{{ . | humanize }}</a></li>
{{ end }}
{{ $pagesDir := .Site.Params.Pages | default (slice "pages") }} {{ $pagesDir := .Site.Params.Pages | default (slice "pages") }}
{{ $pagesList := where .Site.RegularPages "Section" "in" $pagesDir }} {{ $pagesList := where .Site.RegularPages "Section" "in" $pagesDir }}
{{ range $pagesList }} {{ range $pagesList }}

View File

@ -0,0 +1,23 @@
{{ $allPostsList := .AllPostsList }}
{{ $postsList := $allPostsList }}
{{ $featuredPostsList := slice }}
{{ $pagination := slice }}
{{ if site.Params.enableFeatured | default false }}
{{ $featuredPostsList = where $allPostsList "Params.featured" true }}
{{ $postsList = union (where $allPostsList "Params.featured" false) (where $allPostsList "Params.featured" nil) }}
{{ $pagination = (.Ctx.Paginate $postsList).Pages }}
{{ if eq .Ctx.Paginator.PageNumber 1 }}
{{- partial "featured_articles.html" $featuredPostsList -}}
{{ end }}
{{ else }}
{{ $pagination = (.Ctx.Paginate $postsList).Pages }}
{{ end }}
{{/* pagination */}}
<div class="postlist {{ if site.Params.gridView }}gridView{{ end }}" id="postlist">
{{ range $pagination }}
{{- partial "article_card.html" . -}}
{{ end }}
</div>
<div id="getNextBtnContainer"></div>
{{- partial "paginator.html" .Ctx -}}

View File

@ -0,0 +1,13 @@
<h2>
{{ $title := .Title }}
{{ $section := .Section | humanize }}
{{ if and (ne $section $title) (ne $section "Tags") (ne $title (printf "%ss" $section)) }}
{{ $section }}:
{{ end }}
{{ if and (eq $section "Tags") (ne $section $title) }}Tag: #{{ end }}{{ $title }}
</h2>
<ul class="list">
{{ range .Pages }}
<li><span class="date">{{ .Date.Format "2006-01-02" }}</span> <a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>