@@ -332,6 +332,18 @@ class BlogPostPage(RoutablePageMixin, StreamPageAbstract): filename = hashlib.md5(self.full_url.encode("utf-8")).hexdigest() return f"post_pdfs/{filename}.pdf" def get_read_time(self): """ Get the number of words from the body of the post and calculate the number of minutes it will take to read. Most people read at 200 words per minute. :return: The number of minutes it will take to read the post. """ words = str(self.body).split() return round(len(words) / 200) @route(r'^$') def post(self, request): return self.render(request)
modified
pages/templates/pages/blog_post_page.html
@@ -21,12 +21,17 @@<div class="container mt-5"> <div class="row"> <div class="col-12 col-md-8 col-lg-6"> <div class="mb-2"> {% for tag in self.tags.all %} <a href="{% routablepageurl self.get_parent.specific 'tag' tag.slug %}" class="btn btn-secondary btn-sm rounded-pill py-0"> {{ tag|title }} </a> {% endfor %} <div class="d-flex justify-content-between align-items-center"> <div class="mb-2"> {% for tag in self.tags.all %} <a href="{% routablepageurl self.get_parent.specific 'tag' tag.slug %}" class="btn btn-secondary btn-sm rounded-pill py-0"> {{ tag|title }} </a> {% endfor %} </div> <div class="mb-2"> {{ self.get_read_time }} min read </div> </div> <h1 class="fw-bolder">{{ self.title }}</h1> <p class="h5 text-muted">{{ self.search_description }}</p>