diff --git a/website/blog/models.py b/website/blog/models.py index 55e1e92..44e0ab0 100644 --- a/website/blog/models.py +++ b/website/blog/models.py @@ -23,11 +23,8 @@ class BlogPostListPage(BaseListingPage): ] @cached_property - def table_of_contents(self) -> list[TocEntry]: - """ - Showing an accurate ToC is complex alongside pagination - """ - return [] + def show_table_of_contents(self) -> bool: + return False def get_listing_pages(self) -> models.QuerySet: return ( diff --git a/website/common/models.py b/website/common/models.py index ca75f8a..842495e 100644 --- a/website/common/models.py +++ b/website/common/models.py @@ -96,6 +96,10 @@ class BaseContentPage(BasePage, MetadataMixin): def table_of_contents(self) -> list[TocEntry]: return get_table_of_contents(self.content_html) + @cached_property + def show_table_of_contents(self) -> bool: + return len(self.table_of_contents) >= 3 + @cached_property def reading_time(self) -> timedelta: """ @@ -204,8 +208,8 @@ class BaseListingPage(RoutablePageMixin, BaseContentPage): return context @cached_property - def table_of_contents(self) -> list[TocEntry]: - return [] + def show_table_of_contents(self) -> bool: + return False @cached_property def show_reading_time(self) -> bool: diff --git a/website/common/templates/wagtail_base.html b/website/common/templates/wagtail_base.html index bc87c6e..95e356c 100644 --- a/website/common/templates/wagtail_base.html +++ b/website/common/templates/wagtail_base.html @@ -32,7 +32,7 @@