11"use client"
22
33import { LinkButton } from "@/components/ui/LinkButton"
4- import { TextReveal } from "@/components/ui/TextReveal"
54import { getLocaleFromPath , localizeHref } from "@/lib/i18n"
65import { ANIMATION_PRESETS , cn , type AnimationPreset } from "@/lib/utils"
76import { m as motion , type Variants } from "motion/react"
@@ -17,6 +16,29 @@ function hasHighlightedHeading(heading?: string | null) {
1716 return Boolean ( heading && / \* \* .* ?\* \* / . test ( heading ) )
1817}
1918
19+ function renderFormattedText ( text : string ) {
20+ return text . split ( / ( \* \* .* ?\* \* ) / g) . flatMap ( ( part , partIndex ) => {
21+ const highlighted = part . startsWith ( "**" ) && part . endsWith ( "**" ) && part . length > 4
22+ const value = highlighted ? part . slice ( 2 , - 2 ) : part
23+
24+ return value . split ( / ( \\ n | \r \n | \n | \r ) / g) . map ( ( linePart , lineIndex ) => {
25+ const key = `${ partIndex } -${ lineIndex } `
26+
27+ if ( / ^ ( \\ n | \r \n | \n | \r ) $ / . test ( linePart ) ) {
28+ return < br key = { key } />
29+ }
30+
31+ if ( ! highlighted ) return linePart
32+
33+ return (
34+ < span className = "text-white" key = { key } >
35+ { linePart }
36+ </ span >
37+ )
38+ } )
39+ } )
40+ }
41+
2042interface SectionProps {
2143 children : ReactNode
2244 funnelType ?: "center" | "left"
@@ -142,11 +164,11 @@ export function Section({
142164 { createElement (
143165 motion [ headingTag ] ,
144166 { variants : staggerItem , className : headingClassName } ,
145- heading ? < TextReveal > { heading } </ TextReveal > : null ,
167+ heading ? renderFormattedText ( heading ) : null ,
146168 ) }
147169 { description && (
148170 < motion . p variants = { staggerItem } className = "relative z-10 max-w-[90vw] text-center text-xl font-medium text-white/75 lg:w-1/2" >
149- < TextReveal > { description } </ TextReveal >
171+ { renderFormattedText ( description ) }
150172 </ motion . p >
151173 ) }
152174 { showLinkButton && linkUrl &&
@@ -168,11 +190,11 @@ export function Section({
168190 { createElement (
169191 motion [ headingTag ] ,
170192 { variants : staggerItem , className : headingClassName } ,
171- heading ? < TextReveal > { heading } </ TextReveal > : null ,
193+ heading ? renderFormattedText ( heading ) : null ,
172194 ) }
173195 { description && (
174196 < motion . p variants = { staggerItem } className = "relative z-10 max-w-[90vw] text-xl font-medium text-white/75 lg:w-1/2" >
175- < TextReveal > { description } </ TextReveal >
197+ { renderFormattedText ( description ) }
176198 </ motion . p >
177199 ) }
178200 { showLinkButton && linkUrl &&
0 commit comments