List recent notes on homepage

This commit is contained in:
Jake Howard 2024-02-15 18:07:13 +00:00 committed by Jake Howard
parent 93a375b482
commit 234e7046c0
4 changed files with 28 additions and 0 deletions

View File

@ -1 +1,4 @@
---
template: home.html
---
# Notes

2
hooks/notes.py Normal file
View File

@ -0,0 +1,2 @@
def on_env(env, config, files):
env.tests["startswith"] = str.startswith

View File

@ -16,6 +16,7 @@ theme:
icon:
logo: fontawesome/regular/note-sticky
favicon: https://theorangeone.net/favicon.ico
custom_dir: theme/
palette:
# Palette toggle for light mode
- scheme: default
@ -33,6 +34,8 @@ theme:
icon: material/brightness-4
name: Switch to light mode
hooks:
- hooks/notes.py
# Extensions
markdown_extensions:

20
theme/home.html Normal file
View File

@ -0,0 +1,20 @@
{% extends "base.html" %}
{% block content %}
{{ super() }}
<h2>Recent notes</h2>
<ul>
{% for page in (nav.pages|selectattr("url", "startswith", "notes/")|sort(attribute="meta.git_creation_date_localized_raw_iso_datetime", reverse=True))[:10] %}
<li>
<a href="{{ page.url }}">{{ page.title }}</a> - {{ page.meta.git_creation_date_localized_raw_iso_date }}
{% for tag in page.meta.tags %}
<span class="md-tag">{{ tag }}</span>
{% endfor %}
</li>
{% endfor %}
</ul>
<p><a href="{{ 'tags/'|url }}">View all &rarr;</a></p>
{% endblock %}