Skip to content

Commit b062af2

Browse files
authored
Merge pull request #1 from parente/parente/page-metadata
Add page metadata
2 parents 8b4109e + bf29eb1 commit b062af2

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

generate.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
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]
42+
# Brief introductory comment above the start of a page *in HTML*
4143
author_comment: NotRequired[str]
4244
# YYYY-MM-DD date of the page
4345
date: NotRequired[str]
@@ -181,10 +183,11 @@ def execute(self, path: str, page: Page):
181183
meta[key] = "".join(value)
182184
page.update(meta)
183185

186+
# Populate fields expected by the templates
187+
if "author" not in page:
188+
page["author"] = SITE_AUTHOR
184189
if "excerpt" not in page:
185190
page["excerpt"] = self._build_excerpt(text)
186-
# if "author_comment" in page:
187-
# page["author_comment"] = self.md.convert(page["author_comment"])
188191
page["src"] = path
189192
page["slug"] = self._build_page_slug(page)
190193
page["html"] = html

pages/about/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: About
3+
excerpt: Who do I say / think I am?
34
---
45

56
<img alt="Image of Peter Parente" class="inlineRight profilePic" width="140" height="140" src="https://s.gravatar.com/avatar/c7d6948add10f2d0ea4928e4995d6b32?s=128" />

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)