@@ -10,6 +10,10 @@ import { DateRow } from "@/components/ui/MetaRow";
1010import { Container } from "@/components/ui/SectionHeading" ;
1111import { HERO , HERO_PREVIEW , type Story } from "@/lib/home-content" ;
1212
13+ interface HeroProps {
14+ stories ?: Story [ ] ;
15+ }
16+
1317const HERO_GRADIENT =
1418 "linear-gradient(100.768deg, rgba(4, 26, 109, 0.9) 45.439%, rgba(102, 102, 102, 0) 66.403%)" ;
1519
@@ -49,7 +53,8 @@ function calcDotCount(s: SwiperType): number {
4953 return Math . max ( 1 , s . slides . length - visible + 1 ) ;
5054}
5155
52- export function Hero ( ) {
56+ export function Hero ( { stories } : HeroProps = { } ) {
57+ const preview = stories ?. length ? stories : HERO_PREVIEW ;
5358 const [ swiperInstance , setSwiperInstance ] = useState < SwiperType | null > ( null ) ;
5459 const [ activeIndex , setActiveIndex ] = useState ( 0 ) ;
5560 const [ dotCount , setDotCount ] = useState ( 0 ) ;
@@ -110,7 +115,7 @@ export function Hero() {
110115 onRealIndexChange = { ( s : SwiperType ) => setActiveIndex ( s . realIndex ) }
111116 onResize = { ( s : SwiperType ) => setDotCount ( calcDotCount ( s ) ) }
112117 >
113- { HERO_PREVIEW . map ( ( story ) => (
118+ { preview . map ( ( story ) => (
114119 < SwiperSlide
115120 key = { `${ story . image } -${ story . date } ` }
116121 className = "!w-auto"
@@ -122,7 +127,7 @@ export function Hero() {
122127 </ div >
123128
124129 < div className = { `mt-4 flex items-center gap-2 ${ INDENT } ` } >
125- { HERO_PREVIEW . slice ( 0 , dotCount ) . map ( ( story , i ) => (
130+ { preview . slice ( 0 , dotCount ) . map ( ( story , i ) => (
126131 < button
127132 key = { `dot-${ story . image } -${ story . date } ` }
128133 type = "button"
0 commit comments