diff --git a/docs/notes/index.md b/docs/notes/index.md new file mode 100644 index 0000000..77a71c8 --- /dev/null +++ b/docs/notes/index.md @@ -0,0 +1,6 @@ +--- +template: all.html +hide: [toc] +--- + +# Notes diff --git a/hooks/notes.py b/hooks/notes.py index b31d251..2e33233 100644 --- a/hooks/notes.py +++ b/hooks/notes.py @@ -1,2 +1,30 @@ +import jinja2 + +@jinja2.pass_context +def get_page(context, slug): + nav = context["nav"] + for page in nav.pages: + if page.file.src_uri == slug: + return page + + raise ValueError("Unable to find page for '%s'", slug) + + +@jinja2.pass_context +def get_notes(context): + notes = [] + for page in context["nav"].pages: + if not page.file.src_uri.startswith("notes/"): + continue + + if page.file.src_uri == "notes/index.md": + continue + + notes.append(page) + return sorted(notes, key=lambda p: p.meta["git_creation_date_localized_raw_iso_date"], reverse=True) + + def on_env(env, config, files): env.tests["startswith"] = str.startswith + env.globals["get_page"] = get_page + env.globals["get_notes"] = get_notes diff --git a/mkdocs.yml b/mkdocs.yml index 7abb76d..8056434 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -26,7 +26,7 @@ theme: features: - navigation.top - navigation.sections - - navigation.index + - navigation.indexes - toc.follow - search.suggest - navigation.top @@ -102,6 +102,7 @@ plugins: exclude: - tags.md - README.md + - notes/index.md - minify_html - social - rss: diff --git a/theme/all.html b/theme/all.html new file mode 100644 index 0000000..f4c316c --- /dev/null +++ b/theme/all.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} + +{% block content %} + {{ super() }} + +