From 752aacb84c78fc8922dcf8727973d4599846f4bc Mon Sep 17 00:00:00 2001 From: Lee Kai Ze Date: Tue, 4 Nov 2025 23:53:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20feat:=20added=20auto-generated?= =?UTF-8?q?=20summary=20to=20post=20listing=20and=20atom=20feeds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Post listing and Atom feeds will show post summary in separate paragraph alongside with post description. New defaults (breaking changes): - auto_generated_summary_length = 300 - auto_generated_post_listing_summary = true - auto_generated_atom_feed_summary = true --- config.toml | 7 +++++++ static/feed_style.xsl | 5 +++-- templates/atom.xml | 17 ++++++++++++----- templates/macros/list_posts.html | 9 ++++++--- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/config.toml b/config.toml index 39a4313..18a5d45 100644 --- a/config.toml +++ b/config.toml @@ -169,6 +169,13 @@ 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. +# It will be generated in separated paragraph alongside with post description. +# Auto generated when no summary is set using the tag. +auto_generated_summary_length = 300 +auto_generated_post_listing_summary = true +auto_generated_atom_feed_summary = true + # 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..f19c3bf 100644 --- a/templates/atom.xml +++ b/templates/atom.xml @@ -100,11 +100,18 @@ {% 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_generated_atom_feed_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..2a03a85 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_generated_post_listing_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) }}  From 1ff91cebcf75aac299e0122492d97a77f316ec4c Mon Sep 17 00:00:00 2001 From: Lee Kai Ze Date: Thu, 13 Nov 2025 15:12:59 +0800 Subject: [PATCH 2/3] fix(summary): update default parameters Default to: auto_generate_post_summary = true auto_generated_summary_length = 200 Addresses https://github.com/welpo/tabi/pull/579 Closes https://github.com/welpo/tabi/issues/491 --- config.toml | 9 ++++----- templates/atom.xml | 3 ++- templates/macros/list_posts.html | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config.toml b/config.toml index 18a5d45..3c9f105 100644 --- a/config.toml +++ b/config.toml @@ -169,12 +169,11 @@ 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. +# 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 generated when no summary is set using the tag. -auto_generated_summary_length = 300 -auto_generated_post_listing_summary = true -auto_generated_atom_feed_summary = true +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 diff --git a/templates/atom.xml b/templates/atom.xml index f19c3bf..0a9e8c4 100644 --- a/templates/atom.xml +++ b/templates/atom.xml @@ -101,13 +101,14 @@ {{ page.content }} {% 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_generated_atom_feed_summary %} + {% elif config.extra.auto_generate_post_summary %}

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

{% endif %}
diff --git a/templates/macros/list_posts.html b/templates/macros/list_posts.html index 2a03a85..03b50e5 100644 --- a/templates/macros/list_posts.html +++ b/templates/macros/list_posts.html @@ -146,7 +146,7 @@ {% endif %} {% if post.summary %}

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

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

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

{% endif %} From 827e8524daabf13cf23b8cbdbb1ff70e969d86a4 Mon Sep 17 00:00:00 2001 From: Lee Kai Ze Date: Thu, 13 Nov 2025 15:20:17 +0800 Subject: [PATCH 3/3] fix(summary): add default configs under theme.toml --- theme.toml | 6 ++++++ 1 file changed, 6 insertions(+) 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