// === imports === import Button from '@/components/aia/button'; import EventCard from '@/components/aia/event-card'; import { useState, useEffect, useRef } from 'react'; import { getNewsData } from '@/lib/utils'; import { carousel } from '/data/www/aia-official-en-main/web/src/js/patterns/carousel.js';// 重新 pull 的時候 要重新把 landing 改為 export 的函數 export default function SectionLanding() { const carouselRef = useRef(null); const [events, setEvents] = useState([]); const eventCards = events.map((event: any) => { return { eventCardTitle: event.acf.title, eventCardType: event.acf.type, eventCardDate: event.acf.date, eventCardLocation: event.acf.address, eventCardImage: event.acf.imageUrl, eventCardLink: route('event-detail', { id: event.id }), eventCardLinkText: "for more information", }; }); async function initialize() { const data = await getNewsData('', 1, 2); setEvents([...data]); // 將獲取到的數據添加到 events 陣列中 // 在這裡可以進一步處理數據,例如更新狀態或渲染組件 } useEffect(() => { initialize(); }, []); // 空依賴陣列 -> 僅在初次掛載執行一次 // useEffect(() => { // (async () => { // setEvents(await getNewsData()); // console.log('$$$$$$$', events); // })(); // }, []); // 空依賴陣列 -> 僅在初次掛載執行一次 return (
{/* Landing Background */}

AI for All,
All in AI

Fostering a thriving AI ecosystem in Taiwan

{eventCards .map((card: any, index: number) => ( ))}
); }