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

View file

@ -133,7 +133,12 @@ class BaseContentPage(BasePage, MetadataMixin):
@cached_property @cached_property
def summary(self) -> str: 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 @cached_property
def body_html(self) -> str: def body_html(self) -> str:
@ -149,7 +154,7 @@ class BaseContentPage(BasePage, MetadataMixin):
@cached_property @cached_property
def plain_text(self) -> str: def plain_text(self) -> str:
return extract_text(self.content_html) return extract_text(self.content_html).strip()
def hero_url( def hero_url(
self, image_size: str, wagtail_image_spec_extra: Optional[str] = None self, image_size: str, wagtail_image_spec_extra: Optional[str] = None