From 899d9fd52d18f87a5f2a26ed1e69484483fe355a Mon Sep 17 00:00:00 2001 From: Dmitry Kolosov Date: Sun, 7 Jun 2020 14:20:40 +0300 Subject: [PATCH] Add pagination for post single page. Close #22 --- README.md | 5 +++++ layouts/_default/single.html | 5 +++++ layouts/partials/paginationPost.html | 14 ++++++++++++++ static/css/style.css | 13 ++++++++++++- 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 layouts/partials/paginationPost.html diff --git a/README.md b/README.md index 662c673..4176e74 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Anubis is a simple minimalist theme for [Hugo blog engine](https://gohugo.io/). - Multilingual mode - Robots.txt - Favorite posts +- Pagination on post single page ## Installation @@ -59,6 +60,7 @@ params: customCSS: - css/my.css # relative path to "static" directory dateFormat: "2006-01-02" + paginationSinglePost: true ``` ### Check your site @@ -86,6 +88,9 @@ For production — allow all, for other — disallow all. ### Favorite posts 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 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). diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 775a2f6..38f664d 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -9,6 +9,11 @@ {{ partial "postInfo.html" . }} + + {{ if .Site.Params.paginationSinglePost}} + {{ partial "paginationPost.html" . }} + {{ end }} + {{ if .Site.DisqusShortname }} {{ template "_internal/disqus.html" . }} {{ end }} diff --git a/layouts/partials/paginationPost.html b/layouts/partials/paginationPost.html new file mode 100644 index 0000000..bed2af9 --- /dev/null +++ b/layouts/partials/paginationPost.html @@ -0,0 +1,14 @@ +{{ if or ( .PrevInSection ) ( .NextInSection ) }} + +{{ end }} \ No newline at end of file diff --git a/static/css/style.css b/static/css/style.css index 43d9c94..7e37bf9 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -351,11 +351,18 @@ article img { color: #333333; } -.pagination-item a:hover, .pagination-item a:focus { +.pagination-item a:hover, .pagination-item a:focus { color: #a31d1d; border-bottom: 0; } +.post-pagination .pagination-item { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + max-width: 16em; +} + /* Footer */ footer { @@ -418,4 +425,8 @@ ul.language-select > li { header nav a { margin-left: 5%; } + + .post-pagination .pagination-item { + max-width: 10em; + } } \ No newline at end of file