Introduce paragraph count summary (#2761)

Co-authored-by: Justin Mayer <entroP@gmail.com>
This commit is contained in:
Agathe 2024-06-25 15:07:41 +02:00 committed by GitHub
commit 513abbfdc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 80 additions and 2 deletions

View file

@ -28,6 +28,7 @@ from pelican.utils import (
sanitised_join,
set_date_tzinfo,
slugify,
truncate_html_paragraphs,
truncate_html_words,
)
@ -440,8 +441,13 @@ class Content:
if "summary" in self.metadata:
return self.metadata["summary"]
content = self.content
max_paragraphs = self.settings.get("SUMMARY_MAX_PARAGRAPHS")
if max_paragraphs is not None:
content = truncate_html_paragraphs(self.content, max_paragraphs)
if self.settings["SUMMARY_MAX_LENGTH"] is None:
return self.content
return content
return truncate_html_words(
self.content,