-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhooks.py
More file actions
22 lines (16 loc) · 733 Bytes
/
hooks.py
File metadata and controls
22 lines (16 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from pathlib import Path
def on_page_content(html, page, config, files):
is_post = any(ancestor.title == "Posts" for ancestor in page.ancestors)
is_draft = getattr(page, "meta", {}).get("draft", False)
if is_post and not is_draft:
config.setdefault("rss_items", []).append({
"title": page.title,
"link": config["site_url"] + page.url,
"description": f"<![CDATA[{html}]]>",
# TODO: Get timezone programmatically
"date": page.meta["date"].strftime("%a, %d %b %Y %T +0000"),
})
def on_page_context(context, page, config, nav):
if page.title == "Feed":
context["items"] = config.get("rss_items", [])
return context