Debian Codegraph @

example/templates/macros/blog.html

raw
1 {% macro render_blog_post(post, from_index=false, blog_post=true) %}
2 <div class="blog-post">
3 {% if from_index %}
4 <h2><a href="{{ post|url }}">{{ post.title }}</a></h2>
5 {% else %}
6 <h2>{{ post.title }}</h2>
7 {% endif %}
8 <p class="meta">
9 written by
10 {% if post.twitter_handle %}
11 <a href="https://twitter.com/{{ post.twitter_handle
12 }}">{{ post.author or post.twitter_handle }}</a>
13 {% else %}
14 {{ post.author }}
15 {% endif %}
16 on {{ post.pub_date }}
17 </p>
18 {{ post.body }}
19 </div>
20 {# display nav links to other blog posts, but hide on parent blog page #}
21 {% if blog_post %}
22 {{ render_blog_sibling_nav(post) }}
23 {% endif %}
24 {% endmacro %}
25
26 {% macro render_blog_sibling_nav(post, from_index=false) %}
27 {% from "macros/pagination.html" import render_pagination %}
28 <div class="blog-nav">
29 <br>
30 {% set siblings = post.get_siblings() %}
31
32 {# prev/next are swapped since blog children ordered_by is negative
33 {# nav logic for previous page #}
34 {% if siblings.next_page %}
35 {% set prev = siblings.next_page %}
36 {% endif %}
37
38 {# nav logic for next page #}
39 {% if siblings.prev_page %}
40 {% set next = siblings.prev_page %}
41 {% endif %}
42
43 {# previous / nex nav links #}
44 {% if prev %}
45 <a href="{{ prev|url }}" title="{{ prev.title }}" >&laquo; Previous</a>
46 {% endif %}
47
48 {% if prev %} | {% endif %}
49 {{ post.title }}
50 {% if next %} | {% endif %}
51
52 {% if next %}
53 <a href="{{ next|url }}" title="{{ next.title }}" >Next &raquo;</a>
54 {% endif %}
55 </div>
56 {% endmacro %}