Remove ToC from blog list page

Showing an accurate ToC is complex alongside pagination
This commit is contained in:
Jake Howard 2022-10-21 16:56:40 +01:00
parent d2b9db8ace
commit db6dd80385
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -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 (