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