Allow posts to be hidden from feeds or from listings

This commit is contained in:
akp 2025-05-06 10:41:32 +01:00
parent fd57d0c086
commit b5a9570e31

View file

@ -285,7 +285,8 @@ def blog(base_dir: Path, output_dir: Path, jinja_env: jinja2.Environment, site_c
for slug in posts:
post = posts[slug]
if "hidden" in post and bool(post["hidden"]):
if (pv := post.get("visible", {})) == False or not pv.get("list", True):
print(slug)
continue
post_list.append(
@ -390,12 +391,14 @@ def blog(base_dir: Path, output_dir: Path, jinja_env: jinja2.Environment, site_c
)
)
feed_post_list = list(filter(lambda x: (p := posts[x.slug].get("visible", {})) != False and p.get("feed", True), post_list))
# generate feeds
with open(output_dir / "blog" / "feed.atom", "w") as f:
f.write(feeds.atom(site_config, post_list))
f.write(feeds.atom(site_config, feed_post_list))
with open(output_dir / "blog" / "feed.json", "w") as f:
f.write(feeds.json(site_config, post_list))
f.write(feeds.json(site_config, feed_post_list))
def caddy_config(