Add ellipsis to summary when truncated

This commit is contained in:
Jake Howard 2023-07-15 17:43:04 +01:00
parent 29bd939ae4
commit e9de06338b
Signed by: jake
GPG Key ID: 57AFB45680EDD477
1 changed files with 7 additions and 2 deletions

View File

@ -133,7 +133,12 @@ class BaseContentPage(BasePage, MetadataMixin):
@cached_property
def summary(self) -> str:
return truncate_string(self.plain_text, 50)
summary = truncate_string(self.plain_text, 50)
if summary and summary != self.plain_text and not summary.endswith("."):
summary += ""
return summary
@cached_property
def body_html(self) -> str:
@ -149,7 +154,7 @@ class BaseContentPage(BasePage, MetadataMixin):
@cached_property
def plain_text(self) -> str:
return extract_text(self.content_html)
return extract_text(self.content_html).strip()
def hero_url(
self, image_size: str, wagtail_image_spec_extra: Optional[str] = None