From 778ee39137dc69e8761c73af7a731ffc51854397 Mon Sep 17 00:00:00 2001 From: Aditya Telange <21258296+adityatelange@users.noreply.github.com> Date: Thu, 28 Jan 2021 00:05:30 +0530 Subject: [PATCH] init feat Prev Next post links on single post page (#180) usage => in site config add Params: ShowPostNavLinks: true --- assets/css/post-single.css | 44 ++++++++++++++++++++++++++++++++++-- layouts/_default/single.html | 21 +++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/assets/css/post-single.css b/assets/css/post-single.css index f5fa4f42..c37d1255 100644 --- a/assets/css/post-single.css +++ b/assets/css/post-single.css @@ -294,7 +294,8 @@ } .post-tags a, -.share-buttons { +.share-buttons, +.paginav { border-radius: var(--radius); background: var(--code-bg); border: 1px solid var(--border) @@ -310,7 +311,8 @@ background: var(--code-bg) } -.post-tags a:hover { +.post-tags a:hover, +.paginav a:hover { background: var(--border) } @@ -374,3 +376,41 @@ h6:hover .anchor { .post-content table::-webkit-scrollbar-thumb { border-width: 2px; } + +.paginav { + margin: 10px 0; + display: flex; + line-height: 30px; + border-radius: var(--radius); +} + +.paginav a { + padding-inline-start: 14px; + padding-inline-end: 14px; + border-radius: var(--radius); +} + +.paginav .title { + letter-spacing: 1px; + text-transform: uppercase; + font-size: small; + color: var(--secondary); +} + +.paginav .prev, +.paginav .next { + width: 50%; +} + +.paginav span:hover:not(.title) { + box-shadow: 0 1px 0; +} + +.paginav .next { + margin-inline-start: auto; + text-align: right; +} + +[dir="rtl"] .paginav .next { + text-align: left; +} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 84b70d5d..b6298ac7 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -57,6 +57,27 @@ {{- end }} {{- end }} + {{- if .Site.Params.ShowPostNavLinks }} + {{- $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} + {{- if and (gt (len $pages) 1) (in $pages . ) }} + + {{- end }} + {{- end }} {{- if (and .Site.Params.ShowShareButtons (ne .Params.disableShare true) ) }} {{- partial "share_icons.html" . }} {{- end }}