From b17ccbd2fa987395d42313a81b2227f5ec8d88ac Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 28 May 2022 11:12:09 +0200 Subject: Rework the "Latest Publications" section --- layouts/404.html | 6 ++++++ layouts/index.html | 19 +++---------------- layouts/partials/mini-toc.html | 26 ++++++++++++++++++++++++++ layouts/partials/post-toc-summary.html | 7 +++++++ 4 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 layouts/partials/mini-toc.html create mode 100644 layouts/partials/post-toc-summary.html (limited to 'layouts') diff --git a/layouts/404.html b/layouts/404.html index dfe2090..5584276 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -15,3 +15,9 @@ Head back home to try finding it again.

+ +
+ +{{- partial "mini-toc" . -}} + +{{ end }} diff --git a/layouts/index.html b/layouts/index.html index 7dde6eb..d3091c7 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,26 +1,13 @@ {{ define "main" }} -{{- $mainSections := site.Params.mainSections | default (slice "post") }} + {{- with .Content }}
{{ . }}
- {{- $section := where site.RegularPages "Section" "in" $mainSections }} - {{- $section_count := len $section }} - {{- if ge $section_count 1 }}
-
- {{/* TODO: Translate me */}} -

Latest Publications

- -
- {{ end }} + {{- partial "mini-toc" . -}} {{- else }} + {{- $mainSections := site.Params.mainSections | default (slice "post") }} {{ $paginator := .Paginate (where site.RegularPages "Section" "in" $mainSections) }}
{{ with .Title }}

{{ . }}

{{ end }} diff --git a/layouts/partials/mini-toc.html b/layouts/partials/mini-toc.html new file mode 100644 index 0000000..4d4d742 --- /dev/null +++ b/layouts/partials/mini-toc.html @@ -0,0 +1,26 @@ +{{/* Define a section to pull recent posts from. + This will default to the section with the most number of pages. */}} +{{ $mainSections := site.Params.mainSections | default (slice "post") }} + +{{/* Create a variable with that section to use in multiple places. */}} +{{ $section := where site.RegularPages "Section" "in" $mainSections }} + +{{/* Check to see if the section is defined for ranging through it */}} +{{ $sectionCount := len $section }} + +{{ if ge $sectionCount 1 }} + {{ $mxPosts := site.Params.recentPostsSize | default 5 }} + + +{{ end }} diff --git a/layouts/partials/post-toc-summary.html b/layouts/partials/post-toc-summary.html new file mode 100644 index 0000000..d9a70c7 --- /dev/null +++ b/layouts/partials/post-toc-summary.html @@ -0,0 +1,7 @@ + + +{{ .Title }} -- cgit v1.2.3