Skip to content

Commit

Permalink
Improve social media preview
Browse files Browse the repository at this point in the history
  • Loading branch information
svenseeberg committed Oct 31, 2024
1 parent c582537 commit 35489de
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion integreat_cms/api/v3/social_media_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ def get_excerpt(content: str) -> str:
:return: A page excerpt containing the first 100 characters of "raw" content
"""
return unescape(strip_tags(content))[:100].replace("\n", " ").replace("\r", "")
stripped_content = unescape(
strip_tags(content.replace("\n", " ").replace("\r", "").replace("<br>", " "))
)
if len(stripped_content) <= 100:
return stripped_content.strip().replace(" ", " ")
return stripped_content[:100].strip().rsplit(' ', 1)[0]+" ..."


def get_region_title(region: Region, page_title: str) -> str:
Expand Down

0 comments on commit 35489de

Please sign in to comment.