import shuffle from 'lodash.shuffle'; import ChannelGrid from '@/components/ChannelGrid'; import FeatureImage from '@/components/FeatureImage'; import Footer from '@/components/Footer'; import Hero from '@/components/Hero'; import Nav from '@/components/Nav'; import Wrapper from '@/components/Wrapper'; async function getChannels() { const res = await fetch('https://stats.koodiklinikka.fi/api/channels', { next: { revalidate: 3600 } }); if (!res.ok) { // This will activate the closest `error.js` Error Boundary throw new Error('Failed to fetch data'); } return res.json(); } export default async function Home() { let channels: Channel[] = await getChannels(); channels = channels.sort((a, b) => (a.messages_today > b.messages_today ? -1 : 1)); return ( <>