Remove ToC from blog list page
Showing an accurate ToC is complex alongside pagination
This commit is contained in:
parent
d2b9db8ace
commit
db6dd80385
1 changed files with 4 additions and 17 deletions
|
@ -1,7 +1,6 @@
|
||||||
from typing import Any, Optional, Type
|
from typing import Any, Optional, Type
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models.functions import TruncMonth
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from modelcluster.fields import ParentalManyToManyField
|
from modelcluster.fields import ParentalManyToManyField
|
||||||
|
@ -25,22 +24,10 @@ class BlogPostListPage(BaseListingPage):
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def table_of_contents(self) -> list[TocEntry]:
|
def table_of_contents(self) -> list[TocEntry]:
|
||||||
post_months = sorted(
|
"""
|
||||||
{
|
Showing an accurate ToC is complex alongside pagination
|
||||||
dt.strftime("%Y-%m")
|
"""
|
||||||
for dt in self.get_paginator_page()
|
return []
|
||||||
.object_list.annotate(
|
|
||||||
post_month=TruncMonth("date", output_field=models.DateField())
|
|
||||||
)
|
|
||||||
.values_list("post_month", flat=True)
|
|
||||||
},
|
|
||||||
reverse=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
return [
|
|
||||||
TocEntry(post_month, "date-" + post_month, 0, [])
|
|
||||||
for post_month in post_months
|
|
||||||
]
|
|
||||||
|
|
||||||
def get_listing_pages(self) -> models.QuerySet:
|
def get_listing_pages(self) -> models.QuerySet:
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in a new issue