mirror of https://gitlab.com/curben/blog
refactor(titleCase): String index & String.substring()
- String.substr() is a deprecated API - Convert the rest to lowercase
This commit is contained in:
parent
9490884b5a
commit
25aab0be28
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
hexo.extend.helper.register('titleCase', (str) => {
|
hexo.extend.helper.register('titleCase', (str) => {
|
||||||
return str.replace(/[\w]+[^\s-]*/g, (match) => {
|
return str.replace(/[\w]+[^\s]*/g, (match) => {
|
||||||
return match.charAt(0).toUpperCase() + match.substr(1)
|
return match[0].toUpperCase() + match.substring(1).toLowerCase()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue