{"version":3,"file":"index-0ns_7KN6.js","sources":["../../../app/routes/index.tsx"],"sourcesContent":["import {\n json,\n type HeadersFunction,\n type LoaderFunction,\n} from '@remix-run/node'\nimport { useLoaderData } from '@remix-run/react'\nimport { ButtonLink } from '~/components/button.tsx'\nimport { ServerError } from '~/components/errors.tsx'\nimport { BlogSection } from '~/components/sections/blog-section.tsx'\nimport { HeroSection } from '~/components/sections/hero-section.tsx'\nimport { type MdxListItem } from '~/types.ts'\nimport { getBlogRecommendations } from '~/utils/blog.server.ts'\nimport { getBlogMdxListItems } from '~/utils/mdx.server.ts'\nimport {\n formatNumber,\n reuseUsefulLoaderHeaders,\n useCapturedRouteError,\n} from '~/utils/misc.tsx'\nimport { getServerTimeHeader } from '~/utils/timing.server.ts'\nimport { images } from '~/images.tsx'\nimport { useEffect, useState } from 'react'\n\ntype LoaderData = {\n blogPostCount: string\n blogRecommendations: Array\n randomImageNo: number\n}\n\nexport const loader: LoaderFunction = async ({ request }) => {\n const timings = {}\n const [posts, blogRecommendations] = await Promise.all([\n getBlogMdxListItems({ request, timings }),\n getBlogRecommendations({ request, timings }),\n ])\n\n const data: LoaderData = {\n blogRecommendations,\n blogPostCount: formatNumber(posts.length),\n randomImageNo: Math.random(),\n }\n return json(data, {\n headers: {\n 'Cache-Control': 'private, max-age=3600',\n Vary: 'Cookie',\n 'Server-Timing': getServerTimeHeader(timings),\n },\n })\n}\n\nexport const headers: HeadersFunction = reuseUsefulLoaderHeaders\n\nfunction getRandomNumber(min: number, max: number) {\n return Math.floor(Math.random() * (max - min + 1) + min)\n}\n\nexport default function IndexRoute() {\n const data = useLoaderData()\n const [randomIndex, setRandomIndex] = useState(0)\n\n const coverImages = [\n images.homeCover1,\n images.homeCover2,\n images.homeCover3,\n images.homeCover4,\n images.homeCover5,\n ]\n\n useEffect(() => {\n setRandomIndex(getRandomNumber(0, coverImages.length - 1))\n }, [coverImages.length])\n\n const coverImage = coverImages[randomIndex]!\n\n return (\n
\n \n \n Visit the blog\n \n
\n }\n />\n\n
\n \n
\n \n )\n}\n\nexport function ErrorBoundary() {\n const error = useCapturedRouteError()\n console.error(error)\n return \n}\n"],"names":["getRandomNumber","min","max","Math","floor","random","IndexRoute","data","useLoaderData","randomIndex","setRandomIndex","useState","coverImages","images","homeCover1","homeCover2","homeCover3","homeCover4","homeCover5","useEffect","length","coverImage","children","jsx","HeroSection","title","smallSubtitle","animatedTitle","imageBuilder","imageSize","action","className","ButtonLink","to","variant","prefetch","BlogSection","articles","blogRecommendations","description","ErrorBoundary","error","useCapturedRouteError","console","ServerError"],"mappings":"4SAmDA,SAASA,EAAgBC,EAAaC,EAAa,CAC1C,OAAAC,KAAKC,MAAMD,KAAKE,OAAA,GAAYH,EAAMD,EAAM,GAAKA,CAAG,CACzD,CAEA,SAAwBK,GAAa,CACnC,MAAMC,EAAOC,IACP,CAACC,EAAaC,CAAc,EAAIC,WAAS,CAAC,EAE1CC,EAAc,CAClBC,EAAOC,WACPD,EAAOE,WACPF,EAAOG,WACPH,EAAOI,WACPJ,EAAOK,UAAA,EAGTC,EAAAA,UAAU,IAAM,CACdT,EAAeV,EAAgB,EAAGY,EAAYQ,OAAS,CAAC,CAAC,CAC3D,EAAG,CAACR,EAAYQ,MAAM,CAAC,EAEjB,MAAAC,EAAaT,EAAYH,CAAW,EAE1C,cACG,MACC,CAAAa,SAAA,CAAAC,EAAA,IAACC,EAAA,CACCC,MAAM,uGACNC,cAAc,kBACdC,cAAa,GACbC,aAAcP,EACdQ,UAAU,QACVC,OACEP,EAAA,IAAC,MAAI,CAAAQ,UAAU,8BACbT,SAACC,EAAA,IAAAS,EAAA,CAAWC,GAAG,QAAQC,QAAQ,UAAUC,SAAS,SAASb,0BAE3D,EACF,CAAA,CAEJ,EAEAC,EAAA,IAAC,OAAK,CAAAQ,UAAU,QACdT,SAAAC,EAAA,IAACa,EAAA,CACCC,SAAU9B,EAAK+B,oBACfb,MAAM,qBACNc,YAAY,GACd,CACF,CAAA,CAAA,CACF,CAAA,CAEJ,CAEO,SAASC,GAAgB,CAC9B,MAAMC,EAAQC,IACdC,eAAQF,MAAMA,CAAK,QACXG,EAAY,CAAA,CAAA,CACtB"}