select a template using yaml

This commit is contained in:
vitrinekast
2025-02-17 16:00:47 +01:00
parent 7aac2e37e0
commit 4165be7a27
4 changed files with 13 additions and 2 deletions

5
app.py
View File

@ -102,7 +102,10 @@ env.filters["prettydate"] = prettydate
# translate a single file into HTML
def render_single_file(page, path, dist, name = False):
name = Path(path).stem
template = env.select_template([f"{name}.jinja", "index.jinja"])
template_name = name
if "template" in page:
template_name = page["template"]
template = env.select_template([f"{template_name}.jinja", "index.jinja"])
html = template.render(documents=documents, page=page, name=name)
if not os.path.exists(dist):

View File

@ -1,6 +1,7 @@
---
title: A newsletter for december
published: false
template: newsletter
---
# Klankbord Digest January 2025

View File

@ -1,3 +1,9 @@
---
title: A title for my fun newsletter
published: false
template: newsletter
---
I'd like to begin this month's Klankbord Digest with a server update.
Let's backtrack a bit to understand how the current circumstances
arose. The server began as a prototype on a Mac Pro Trash Bin computer

View File

@ -23,6 +23,7 @@
max-width: 800px;
margin: 2rem auto;
font-family: sans-serif;
padding: 12px;
}
</style>
{% block title %}
@ -38,7 +39,7 @@
</head>
</head>
<body>
settings for newssletter only {{ name }}
<main>
<section>
<article>