Support pagination for the blog

This commit is contained in:
southerntofu 2020-03-29 22:08:09 +02:00
parent 349d79627a
commit febdc49fbd
6 changed files with 40 additions and 4 deletions

View File

@ -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"

View File

@ -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!

View File

@ -1,3 +1,5 @@
+++
title = "Derniers articles"
paginate_by = 10
sort_by = "date"
+++

View File

@ -1,3 +1,5 @@
+++
title = "Latest articles"
paginate_by = 10
sort_by = "date"
+++

View File

@ -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;
}

View File

@ -4,9 +4,10 @@
{% block main %}
<section class="h-feed">
<h1 class="p-name">{{ section.title }}</h1>
<h1><span class="p-name">{{ section.title }}</span>{% if paginator and paginator.number_pagers > 1 %} ({{ paginator.current_index }}/{{ paginator.number_pagers }}){% endif %}</h1>
<a class="u-url" hidden aria-hidden=true href="{{ section.permalink }}">Permalink</a>
{% for page in section.pages %}
{% set pages = paginator.pages| default(value=section.pages) %}
{% for page in pages %}
<article>
<div>
<a class="u-url" href="{{ page.permalink }}"><h2>{{ page.title }}</h2></a>
@ -24,5 +25,21 @@
{% endif %}
</article>
{% endfor %}
</article>
{% if paginator and paginator.number_pagers > 1 %}
<aside class="pagination">
{% if paginator.previous %}
<a href="{{ paginator.previous }}">
<--&nbsp;&nbsp;{% if lang %}{{ trans(key="previousPage", lang=lang) }}
{% else %}{{ trans(key="previousPage") }}{% endif %}
</a>
{% endif %}
{% if paginator.next %}
<a href="{{ paginator.next }}">
{% if lang %}{{ trans(key="nextPage", lang=lang) }}
{% else %}{{ trans(key="nextPage") }}{% endif %}&nbsp;&nbsp;-->
</a>
{% endif %}
</aside>
{% endif %}
</section>
{% endblock %}