main website improvements

This commit is contained in:
Michael Zhang 2018-09-22 03:17:41 -05:00
parent 99c08e03c0
commit 0803c5f2a4
No known key found for this signature in database
GPG key ID: A1B65B603268116B
4 changed files with 27 additions and 2 deletions

View file

@ -121,4 +121,9 @@ header {
margin-left: 10px;
margin-right: 10px;
}
}
}
.toc {
background-color: #f0f0f0;
padding: 8px;
}

View file

@ -9,7 +9,7 @@
</span>
<br />
<small>
Posted {% if post.extra.author %}by {{ post.extra.author }}{% endif %}
{{ post.reading_time }} min - Posted {% if post.extra.author %}by {{ post.extra.author }}{% endif %}
on {{ post.date }}
</small>
</td>

View file

@ -0,0 +1,12 @@
{% macro render_toc(toc) %}
<ul>
{% for item in toc %}
<li>
<a href="{{ item.permalink | safe }}">{{ item.title }}</a>
{% if item.children %}
{{ self::render_toc(toc=item.children) }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endmacro %}

View file

@ -1,4 +1,5 @@
{% extends "layout.html" %}
{% import "macros/post.html" as post %}
{% block title %}
{% if page.title %}{{ page.title }} - {% endif %}
@ -14,6 +15,13 @@
on {{ page.date }}
</small>
{% endif %}
{% if page.toc.children | length %}
<div class="toc">
{{ post::render_toc(toc=page.toc) }}
</div>
{% endif %}
{{ page.content | safe }}
{% if page.extra.link %}
<p>Visit <a href="{{ page.extra.link }}">here</a> for more info.</p>