feat: blog templates

pull/5/head
Aravinth Manivannan 2022-04-18 01:55:37 +05:30
parent 4c0f194292
commit 60ac23acd2
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88
5 changed files with 77 additions and 0 deletions

View File

@ -7,6 +7,11 @@ compile_sass = true
# Whether to build a search index to be used later on by a JavaScript library
build_search_index = true
taxonomies = [
{name = "tags", feed = true}, # each tag will have its own feed
{name = "categories", paginate_by = 5}, # 5 items per page for a term
]
[markdown]
# Whether to do syntax highlighting
# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola
@ -14,3 +19,7 @@ highlight_code = true
[extra]
# Put all your custom variables here
authors = [
{ "nick"="dachary", name="Loïc Dachary", "website"="https://dachary.org" },
{ "nick"="realaravinth", name="Aravinth Manivannan", "website"="https://batsense.net" }
]

View File

@ -0,0 +1,4 @@
<p class="blog__post-meta">
{{ macros::get_author(nick=page.extra.author) }} &middot; {{ page.day }} {{ macros::get_month(month=page.month) }},
{{ page.year }} &middot; <b>{{ page.reading_time }} min read</b>
</p>

31
templates/blog/index.html Normal file
View File

@ -0,0 +1,31 @@
{% extends "base.html" %} {% block meta %}
{% set title = "Posts" %}
{% set description = title %}
{{ macros::get_meta_tags(title=title, description=description) }}
{% endblock meta %} {% block content %}
<div class="blog__container">
<h1 class="blog__title">{{ section.title }}</h1>
<ul class="blog__list">
{% for page in section.pages %}
<li class="blog__post-item">
<a href="{{ page.permalink | safe }}" class="blog__post-link">
<h2 class="blog__post-title">{{ page.title }}</h2>
{% include "blog/_meta.html" %}
<p class="blog__post-description">{{ page.description | safe }} </p>
</a>
<div class="blog__post-tag-container">
{% for t in page.taxonomies.tags %}
<a class="blog__post-tag" href="/tags/{{t | slugify }}">#{{ t }}</a>
{% endfor %}
</div>
</li>
{% endfor %}
</ul>
</div>
{% block rss %}
<link rel="alternate" type="application/rss+xml" title="RSS" href="{{ get_url(path="rss.xml", trailing_slash=false) }}">
{% endblock %}
{% endblock content %}

25
templates/blog/post.html Normal file
View File

@ -0,0 +1,25 @@
{% extends "base.html" %} {% block meta %}
{% set description = page.title %}
{{ macros::get_meta_tags(title=page.title, description=description) }}
{% endblock meta %} {% block content %}
<div class="page__container">
<h1 class="page__group-title">{{ page.title }}</h1>
{% include "blog/_meta.html" %}
<div class="blog__content">
{{ page.content | safe }}
</div>
<br>
<br>
<div class="blog__post-tag-container">
{% for t in page.taxonomies.tags %}
<a class="blog__post-tag" href="/tags/{{t | slugify }}">#{{ t }}</a>
{% endfor %}
</div>
</div>
{% endblock content %}

View File

@ -168,3 +168,11 @@
<a class="nav__link" rel="noreferrer" href="{{ link }}">{{ name }}</a>
</div>
{% endmacro nav_link %}
{% macro get_author(nick) %}
{% for author in config.extra.authors %}
{% if author.nick == nick %}
<a href="{{ author.website }}" class="post__author">{{ author.name }}</a>
{% endif %}
{% endfor %}
{% endmacro get_author %}