@@ -8,10 +8,25 @@ interface DescriptionSectionProps {
88export default function DescriptionSection ( {
99 description,
1010} : DescriptionSectionProps ) {
11+ // Transform heading levels: h1->h2, h2->h3, h3->h4, h4->h5, h5->h6, h6->h6
12+ const transformedDescription = description
13+ . replace ( / < h 6 ( [ ^ > ] * ) > / g, "<h6$1>" )
14+ . replace ( / < \/ h 6 > / g, "</h6>" )
15+ . replace ( / < h 5 ( [ ^ > ] * ) > / g, "<h6$1>" )
16+ . replace ( / < \/ h 5 > / g, "</h6>" )
17+ . replace ( / < h 4 ( [ ^ > ] * ) > / g, "<h5$1>" )
18+ . replace ( / < \/ h 4 > / g, "</h5>" )
19+ . replace ( / < h 3 ( [ ^ > ] * ) > / g, "<h4$1>" )
20+ . replace ( / < \/ h 3 > / g, "</h4>" )
21+ . replace ( / < h 2 ( [ ^ > ] * ) > / g, "<h3$1>" )
22+ . replace ( / < \/ h 2 > / g, "</h3>" )
23+ . replace ( / < h 1 ( [ ^ > ] * ) > / g, "<h2$1>" )
24+ . replace ( / < \/ h 1 > / g, "</h2>" ) ;
25+
1126 const isLongDescription =
12- description . length > 300 ||
13- ( description . match ( / < \/ p > / g) || [ ] ) . length > 1 ||
14- ( description . match ( / < h [ 1 - 6 ] > / g) || [ ] ) . length > 0 ;
27+ transformedDescription . length > 300 ||
28+ ( transformedDescription . match ( / < \/ p > / g) || [ ] ) . length > 1 ||
29+ ( transformedDescription . match ( / < h [ 1 - 6 ] > / g) || [ ] ) . length > 0 ;
1530
1631 return (
1732 < div className = "mb-8" >
@@ -25,8 +40,10 @@ export default function DescriptionSection({
2540 />
2641 { /* Content container with collapse effect */ }
2742 < div className = "overflow-hidden transition-all duration-300 ease-in-out peer-checked:max-h-[9999px] max-h-[12.5em]" >
28- < div className = "prose prose-h1:font-bold prose-p:text-gray-700 prose-a:text-blue-600 !max-w-none" >
29- < div dangerouslySetInnerHTML = { { __html : description } } />
43+ < div className = "prose prose-h2:font-bold prose-h3:font-bold prose-h4:font-bold prose-h5:font-bold prose-h6:font-bold prose-p:text-gray-700 prose-a:text-blue-600 !max-w-none" >
44+ < div
45+ dangerouslySetInnerHTML = { { __html : transformedDescription } }
46+ />
3047 </ div >
3148 </ div >
3249
@@ -78,8 +95,8 @@ export default function DescriptionSection({
7895 </ div >
7996 </ div >
8097 ) : (
81- < div className = "prose prose-h1 :font-bold prose-p:text-gray-700 prose-a:text-blue-600 prose-max-w-none" >
82- < div dangerouslySetInnerHTML = { { __html : description } } />
98+ < div className = "prose prose-h2:font-bold prose-h3:font-bold prose-h4:font-bold prose-h5:font-bold prose-h6 :font-bold prose-p:text-gray-700 prose-a:text-blue-600 prose-max-w-none" >
99+ < div dangerouslySetInnerHTML = { { __html : transformedDescription } } />
83100 </ div >
84101 ) }
85102 </ div >
0 commit comments