Extract includes for links, tags and related posts

This commit is contained in:
Oliver Davies 2024-09-14 14:08:27 +01:00
parent 5baae90010
commit e70d8c6f1f
4 changed files with 38 additions and 30 deletions

View file

@ -13,37 +13,13 @@
{% block content %}{% endblock %}
{% if page.links is not empty %}
<h2>Links</h2>
{% include "notes/links" with { links: page.links } %}
<ul>
{% for url in page.links %}
<li><a href="{{ url }}">{{ url }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% include "notes/related" with {
notes: data.notes,
related: page.related,
} %}
{% if page.tags is not empty %}
<h2>Tags</h2>
{% include "notes/tags" with { tags: page.tags } %}
<ul>
{% for tag in page.tags|sort %}
<li>{{ tag }}</li>
{% endfor %}
</ul>
{% endif %}
{% if page.related and data.notes %}
<section>
<h2>Related</h2>
<ul>
{% for note in data.notes if page.related|filter((title) => title == note.title) %}
<li>
<a href="{{ note.url|trim('/', 'right') }}">{{ note.title }}</a>
</li>
{% endfor %}
</ul>
</section>
{% endif %}
{% endblock %}