mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-03 20:15:27 +00:00
feat: add helper function for title case
This commit is contained in:
@@ -6,4 +6,5 @@ export * from './remark-widont';
|
||||
export * from './sort-by-alphabet';
|
||||
export * from './sort-by-date';
|
||||
export * from './sort-by-sortkey';
|
||||
export * from './titlecase';
|
||||
export * from './word-count';
|
||||
|
||||
7
src/utils/titlecase.ts
Normal file
7
src/utils/titlecase.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export const titleCase = (str: string) => {
|
||||
let words = str.toLowerCase().split(' ');
|
||||
for (let i = 0; i < words.length; i++) {
|
||||
words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1);
|
||||
}
|
||||
return words.join(' ');
|
||||
};
|
||||
Reference in New Issue
Block a user