-
-
Notifications
You must be signed in to change notification settings - Fork 269
/
Copy pathpostcard_categories.html
64 lines (57 loc) · 2.29 KB
/
postcard_categories.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{%- macro pathtocategory(category) -%}
{% set path = "blog/category/" + category %}
{{ pathto(path) }}
{%- endmacro -%}
{%- macro setcolorclass(active) -%}
{% if active %}
{{ "sd-text-success" }}
{% else %}
{{ "sd-text-muted" }}
{% endif %}
{%- endmacro -%}
{%- macro category_item(name, icon, active) -%}
<a href="{{ pathtocategory(name) }}" class="{{ setcolorclass(active) }}" title="{{ name }}">
<span class="fas {{ icon }}"></span>
<label class="sr-only">{{ name }}</label>
</a>
{%- endmacro -%}
<!-- {% set post = "" %} -->
<!-- {% if pagename in ablog %} -->
{% set post = ablog[pagename] %}
<!-- {% endif %} -->
<h3>
<a href="{{ pathto(ablog.category.path) }}">{{ gettext('Categories') }}</a>
</h3>
<div id="category" class="sd-text-justify sd-fs-4 sd-text-muted">
<!-- level categories -->
{% set i_bool = "intermediate" in post.category|map('string') %}
{% set b_bool = "beginner" in post.category|map('string') %}
{% set a_bool = "advanced" in post.category|map('string') %}
<div class="container">
<div class="row">
<div class="col">
{{ category_item("beginner", "fa-crow", b_bool) }}
</div>
<div class="col">
{{ category_item("intermediate", "fa-dove", i_bool) }}
</div>
<div class="col">
{{ category_item("advanced", "fa-dragon", a_bool) }}
</div>
</div>
</div>
<!-- diataxis type categories -->
<div class="container sd-fs-6 sd-font-weight-bold">
<div class="row border-top border-bottom">
{% set t_bool = "tutorial" in post.category|map('string') %}
<div class="col"><a class="{{ setcolorclass(t_bool) }}" href="{{ pathtocategory('tutorial') }}">Tutorial</a></div>
{% set h_bool = "how-to" in post.category|map('string') %}
<div class="col"><a class="{{ setcolorclass(h_bool) }}" href="{{ pathtocategory('how-to') }}">How-to</a></div>
<div class="w-100"></div>
{% set e_bool = "explanation" in post.category|map('string') %}
<div class="col"><a class="{{ setcolorclass(e_bool) }}" href="{{ pathtocategory('explanation') }}">Explanation</a></div>
{% set r_bool = "reference" in post.category|map('string') %}
<div class="col"><a class="{{ setcolorclass(r_bool) }}" href="{{ pathtocategory('reference') }}">Reference</a></div>
</div>
</div>
</div>