Skip to content

Commit bf29eb1

Browse files
committed
Add page metadata
1 parent 4f9a5da commit bf29eb1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

generate.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
class Page(TypedDict):
3838
"""A page on the site."""
3939

40-
# Brief introductory comment above at the start of a page
40+
# Author of the page, if different from SITE_AUTHOR
41+
author: NotRequired[str]
4142
# Brief introductory comment above the start of a page *in HTML*
4243
author_comment: NotRequired[str]
4344
# YYYY-MM-DD date of the page
@@ -182,6 +183,9 @@ def execute(self, path: str, page: Page):
182183
meta[key] = "".join(value)
183184
page.update(meta)
184185

186+
# Populate fields expected by the templates
187+
if "author" not in page:
188+
page["author"] = SITE_AUTHOR
185189
if "excerpt" not in page:
186190
page["excerpt"] = self._build_excerpt(text)
187191
page["src"] = path

templates/page.mako

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
<%inherit file="shell.mako"/>
33
<%block name="header">
44
<title>${page['title']} - ${site_name}</title>
5+
<meta name="description" content="${page['excerpt']}" />
6+
<meta name="author" content="${page['author']}" />
7+
% if 'date' in page:
8+
<meta property="article:published_time" content="${page['date']}" />
9+
% endif
510
</%block>
611

712
<%block name="mainColumn">

0 commit comments

Comments
 (0)