add featured posts, tweak ToC a bit

This commit is contained in:
John Bowdre 2023-08-21 19:54:33 -05:00
parent 0ad452dc28
commit 27cdf6ee03
4 changed files with 64 additions and 20 deletions

View file

@ -3,6 +3,7 @@ usePageBundles = true
description = "while (true) { bugs++; }"
mainSections = ["posts"]
fallBackOgImage = "images/broken-computer.svg"
numberOfFeaturedPosts = 5
# Comments
comments = true

View file

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="{{- site.Language.Lang -}}">
<head>
{{- partial "head.html" . -}}
</head>
<body>
<div class="page">
<header class="page__header">
{{- partial "header.html" . -}}
</header>
<section class="page__body">
{{- block "main" . }}{{- end }}
</section>
<section class="page__aside">
<div class="aside__about">
{{- partial "about.html" . -}}
</div>
<hr>
<div class="aside__content">
{{- partial "aside" . }}
</div>
</section>
<footer class="page__footer">
{{- partial "footer.html" . -}}
</footer>
</div>
</body>
</html>

View file

@ -3,10 +3,6 @@
<header class="content__header">
<h1>{{ .Title | markdownify }}</h1>
</header>
{{ if .Params.toc }}
<aside>
</aside>
{{ end }}
{{- with .Param "lastmod" -}}
{{- $ageDays = div (sub now.Unix .Unix) 86400 -}}
{{- end -}}
@ -31,19 +27,3 @@
{{- end }}
<footer class="content__footer"></footer>
{{ end }}
{{define "aside" }}
{{ if .Params.description }}<p>{{ .Params.description }}</p>{{ end }}
{{ if or (.Params.author) (.Params.date) }}
<p>
{{ if .Params.author }}By {{ .Params.author }}{{ if .Date }}, {{ end }}{{ end }}
{{ if .Date }}{{ .Date.Format "2006-01-02" }}{{ end }}
</p>
{{ end }}
{{ if and (.Params.toc) (gt .WordCount 400 ) (gt (len .TableOfContents) 180) (.TableOfContents) }}
<hr>
On this page:
{{ .TableOfContents }}
{{ end }}
{{ end }}

View file

@ -0,0 +1,27 @@
{{ if .Params.description }}<p>{{ .Params.description }}</p>{{ end }}
{{ if or (.Params.author) (.Params.date) }}
<p>
{{ if .Params.author }}By {{ .Params.author }}{{ if .Date }}, {{ end }}{{ end }}
{{ if .Date }}{{ .Date.Format "2006-01-02" }}{{ end }}
</p>
{{ end }}
{{ if and (gt .WordCount 400 ) (gt (len .TableOfContents) 180) }}
<hr>
<h2>On this page</h2>
{{ .TableOfContents }}
{{ end }}
{{- $posts := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{- $featured := default 8 .Site.Params.numberOfFeaturedPosts }}
{{- $featuredPosts := first $featured (where $posts "Params.featured" true)}}
{{- with $featuredPosts }}
<h2>Featured Posts</h2>
<ul>
{{- range . }}
<li>
<a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title | markdownify }}</a>
</li>
{{- end }}
</ul>
{{- end }}