Skip to content

Commit 495f5b8

Browse files
committed
Populate the "Notes" note with all notes sorted by title.
1 parent c626828 commit 495f5b8

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

content/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ I am always striving to learn new things and improve my skills. Hopefully, this
1313

1414
## Pinned notes
1515

16+
- [Notes](@/notes/_index.md)
1617
- [Repositories](@/notes/Repositories/_index.md)
1718
- [Search](@/notes/Search.md)
1819

content/notes/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
+++
22
title = "Notes"
3-
template = "section.html"
3+
template = "notes.html"
44
page_template = "page.html"
55
+++

templates/macros.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,23 @@
1717
{% endfor %}
1818
</ol>
1919
{% endmacro toc %}
20+
21+
{% macro sitemap(parent_note) %}
22+
{% set notes = parent_note.pages %}
23+
24+
{% for path in parent_note.subsections %}
25+
{% set subsection = get_section(path=path) %}
26+
{% set_global notes = notes | concat(with=subsection) %}
27+
{% endfor %}
28+
29+
{% set notes = notes | sort(attribute="relative_path") %}
30+
31+
<ul>
32+
{% for note in notes %}
33+
<li><a href="{{ note.permalink }}">{{ note.title }}</a></li>
34+
{% if note.pages | length %}
35+
{{ macros::sitemap(parent_note=note) }}
36+
{% endif %}
37+
{% endfor %}
38+
</ul>
39+
{% endmacro sitemap %}

templates/notes.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% extends "section.html" %}
2+
3+
{% block content %}
4+
<p>All notes sorted by relative path:</p>
5+
6+
{{ macros::sitemap(parent_note=section) }}
7+
8+
{% endblock content %}

0 commit comments

Comments
 (0)