1
0

Surface metadata in header

This commit is contained in:
Tim Van Baak 2023-09-11 21:55:35 -07:00
parent ed68da077e
commit 5b1d8f6243
2 changed files with 29 additions and 3 deletions

View File

@ -78,9 +78,31 @@ def main():
# Apply metadata to the template
if meta_title := meta.get("title"):
title = "".join(meta_title)
page.title.string = title
page.header.h1.string = title
page.title.string = meta_title[0]
page.header.h1.string = meta_title[0]
if meta_date := meta.get("date"):
p = page.new_tag("p")
p["class"] = "metadata"
p.string = "Date: " + meta_date[0]
page.header.append(p)
if meta_author := meta.get("author"):
p = page.new_tag("p")
p["class"] = "metadata"
p.string = "Author: " + meta_author[0]
page.header.append(p)
if meta_source := meta.get("source"):
for source_url in meta_source:
a = page.new_tag("a")
a["href"] = source_url
a.string = source_url
p = page.new_tag("p")
p["class"] = "metadata"
p.string = "URL: "
p.append(a)
page.header.append(p)
# The fully templated page is the new content
content = str(page)

View File

@ -14,6 +14,10 @@ nav {
font-size: 1.2em;
font-family: monospace;
}
header .metadata {
font-size: small;
margin-block: 0;
}
h1 {
line-height: 1em;
}