about summary refs log tree commit diff
path: root/templates/macros/posts.html
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2023-03-26 16:55:25 +0900
committersefidel <contact@sefidel.net>2023-03-26 16:55:25 +0900
commit77ffc8dfeabd45cb3fac500902fcbcb7176edcc7 (patch)
tree4c3a538e0792d60ca637a3921341820087311233 /templates/macros/posts.html
downloadsefidel-web-77ffc8dfeabd45cb3fac500902fcbcb7176edcc7.tar.gz
sefidel-web-77ffc8dfeabd45cb3fac500902fcbcb7176edcc7.zip
project: Initial commit
Diffstat (limited to 'templates/macros/posts.html')
-rw-r--r--templates/macros/posts.html61
1 files changed, 61 insertions, 0 deletions
diff --git a/templates/macros/posts.html b/templates/macros/posts.html
new file mode 100644
index 0000000..506adff
--- /dev/null
+++ b/templates/macros/posts.html
@@ -0,0 +1,61 @@
+{% macro display(pages) %}
+  <div class="article-list">
+    <!-- If you are using pagination, section.pages will be empty. You need to use the paginator object -->
+    {% for page in pages %}
+      <article>
+        <header lang="{{ page.lang }}">
+          <time datetime="{{ page.date }}">{{ page.date }}</time>
+          <h3>{{ posts::link(page=page) }}</h3>
+          <p class="post-meta">{{ posts::taxonomies(taxonomies=page.taxonomies) }}</p>
+        </header>
+      </article>
+    {% endfor %}
+</div>
+{% endmacro display %}
+
+{% macro link(page) %}
+  <a href="{{ page.permalink | safe }}">{{ page.title }}</a>
+{% endmacro link %}
+
+{% macro meta(page) %}
+  {% if page.date %}
+    Published on {{ page.date }}
+  {% endif %}
+  {% if page.updated %}
+    | Edited on {{ page.updated }}
+  {% endif %}
+  {% if page.taxonomies %}
+    :: {{ posts::taxonomies(taxonomies=page.taxonomies) }}
+  {% endif %}
+{% endmacro meta %}
+
+{% macro taxonomies(taxonomies) %}
+  {% if taxonomies.categories %}
+    {{ posts::categories(categories=taxonomies.categories) }}
+  {% endif %}
+  {% if taxonomies.tags %}
+    {{ posts::tags(tags=taxonomies.tags) }}
+  {% endif %}
+{% endmacro taxonomies %}
+
+{% macro categories(categories) %}
+  [
+  {% for category in categories %}
+    {% if loop.last %}
+      <a href="{{ get_taxonomy_url(kind="categories", name=category) }}">{{ category }}</a>
+    {% else %}
+      <a href="{{ get_taxonomy_url(kind="categories", name=category) }}">{{ category }}</a>,
+    {% endif %}
+  {% endfor %}
+  ]
+{% endmacro categories %}
+
+{% macro tags(tags) %}
+  {% for tag in tags %}
+    {% if loop.last %}
+      #<a href="{{ get_taxonomy_url(kind="tags", name=tag) }}">{{ tag }}</a>
+    {% else %}
+      #<a href="{{ get_taxonomy_url(kind="tags", name=tag) }}">{{ tag }}</a>,
+    {% endif %}
+  {% endfor %}
+{% endmacro tags %}