Added titleCase filter.

This is necessary for some book titles, like 1 and 2 Corinthians, since
the existing capitalize filter would otherwise ignore the title casing
on the book name.
This commit is contained in:
Benjamin A. Shelton 2026-05-17 17:45:03 -06:00
commit 8de8227bb3
Signed by: zancarius
GPG key ID: 8BD42DBD6C337E01
3 changed files with 13 additions and 1 deletions

View file

@ -21,6 +21,8 @@ module.exports = config => {
// Remove whitespace from a string // Remove whitespace from a string
config.addNunjucksFilter('spaceless', helpers.spaceless) config.addNunjucksFilter('spaceless', helpers.spaceless)
config.addNunjucksFilter('titleCase', helpers.titleCase)
// Minify our HTML // Minify our HTML
config.addTransform('htmlminify', require('./utilities/transforms/htmlminify')) config.addTransform('htmlminify', require('./utilities/transforms/htmlminify'))

View file

@ -47,7 +47,7 @@ pagination:
{%- if item !== 'notes' -%} {%- if item !== 'notes' -%}
<span class="category bg-{%- if post.data.scripture_category %}{{ post.data.scripture_category }} {%- else %}secondary {%- endif %} color-primary text-300">{{ item | capitalize }}</span> <span class="category bg-{%- if post.data.scripture_category %}{{ post.data.scripture_category }} {%- else %}secondary {%- endif %} color-primary text-300">{{ item | titleCase }}</span>
{%- endif -%} {%- endif -%}

View file

@ -2,3 +2,13 @@
module.exports.spaceless = str => ( module.exports.spaceless = str => (
str.replace(/\s/g, '') str.replace(/\s/g, '')
) )
var titleCase = function(str) {
if (!str) return "";
return str
.toLowerCase()
.split(' ')
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ');
};
module.exports.titleCase = titleCase;