Skip to content

Conversation

@adrianboston
Copy link

Added substr, find and rfind into src/builtsin/filters/string.rs

Substr motivated by providing a descriptive href link opposed to the common ...more.

Used as such with Zola

{{page.content | striptags | substr(begin = 0, length=300) | safe}}
<a href="{{ page.permalink | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{page.content | striptags | substr(begin = 300, length=30) | safe}}...</a>

find and rfind used to facilitate ending on a word end or period in the link rfind(" ") or rfind(".")

Tests included for all also within string.rs

@EvanCarroll EvanCarroll mentioned this pull request Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant