feat: title case following The Chicago Manual of Style (#14048)

This commit is contained in:
Tony
2023-12-15 22:37:12 +08:00
committed by GitHub
parent fac29ed93b
commit a1644ac4ca
4 changed files with 142 additions and 10 deletions
+2 -6
View File
@@ -1,12 +1,8 @@
const { parseDate } = require('@/utils/parse-date');
const title = require('title');
// convert a string into title case
const toTitleCase = (str) =>
str
.toLowerCase()
.split(' ')
.map((word) => word.replace(word[0], word[0].toUpperCase()))
.join(' ');
const toTitleCase = (str) => title(str);
const rWhiteSpace = /\s+/;
const rAllWhiteSpace = /\s+/g;