From 8de8227bb349ccdd9e08bd805ba122c6343a9607 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Shelton" Date: Sun, 17 May 2026 17:45:03 -0600 Subject: [PATCH] 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. --- sources/eleventy.config.js | 2 ++ sources/site/includes/layouts/notes.njk | 2 +- sources/utilities/filters/helpers.js | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sources/eleventy.config.js b/sources/eleventy.config.js index e6320eb..5964b25 100644 --- a/sources/eleventy.config.js +++ b/sources/eleventy.config.js @@ -21,6 +21,8 @@ module.exports = config => { // Remove whitespace from a string config.addNunjucksFilter('spaceless', helpers.spaceless) + config.addNunjucksFilter('titleCase', helpers.titleCase) + // Minify our HTML config.addTransform('htmlminify', require('./utilities/transforms/htmlminify')) diff --git a/sources/site/includes/layouts/notes.njk b/sources/site/includes/layouts/notes.njk index 2d34a69..03c641a 100644 --- a/sources/site/includes/layouts/notes.njk +++ b/sources/site/includes/layouts/notes.njk @@ -47,7 +47,7 @@ pagination: {%- if item !== 'notes' -%} - {{ item | capitalize }} + {{ item | titleCase }} {%- endif -%} diff --git a/sources/utilities/filters/helpers.js b/sources/utilities/filters/helpers.js index f8d57ab..2730f63 100644 --- a/sources/utilities/filters/helpers.js +++ b/sources/utilities/filters/helpers.js @@ -2,3 +2,13 @@ module.exports.spaceless = str => ( 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; \ No newline at end of file