diff --git a/config.toml b/config.toml index 39a4313..3c9f105 100644 --- a/config.toml +++ b/config.toml @@ -169,6 +169,12 @@ show_date = true # "both" - Show both the original date and the last updated date. post_listing_date = "date" +# Auto generate summary for post listing and Atom feeds, +# when no summary is set using the tag. +# It will be generated in separated paragraph alongside with post description. +auto_generate_post_summary = true +auto_generated_summary_length = 200 + # Enable iine like buttons on all posts: https://iine.to/ # Can be set at page or section levels, following the hierarchy: page > section > config. See: https://welpo.github.io/tabi/blog/mastering-tabi-settings/#settings-hierarchy iine = true diff --git a/static/feed_style.xsl b/static/feed_style.xsl index 1e413bb..785c817 100644 --- a/static/feed_style.xsl +++ b/static/feed_style.xsl @@ -1,6 +1,7 @@ + xmlns:atom="http://www.w3.org/2005/Atom" xmlns:tabi="https://github.com/welpo/tabi" + xmlns:xhtml="http://www.w3.org/1999/xhtml"> @@ -100,7 +101,7 @@
- +
diff --git a/templates/atom.xml b/templates/atom.xml index 3e5b55c..0a9e8c4 100644 --- a/templates/atom.xml +++ b/templates/atom.xml @@ -100,11 +100,19 @@ {% if config.extra.full_content_in_feed %} {{ page.content }} {% endif -%} - {% if page.description -%} - {{ page.description }} - {% elif page.summary -%} - {{ page.summary | striptags | trim_end_matches(pat=".") | safe }}… - {% endif -%} + + +
+ {% if page.description -%} +

{{ page.description | markdown(inline=true) | safe }}

+ {% endif %} + {% if page.summary -%} +

{{ page.summary | striptags | trim_end_matches(pat=".") | safe }}...

+ {% elif config.extra.auto_generate_post_summary %} +

{{ page.content | striptags | truncate(length=config.extra.auto_generated_summary_length) | safe }}

+ {% endif %} +
+
{%- endfor %} diff --git a/templates/macros/list_posts.html b/templates/macros/list_posts.html index 2076194..03b50e5 100644 --- a/templates/macros/list_posts.html +++ b/templates/macros/list_posts.html @@ -142,9 +142,12 @@
{% if post.description %} -

{{ post.description | markdown(inline=true) | safe }}

- {% elif post.summary %} -

{{ post.summary | markdown(inline=true) | trim_end_matches(pat=".") | safe }}…

+

{{ post.description | markdown(inline=true) | safe }}

+ {% endif %} + {% if post.summary %} +

{{ post.summary | striptags | trim_end_matches(pat=".") | safe }}...

+ {% elif config.extra.auto_generate_post_summary %} +

{{ post.content | striptags | truncate(length=config.extra.auto_generated_summary_length) | safe }}

{% endif %}
{{ macros_translate::translate(key="read_more", default="Read more", language_strings=language_strings) }}  diff --git a/theme.toml b/theme.toml index c3ecdb6..83548f6 100644 --- a/theme.toml +++ b/theme.toml @@ -117,6 +117,12 @@ show_date = true # "both" - Show both the original date and the last updated date. post_listing_date = "date" +# Auto generate summary for post listing and Atom feeds, +# when no summary is set using the tag. +# It will be generated in separated paragraph alongside with post description. +auto_generate_post_summary = true +auto_generated_summary_length = 200 + # Enable iine like buttons on all posts: https://iine.to/ # Can be set at page or section levels, following the hierarchy: page > section > config. See: https://welpo.github.io/tabi/blog/mastering-tabi-settings/#settings-hierarchy iine = false