blog/themes/chameleon/scripts/titleCase.js

14 lines
321 B
JavaScript
Raw Permalink Normal View History

2024-09-28 06:31:52 +00:00
'use strict'
/* global hexo */
/*
* Simpler version of titlecase() https://github.com/rvagg/titlecase
* Does not ignore words with a dot
*/
hexo.extend.helper.register('titleCase', (str) => {
return str.replace(/[\w]+[^\s]*/g, (match) => {
return match[0].toUpperCase() + match.substring(1).toLowerCase()
})
})