Skip to content

Commit b3dcbfa

Browse files
fix: lettering capitalization in TOC
Signed-off-by: rishabhsharma1997 <[email protected]>
1 parent ecbedd1 commit b3dcbfa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/custom/TOCChapter/TOCChapter.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ interface TOCProps {
99

1010
const TOC: React.FC<TOCProps> = ({ availableChapters, currentChapter, onClick }) => {
1111
const reformatTOC = (data: string): string => {
12-
let newData = data.split('-').join(' ');
13-
const firstLetter = newData.charAt(0).toUpperCase();
14-
newData = `${firstLetter}${newData.slice(1)}`;
15-
return newData;
12+
const words = data.split('-');
13+
const formattedString = words
14+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
15+
.join(' ');
16+
return formattedString;
1617
};
1718
return (
1819
<TOCWrapper>

0 commit comments

Comments
 (0)