diff --git a/website/common/models.py b/website/common/models.py index d8068d2..5cbb95c 100644 --- a/website/common/models.py +++ b/website/common/models.py @@ -28,10 +28,6 @@ class BasePage(Page): """ return self.get_ancestors().reverse().exclude(depth__lte=2) - @cached_property - def table_of_contents(self) -> list[TocEntry]: - return get_table_of_contents() - class BaseContentMixin(models.Model): subtitle = models.CharField(max_length=255, blank=True) @@ -47,6 +43,18 @@ class BaseContentMixin(models.Model): class Meta: abstract = True + @cached_property + def table_of_contents(self) -> list[TocEntry]: + return get_table_of_contents() + + @cached_property + def reading_time(self) -> int: + return 4 + + @cached_property + def word_count(self) -> int: + return 1600 + class ContentPage(BasePage, BaseContentMixin): # type: ignore[misc] subpage_types: list[Any] = [] diff --git a/website/common/templates/common/content-details.html b/website/common/templates/common/content-details.html index b9234be..1fa53f3 100644 --- a/website/common/templates/common/content-details.html +++ b/website/common/templates/common/content-details.html @@ -1,7 +1,11 @@ {% if page.date %} {{ page.date|date:"Y-m-d" }} {% endif %} -4 minutes + +{% if page.reading_time %} + {{ page.reading_time }} minutes +{% endif %} + {% if page.tags.all %} {% for tag in page.tags.all %}#{{ tag.slug }}{% endfor %} {% endif %}