Skip to content

Commit 5330422

Browse files
committed
Merge branch 'parente/utterances'
2 parents 455251b + d0e96df commit 5330422

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

generate.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@
3535

3636

3737
class Page(TypedDict):
38-
"""A page on the site."""
38+
"""A page on the site.
39+
40+
Reminder: All types are parsed as strings by python-markdown.
41+
"""
3942

4043
# Allow comments on the page
41-
allow_comments: NotRequired[bool]
44+
allow_comments: NotRequired[str | bool]
4245
# Author of the page, if different from SITE_AUTHOR
4346
author: NotRequired[str]
4447
# Brief introductory comment above the start of a page *in HTML*
@@ -52,7 +55,7 @@ class Page(TypedDict):
5255
# The next page in chronological series of pages
5356
next: "Page"
5457
# Flag to skip rendering the page
55-
skip: NotRequired[bool]
58+
skip: NotRequired[str | bool]
5659
# The URL slug of the page
5760
slug: str
5861
# The path containing the source document of the page
@@ -202,6 +205,12 @@ def execute(self, path: str, page: Page):
202205
page["excerpt"] = self._build_excerpt(text)
203206
if "allow_comments" not in page:
204207
page["allow_comments"] = True
208+
else:
209+
page["allow_comments"] = page["allow_comments"].lower() in (
210+
"true",
211+
"yes",
212+
"1",
213+
)
205214
page["src"] = path
206215
page["slug"] = self._build_page_slug(page)
207216
page["html"] = html

templates/page.mako

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</%block>
2222

2323
<%block name="pageMeta">
24-
% if 'allow_comments' in page:
24+
% if page['allow_comments']:
2525
<div class="footerSection" id="userComments">
2626
<script src="https://utteranc.es/client.js"
2727
repo="parente/blog"

0 commit comments

Comments
 (0)