init feat Prev Next post links on single post page (#180)

usage =>
in site config add 
Params:
   ShowPostNavLinks: true
This commit is contained in:
Aditya Telange 2021-01-28 00:05:30 +05:30 committed by GitHub
parent 3c3888f7ad
commit 778ee39137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 63 additions and 2 deletions

View File

@ -294,7 +294,8 @@
} }
.post-tags a, .post-tags a,
.share-buttons { .share-buttons,
.paginav {
border-radius: var(--radius); border-radius: var(--radius);
background: var(--code-bg); background: var(--code-bg);
border: 1px solid var(--border) border: 1px solid var(--border)
@ -310,7 +311,8 @@
background: var(--code-bg) background: var(--code-bg)
} }
.post-tags a:hover { .post-tags a:hover,
.paginav a:hover {
background: var(--border) background: var(--border)
} }
@ -374,3 +376,41 @@ h6:hover .anchor {
.post-content table::-webkit-scrollbar-thumb { .post-content table::-webkit-scrollbar-thumb {
border-width: 2px; 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;
}

View File

@ -57,6 +57,27 @@
{{- end }} {{- end }}
</ul> </ul>
{{- end }} {{- end }}
{{- if .Site.Params.ShowPostNavLinks }}
{{- $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}
{{- if and (gt (len $pages) 1) (in $pages . ) }}
<nav class="paginav">
{{- with $pages.Next . }}
<a class="prev" href="{{.Permalink}}">
<span class="title">« {{ i18n "prev_page" }}</span>
<br>
<span>{{- .Name -}}</span>
</a>
{{- end}}
{{- with $pages.Prev . }}
<a class="next" href="{{.Permalink}}">
<span class="title">{{ i18n "next_page" }} »</span>
<br>
<span>{{- .Name -}}</span>
</a>
{{- end}}
</nav>
{{- end }}
{{- end }}
{{- if (and .Site.Params.ShowShareButtons (ne .Params.disableShare true) ) }} {{- if (and .Site.Params.ShowShareButtons (ne .Params.disableShare true) ) }}
{{- partial "share_icons.html" . }} {{- partial "share_icons.html" . }}
{{- end }} {{- end }}