Surface metadata in header
This commit is contained in:
parent
ed68da077e
commit
5b1d8f6243
28
build.py
28
build.py
@ -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)
|
||||
|
@ -14,6 +14,10 @@ nav {
|
||||
font-size: 1.2em;
|
||||
font-family: monospace;
|
||||
}
|
||||
header .metadata {
|
||||
font-size: small;
|
||||
margin-block: 0;
|
||||
}
|
||||
h1 {
|
||||
line-height: 1em;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user