Add pagination for post single page. Close #22

This commit is contained in:
Dmitry Kolosov 2020-06-07 14:20:40 +03:00
parent 9ea38661fb
commit 899d9fd52d
4 changed files with 36 additions and 1 deletions

View File

@ -17,6 +17,7 @@ Anubis is a simple minimalist theme for [Hugo blog engine](https://gohugo.io/).
- Multilingual mode - Multilingual mode
- Robots.txt - Robots.txt
- Favorite posts - Favorite posts
- Pagination on post single page
## Installation ## Installation
@ -59,6 +60,7 @@ params:
customCSS: customCSS:
- css/my.css # relative path to "static" directory - css/my.css # relative path to "static" directory
dateFormat: "2006-01-02" dateFormat: "2006-01-02"
paginationSinglePost: true
``` ```
### Check your site ### Check your site
@ -86,6 +88,9 @@ For production — allow all, for other — disallow all.
### Favorite posts ### Favorite posts
To mark posts as favorite just add `favorite: true` in post's front matter. It adds a "★" icon nearby post's title. To mark posts as favorite just add `favorite: true` in post's front matter. It adds a "★" icon nearby post's title.
### Pagination on post single page
Enabled by `paginationSinglePost` param in `params` section of config.
## Contributing ## Contributing
If you find a bug or have an idea for a feature, feel free to write an [issue](https://github.com/mitrichius/hugo-theme-anubis/issues). If you find a bug or have an idea for a feature, feel free to write an [issue](https://github.com/mitrichius/hugo-theme-anubis/issues).

View File

@ -9,6 +9,11 @@
</div> </div>
{{ partial "postInfo.html" . }} {{ partial "postInfo.html" . }}
</article> </article>
{{ if .Site.Params.paginationSinglePost}}
{{ partial "paginationPost.html" . }}
{{ end }}
{{ if .Site.DisqusShortname }} {{ if .Site.DisqusShortname }}
{{ template "_internal/disqus.html" . }} {{ template "_internal/disqus.html" . }}
{{ end }} {{ end }}

View File

@ -0,0 +1,14 @@
{{ if or ( .PrevInSection ) ( .NextInSection ) }}
<div class="pagination post-pagination">
<div class="left pagination-item {{ if not .PrevInSection }}disabled{{ end }}">
{{ if .PrevInSection }}
<a href="{{ .PrevInSection.Permalink | relLangURL }}">{{ .PrevInSection.Title }}</a>
{{ end }}
</div>
<div class="right pagination-item {{ if not .NextInSection }}disabled{{ end }}">
{{ if .NextInSection }}
<a href="{{ .NextInSection.Permalink | relLangURL }}">{{ .NextInSection.Title }}</a>
{{ end }}
</div>
</div>
{{ end }}

View File

@ -356,6 +356,13 @@ article img {
border-bottom: 0; border-bottom: 0;
} }
.post-pagination .pagination-item {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 16em;
}
/* Footer */ /* Footer */
footer { footer {
@ -418,4 +425,8 @@ ul.language-select > li {
header nav a { header nav a {
margin-left: 5%; margin-left: 5%;
} }
.post-pagination .pagination-item {
max-width: 10em;
}
} }