Blog: Check if blog_archive_prev/next exist before showing link

Also minor cleanup of the classes and excessive indenting.
This commit is contained in:
2017-10-05 16:38:53 +02:00
committed by Sybren A. Stüvel
parent 01dab4188c
commit 6d8870ba25
4 changed files with 61 additions and 49 deletions

View File

@@ -64,13 +64,14 @@ a.btn.btn-default.button-create(href="{{url_for('nodes.posts_create', project_id
| {% for node in posts[1:] %}
| {% if loop.first %}
h4.blog_index-title Blasts from the past
.blog-archive-navigation
span Blasts from the past
| {% endif %}
| {{ render_blog_list_item(node) }}
| {% endfor %}
| {% if more_posts_available %}
h4.blog_index-title.blog-archive
.blog-archive-navigation
a(href="{{ project.blog_archive_url }}")
| {{posts_meta.total - posts|length}} more blog posts over here
i.pi-angle-right
@@ -84,22 +85,36 @@ h4.blog_index-title.blog-archive
| {% endif %} {# posts #}
| {% endmacro %}
//- ******************************************************* -//
//- Macro for rendering the navigation buttons for prev/next pages -//
| {% macro render_archive_pagination(project) %}
h4.blog_index-title.blog-archive
a(class="{% if not project.blog_archive_prev %}disabled{% endif %}",
.blog-archive-navigation
| {% if project.blog_archive_prev %}
a.archive-nav-button(
href="{{ project.blog_archive_prev }}", rel="prev")
i.pi-angle-left
| Previous page
| {% else %}
span.archive-nav-button
i.pi-angle-left
| Previous page
| {% endif %}
a(href="{{ url_for('main.project_blog', project_url=project.url) }}", rel="prev")
a.archive-nav-button(
href="{{ url_for('main.project_blog', project_url=project.url) }}")
| Blog Index
a(class="{% if not project.blog_archive_next %}disabled{% endif %}",
| {% if project.blog_archive_next %}
a.archive-nav-button(
href="{{ project.blog_archive_next }}", rel="next")
| Next page
i.pi-angle-right
| {% else %}
span.archive-nav-button
| Next page
i.pi-angle-right
| {% endif %}
| {% endmacro %}
| {% macro render_archive(project, posts, posts_meta) %}