#692, #723: Redesign blog, add thumbnails support and pagination

This commit is contained in:
Alex Shpak
2025-09-18 10:12:03 +02:00
parent 2745893250
commit 6f472b3009
9 changed files with 103 additions and 24 deletions
+28
View File
@@ -0,0 +1,28 @@
{{- if .Paginator -}}
<div class="flex flex-wrap justify-between">
<span>
{{- with .Paginator.Prev }}
<a href="{{ .URL }}" class="flex align-center">
<img src="{{ "svg/backward.svg" | relURL }}" class="book-icon" alt="Previous" />
</a>
{{ end }}
</span>
{{ if gt (len .Paginator.Pagers) 1 }}
<span class="flex gap">
{{- $currentPageNumber := .Paginator.PageNumber -}}
{{- range $pageIndex := (slice -2 -1 0 1 2) -}}
{{- with index $.Paginator.Pagers (add $currentPageNumber $pageIndex -1) -}}
<a {{if ne $currentPageNumber .PageNumber }}href="{{ .URL }}"{{end}}>{{ .PageNumber }}</a>
{{- end -}}
{{- end -}}
</span>
{{ end }}
<span>
{{- with .Paginator.Next }}
<a href="{{ .URL }}" class="flex align-center">
<img src="{{ "svg/forward.svg" | relURL }}" class="book-icon" alt="Next" />
</a>
{{ end }}
</span>
</div>
{{- end -}}
@@ -0,0 +1,18 @@
<div class="flex flex-wrap justify-between">
<span>
{{ with .NextInSection }}
<a href="{{ .RelPermalink }}" class="flex align-center">
<img src="{{ "svg/backward.svg" | relURL }}" class="book-icon" alt="Previous" title="{{ partial "docs/title" . }}" />
<span>{{ partial "docs/title" . }}</span>
</a>
{{ end }}
</span>
<span>
{{ with .PrevInSection }}
<a href="{{ .RelPermalink }}" class="flex align-center">
<span>{{ partial "docs/title" . }}</span>
<img src="{{ "svg/forward.svg" | relURL }}" class="book-icon" alt="Next" title="{{ partial "docs/title" . }}" />
</a>
{{ end }}
</span>
</div>
+19 -7
View File
@@ -1,17 +1,25 @@
{{ define "main" }}
{{ range sort .Paginator.Pages }}
<article class="markdown book-post">
<article class="book-post markdown">
<h2>
<a href="{{ .RelPermalink }}">{{ partial "docs/title.html" . }}</a>
<a href="{{ .RelPermalink }}">{{ partial "docs/title" . }}</a>
</h2>
{{ partial "docs/post-meta" . }}
<div class="book-post-content">
{{- .Summary -}}
<div class="book-post-container flex gap">
<div>
{{ partial "docs/post-meta" . }}
<div class="book-post-content markdown-inner">
{{- .Summary | truncate 256 -}}
</div>
</div>
{{- $thumbnail := default "thumbnail.*" .Params.BookPostThumbnail -}}
{{- with or (.Resources.GetMatch $thumbnail) (resources.GetMatch $thumbnail) -}}
<div class="book-post-thumbnail">
<img src="{{ .RelPermalink }}" />
</div>
{{- end -}}
</div>
</article>
{{ end }}
{{ template "_internal/pagination.html" . }}
{{ end }}
{{ define "toc-container" }}
@@ -25,3 +33,7 @@
{{ define "toc" }}
{{ partial "docs/taxonomy" . }}
{{ end }}
{{ define "footer" }}
{{ partial "docs/pagination.html" . }}
{{ end }}
+6 -2
View File
@@ -1,10 +1,10 @@
{{ define "main" }}
<article class="markdown book-post">
<h1>
{{ partial "docs/title.html" . }}
{{ partial "docs/title" . }}
</h1>
{{ partial "docs/post-meta" . }}
<div class="book-post-content">
<div class="book-post-content markdown-inner">
{{- .Content -}}
</div>
</article>
@@ -13,3 +13,7 @@
{{ define "toc" }}
{{ partial "docs/toc" . }}
{{ end }}
{{ define "footer" }}
{{ partial "docs/post-prev-next" . }}
{{ end }}
+1 -1
View File
@@ -2,7 +2,7 @@
{{ range sort .Paginator.Pages }}
<article class="markdown book-post">
<h2>
<a href="{{ .RelPermalink }}">{{ partial "docs/title.html" . }}</a>
<a href="{{ .RelPermalink }}">{{ partial "docs/title" . }}</a>
</h2>
{{ partial "docs/post-meta" . }}
<div class="book-post-content">