~andrewzah/personal-site

personal-site/templates/macros.html -rw-r--r-- 3.6 KiB View raw
dd273feeAndrew Zah begin new watch post 6 months ago
                                                                                
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
{% macro post_link(page, section) %}
  {% if page.draft %}
  {% else %}
    <div class="row">
      {% if page.date %}
        <div class="post-date">
          <a href="/{{section.components[0]}}/{{page.slug | safe}}/">
            {{ page.date | date(format="%B %d, %Y") }}
          </a>
        </div>
      {% endif %}
      <div class="post-title">
        <a href="/{{section.components[0]}}/{{page.slug | safe}}/">
          <span>{{ page.title }}</span>
        </a>
      </div>
    </div>
  {% endif %}
{% endmacro post_link %}

{% macro render_taxonomies(taxonomies) %}
  {{ macros::render_tags(tags=taxonomies.tags) }}
  {{ macros::render_categories(categories=taxonomies.categories) }}
{% endmacro render_taxonomies %}

{% macro render_tags(tags) %}
  <div class="tags">
    Tags: 
    {% for tag in tags %}
      {% if loop.last %}
        <a href="/tags/{{ tag | slugify }}/">{{ tag | title }}</a>
      {% else %}
        <a href="/tags/{{ tag | slugify }}/">{{ tag | title }}</a> | 
      {% endif %}
    {% endfor %}
  </div>
{% endmacro render_tags %}

{% macro render_categories(categories) %}
  <div class="categories">
    Categories: 
    {% for category in categories %}
      {% if loop.last %}
        <a href="/categories/{{ category | slugify }}/">{{ category | title }}</a>
      {% else %}
        <a href="/categories/{{ category | slugify }}/">{{ category | title }}</a> | 
      {% endif %}
    {% endfor %}
  </div>
{% endmacro render_categories %}

{% macro render_footnotes(footnotes) %}
  <div id="footnotes">
    <h3> Footnotes </h3>
    <ul>
      {% for footnote in footnotes %}
        <li>
          <span>
            <a
              id="footnote-{{loop.index0}}"
              href="#footnote-cite-{{loop.index0}}"
            >
              ({{loop.index0}}) &#x21A9;</a>{{ footnote }}
          </span>
        </li>
      {% endfor %}
    </ul>
  </div>
{% endmacro render_footnotes %}

{% macro render_references(references) %}
  <div id="references">
    <h3> References </h3>
    <ul>
      {% for reference in references %}
        <li>
          <span>
            <a
              id="reference-{{loop.index0}}"
              href="#refer-{{loop.index0}}"
            >
              [{{loop.index0}}] &#x21A9;</a><a href="{{reference.1}}">
              {{reference.0}}
            </a>
          </span>
        </li>
      {% endfor %}
    </ul>
  </div>
{% endmacro render_references %}

{% macro render_resources(resources) %}
  <div id="resources">
    <h3> Further Reading </h3>
    <ul>
      {% for resource in resources %}
        <li>
          <span>
            <a href="{{resource.1}}">
              {{resource.0}}
            </a>
          </span>
        </li>
      {% endfor %}
    </ul>
  </div>
{% endmacro render_resources %}

{% macro render_nav(current_path) %}
  <nav>
    <div id="nav-links">
      {% set path = current_path | truncate(length=5, end="") %}
      <ul>
        <li><a href="/">Home</a></li>
        <li {% if path == 'posts' %}class="active"{% endif %}><a href="/posts/">Posts</a></li>
        <li {% if path == 'links' %}class="active"{% endif %}><a href="/contact/">Links</a></li>
        <li {% if path == 'about' %}class="active"{% endif %}><a href="/contact/">About</a></li>
      </ul>
    </div>
  </nav>
{% endmacro render_nav %}

{% macro render_term(term) %}
  <div class="row">
    <tr>
      <td><time datetime="{{ term.date }}">{{ term.date  }}</time></td>
        {% if term.components[0] == "talks" %}
          <td> (talk) </td>
        {% endif %}
      <td><a href="/{{ term.path }}">{{ term.title }}</a></td>
    </tr>
  </div>
{% endmacro render_term %}