26 lines
1.0 KiB
Python
26 lines
1.0 KiB
Python
# retoor <retoor@molodetz.nl>
|
|
from molodetz.constants import TOPICS
|
|
from molodetz.database import published_posts
|
|
from molodetz.responses import respond
|
|
from molodetz.schemas.posts import PostListOut
|
|
from molodetz.seo import base_seo_context, website_schema
|
|
from molodetz.seo_meta_text import description_for
|
|
|
|
|
|
def topic_listing(request, topic):
|
|
before = request.query_params.get("before")
|
|
posts, next_cursor = published_posts(topic=topic, before=before, limit=25)
|
|
title = TOPICS[topic]
|
|
next_url = f"{request.url.path}?before={next_cursor}" if next_cursor else None
|
|
seo = base_seo_context(
|
|
request,
|
|
title,
|
|
description_for(topic),
|
|
breadcrumbs=[("Molodetz", "/"), (title, f"/{topic}")],
|
|
schemas=[website_schema(request)],
|
|
next_url=next_url,
|
|
robots="noindex,follow" if before else "index,follow",
|
|
)
|
|
ctx = {"title": title, "topic": topic, "posts": posts, "next_cursor": next_cursor, "next_url": next_url, "seo": seo}
|
|
return respond(request, "listing.html", ctx, model=PostListOut)
|