feat(helper): titleCase

- simpler version of https://github.com/rvagg/titlecase
  * no exceptions
This commit is contained in:
MDLeom 2020-08-19 03:29:17 +00:00
parent bbdfe74b48
commit 9490884b5a
No known key found for this signature in database
GPG Key ID: 32D3E28E96A695E8
5 changed files with 17 additions and 4 deletions

View File

@ -4,7 +4,7 @@
let title = page.title
if (is_archive()) {
title = titlecase(config.archive_dir)
title = titleCase(config.archive_dir)
if (is_month()) {
title += ': ' + page.year + '/' + page.month

View File

@ -2,6 +2,6 @@
<%- list_tags(post.tags, {
show_count: false,
class: 'article-tag',
transform: titlecase
transform: titleCase
}) %>
<% } %>

View File

@ -10,6 +10,6 @@
<%- list_tags({
amount: 0,
class: 'index',
transform: titlecase
transform: titleCase
}) %>
</div>

View File

@ -5,6 +5,6 @@
<%- list_tags({
amount: 0,
class: 'index',
transform: titlecase
transform: titleCase
}) %>
</div>

View File

@ -0,0 +1,13 @@
'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.charAt(0).toUpperCase() + match.substr(1)
})
})