From b7558aca44b3c8899c1515fc57e6b9f38db7f8d2 Mon Sep 17 00:00:00 2001 From: Jinuk Im Date: Thu, 5 Oct 2023 04:13:49 +0900 Subject: [PATCH] feat: support empty prev/next pagination (#130) [skip ci] --- layouts/partials/components/pager.html | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/layouts/partials/components/pager.html b/layouts/partials/components/pager.html index 8917dcd..2ecc6a7 100644 --- a/layouts/partials/components/pager.html +++ b/layouts/partials/components/pager.html @@ -5,15 +5,23 @@ {{- $prev := cond $reversePagination .PrevInSection .NextInSection -}} {{- $next := cond $reversePagination .NextInSection .PrevInSection -}} -{{- with .Params.prev -}} - {{- with $.Site.GetPage . -}} - {{- if $reversePagination }}{{ $next = . }}{{ else }}{{ $prev = . }}{{ end -}} +{{- if eq .Params.prev false }} + {{- if $reversePagination }}{{ $next = false }}{{ else }}{{ $prev = false }}{{ end -}} +{{ else }} + {{- with .Params.prev -}} + {{- with $.Site.GetPage . -}} + {{- if $reversePagination }}{{ $next = . }}{{ else }}{{ $prev = . }}{{ end -}} + {{- end -}} {{- end -}} {{- end -}} -{{- with .Params.next -}} - {{- with $.Site.GetPage . -}} - {{- if $reversePagination }}{{ $prev = . }}{{ else }}{{ $next = . }}{{ end -}} +{{- if eq .Params.next false }} + {{- if $reversePagination }}{{ $prev = false }}{{ else }}{{ $next = false }}{{ end -}} +{{ else }} + {{- with .Params.next -}} + {{- with $.Site.GetPage . -}} + {{- if $reversePagination }}{{ $prev = . }}{{ else }}{{ $next = . }}{{ end -}} + {{- end -}} {{- end -}} {{- end -}}