mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Introduce paragraph count summary (#2761)
Co-authored-by: Justin Mayer <entroP@gmail.com>
This commit is contained in:
parent
ef501a3d89
commit
513abbfdc6
6 changed files with 80 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue