Skip to content

Commit

Permalink
fix: lettering capitalization in TOC
Browse files Browse the repository at this point in the history
Signed-off-by: rishabhsharma1997 <[email protected]>
  • Loading branch information
rishabhsharma1997 committed Aug 9, 2024
1 parent ecbedd1 commit b3dcbfa
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/custom/TOCChapter/TOCChapter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ interface TOCProps {

const TOC: React.FC<TOCProps> = ({ availableChapters, currentChapter, onClick }) => {
const reformatTOC = (data: string): string => {
let newData = data.split('-').join(' ');
const firstLetter = newData.charAt(0).toUpperCase();
newData = `${firstLetter}${newData.slice(1)}`;
return newData;
const words = data.split('-');
const formattedString = words
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ');
return formattedString;
};
return (
<TOCWrapper>
Expand Down

0 comments on commit b3dcbfa

Please sign in to comment.