blob: d5f1c57ed8257f3473b2290b55e6272ee036e8d2 (
plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
{# render meta links #}
{% macro meta_item(name, href, text) %}
<tr>
<td>
<strong>{{ name }}</strong>
</td>
<td>
<a href="{{ href }}">{{ text }}</a>
</td>
</tr>
{% endmacro %}
{# render navbar item #}
{% macro nav_item(name, url) %}
<a {% if current_url and url == current_url %}class="active"{% endif %} href={{ url }}>{{ name }}</a>
{% endmacro %}
{# render table of contents recursively #}
{% macro toc_item(item, depth=0) %}
<li>
<a href="{{ item.permalink | safe }}">{{ item.title }}</a>
{% if depth < 6 and item.children %}
<ul>
{% for child in item.children %}{{ self::toc_item(item=child, depth=depth + 1) }}{% endfor %}
</ul>
{% endif %}
</li>
{% endmacro %}
{# render table of contents #}
{% macro toc(toc) %}
{%- set len = toc | length -%}
{% if len > 1 %}
<nav>
<ul>
{% for child in toc %}{{ self::toc_item(item=child) }}{% endfor %}
</ul>
</nav>
{% endif %}
{% endmacro %}
{# render content header #}
{% macro header(item, link=true) %}
<header>
<hgroup>
<h1>
{% if not link or not item.permalink %}
{{ item.title }}
{% elif item.extra.external %}
<a href="{{ item.extra.external }}">{{ item.title }}</a>
{% else %}
<a href="{{ item.permalink }}">{{ item.title }}</a>
{% endif %}
</h1>
<p>{{ item.description }}</p>
</hgroup>
{% if item.taxonomies["tags"] %}
<nav>
{% for tag in item.taxonomies["tags"] %}
<a href={{ get_taxonomy_url(kind="tags", name=tag) }}>#{{ tag }}</a>
{% endfor %}
</nav>
{% endif %}
</header>
{% if item.date or item.authors %}
<footer>
<p>
Posted
{% if item.date %}
on
<time pubdate datetime="{{ item.date | date(format="%Y-%m-%d") }}">
{{ item.date | date(format="%d %b %Y") }}
</time>
{% endif %}
{% if item.authors %}
<span>
<address>
by
{{ item.authors | join(sep=", ") }}
</address>
</span>
{% endif %}
{% if item.updated %}
<time datetime="{{ item.updated | date(format="%Y-%m-%d") }}">
(Edited: {{ item.updated | date(format="%d %b %Y") }})
</time>
{% endif %}
</p>
</footer>
{% endif %}
{% endmacro %}
|