1
Fork 0
mirror of https://github.com/RealOrangeOne/notes.git synced 2024-12-22 02:55:58 +00:00

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 %}