Add category taxonomy and navigation integration
Implements Issue #35 with category snippets, article category routing, category-aware templates, and category RSS feeds with tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -3,7 +3,7 @@ from django.contrib.syndication.views import Feed
|
||||
from django.shortcuts import get_object_or_404
|
||||
from taggit.models import Tag
|
||||
|
||||
from apps.blog.models import ArticlePage
|
||||
from apps.blog.models import ArticlePage, Category
|
||||
|
||||
|
||||
class AllArticlesFeed(Feed):
|
||||
@@ -48,3 +48,15 @@ class TagArticlesFeed(AllArticlesFeed):
|
||||
|
||||
def items(self, obj):
|
||||
return ArticlePage.objects.live().filter(tags=obj).order_by("-first_published_at")[:20]
|
||||
|
||||
|
||||
class CategoryArticlesFeed(AllArticlesFeed):
|
||||
def get_object(self, request, category_slug: str):
|
||||
self.request = request
|
||||
return get_object_or_404(Category, slug=category_slug)
|
||||
|
||||
def title(self, obj):
|
||||
return f"No Hype AI — {obj.name}"
|
||||
|
||||
def items(self, obj):
|
||||
return ArticlePage.objects.live().filter(category=obj).order_by("-first_published_at")[:20]
|
||||
|
||||
Reference in New Issue
Block a user