From a8e49cfedfeba14b702db8913b984c87ce20e595 Mon Sep 17 00:00:00 2001 From: welpo Date: Sun, 5 Mar 2023 19:48:16 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20use=20consiste?= =?UTF-8?q?nt=20pagination?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sass/parts/_pagination.scss | 30 +++++++++++++++++++++++++++++ templates/base.html | 3 +-- templates/cards.html | 14 +------------- templates/section.html | 38 ++++++++++++++----------------------- 4 files changed, 46 insertions(+), 39 deletions(-) create mode 100644 sass/parts/_pagination.scss diff --git a/sass/parts/_pagination.scss b/sass/parts/_pagination.scss new file mode 100644 index 0000000..a6e51d6 --- /dev/null +++ b/sass/parts/_pagination.scss @@ -0,0 +1,30 @@ +.pagination { + display: flex; + justify-content: space-between; + align-items: center; + margin-top: 2rem; + font-size: 1em; + list-style: none; + padding: 0; + + li { + margin-right: 1rem; + } + + .page-link { + background: transparent; + border: none; + cursor: pointer; + padding: 0; + + &.disabled { + opacity: 0.5; + pointer-events: none; + } + } + + .page-numbers { + font-size: 0.9rem; + color: var(--meta-color); + } +} diff --git a/templates/base.html b/templates/base.html index 4e9c324..dee73e3 100644 --- a/templates/base.html +++ b/templates/base.html @@ -4,9 +4,8 @@ {% import "macros/page_desc.html" as macros_page_desc %} {% import "macros/content.html" as macros_content %} {% import "macros/cards_posts.html" as macros_cards_posts %} -{% import "macros/list_title.html" as macros_list_title %} {% import "macros/set_title.html" as macros_set_title %} - +{% import "macros/paginate.html" as macros_paginate %} diff --git a/templates/cards.html b/templates/cards.html index 8698001..4f02fa5 100644 --- a/templates/cards.html +++ b/templates/cards.html @@ -18,18 +18,6 @@ {% if paginator %} - + {{ macros_paginate::paginate() }} {% endif %} {% endblock main_content %} diff --git a/templates/section.html b/templates/section.html index a2cc00c..a96ace0 100644 --- a/templates/section.html +++ b/templates/section.html @@ -2,39 +2,29 @@ {% block main_content %} {% if section.extra.section_path -%} -{% set section = get_section(path=section.extra.section_path) %} + {% set extra_section = get_section(path=section.extra.section_path) %} {% endif -%} {%- if section.extra.header %} - {{ macros_page_desc::page_desc(desc=section.extra.header, page=section) }} + {{ macros_page_desc::page_desc(desc=section.extra.header, page=section) }} {% endif -%}
-
- {{ macros_page_header::page_header(title=section.title) }} -
- {%- if paginator %} - {%- set show_pages = paginator.pages -%} - {% else %} - {%- set show_pages = section.pages -%} - {% endif -%} +
+ {{ macros_page_header::page_header(title=section.title) }} +
- {{ macros_list_posts::list_posts(pages=show_pages) }} + {%- if paginator %} + {%- set pages = paginator.pages -%} + {% else %} + {%- set pages = extra_section.pages -%} + {% endif -%} + + {% set max = section.extra.max_posts | default(value=999999) %} + {{ macros_list_posts::list_posts(posts=pages, max=max) }}
{% if paginator %} - + {{ macros_paginate::paginate() }} {% endif %} {% endblock main_content %}