From febdc49fbd10e39d0594dcbe254ac65b5f65ebf5 Mon Sep 17 00:00:00 2001 From: southerntofu Date: Sun, 29 Mar 2020 22:08:09 +0200 Subject: [PATCH] Support pagination for the blog --- config.toml | 4 ++++ content/blog/2020/new-homepage/index.fr.md | 2 +- content/blog/_index.fr.md | 2 ++ content/blog/_index.md | 2 ++ sass/style.scss | 11 +++++++++++ templates/section.html | 23 +++++++++++++++++++--- 6 files changed, 40 insertions(+), 4 deletions(-) diff --git a/config.toml b/config.toml index 2ac55b0..c87255a 100644 --- a/config.toml +++ b/config.toml @@ -27,6 +27,10 @@ name = "tildegit" [translations.fr] source = "Source de cette page" readmore = "Lire la suite" +previousPage = "Page précédente" +nextPage = "Page suivante" [translations.en] source = "Source for this page" readmore = "Read more" +previousPage = "Previous page" +nextPage = "Next page" diff --git a/content/blog/2020/new-homepage/index.fr.md b/content/blog/2020/new-homepage/index.fr.md index 2ef5a25..04bd865 100644 --- a/content/blog/2020/new-homepage/index.fr.md +++ b/content/blog/2020/new-homepage/index.fr.md @@ -1,7 +1,7 @@ +++ title = "Un nouveau site pour dnsmanager" slug = "nouveau-site" -date = 2020-03-29 +date = 2020-03-30 +++ Aujourd'hui, nous ouvrons un nouveau site web pour dnsmanager! diff --git a/content/blog/_index.fr.md b/content/blog/_index.fr.md index 59d8720..4646c76 100644 --- a/content/blog/_index.fr.md +++ b/content/blog/_index.fr.md @@ -1,3 +1,5 @@ +++ title = "Derniers articles" +paginate_by = 10 +sort_by = "date" +++ diff --git a/content/blog/_index.md b/content/blog/_index.md index e0214d1..68fe230 100644 --- a/content/blog/_index.md +++ b/content/blog/_index.md @@ -1,3 +1,5 @@ +++ title = "Latest articles" +paginate_by = 10 +sort_by = "date" +++ diff --git a/sass/style.scss b/sass/style.scss index 8933d23..9c2965a 100644 --- a/sass/style.scss +++ b/sass/style.scss @@ -25,6 +25,17 @@ article > div:first-child { font-weight: bold; } +.pagination { + background-color: rgb(239, 239, 239); + margin-top: 1rem; + text-align: center; + > a { + font-weight: bolder; + font-variant: small-caps; + padding: 0 2rem; + } +} + main { margin: 1rem 0; } diff --git a/templates/section.html b/templates/section.html index 43dc8ed..69a9af7 100644 --- a/templates/section.html +++ b/templates/section.html @@ -4,9 +4,10 @@ {% block main %}
-

{{ section.title }}

+

{{ section.title }}{% if paginator and paginator.number_pagers > 1 %} ({{ paginator.current_index }}/{{ paginator.number_pagers }}){% endif %}

- {% for page in section.pages %} + {% set pages = paginator.pages| default(value=section.pages) %} + {% for page in pages %} {% endfor %} - + {% if paginator and paginator.number_pagers > 1 %} + + {% endif %} +
{% endblock %}