import useSWR from "swr"; import { DEV_MODE } from "../../env"; import { HydrationData } from "../../../../libs/types/hydration"; import { HOMEPAGE, HOMEPAGE_ITEMS } from "../../telemetry/constants"; import "./index.scss"; export default function FeaturedArticles(props: HydrationData) { const fallbackData = props.hyData ? props : undefined; const { data: { hyData } = {} } = useSWR( "./index.json", async (url) => { const response = await fetch(url); if (!response.ok) { const text = await response.text(); throw new Error(`${response.status} on ${url}: ${text}`); } return await response.json(); }, { fallbackData, revalidateOnFocus: DEV_MODE, revalidateOnMount: !fallbackData, } ); return hyData?.featuredArticles.length ? (

Featured articles

{hyData.featuredArticles.map((article, index) => { return (
{article.tag && ( {article.tag.title} )}

{article.title}

{article.summary}

); })}
) : null; }