diff --git a/scripts/build-post-list.js b/scripts/build-post-list.js index 10ade062dc4..90298401d96 100644 --- a/scripts/build-post-list.js +++ b/scripts/build-post-list.js @@ -183,7 +183,9 @@ async function isDirectory(dir) { } function capitalize(text) { - return text.replace(/(?:^|\s|-)([a-z])/g, (_, char) => char.toUpperCase()) + return text.split(/[\s-]/) + .map(word => word.charAt(0).toUpperCase() + word.slice(1)) + .join(' '); } module.exports = { slugifyToC, buildPostList }