diff --git a/lib/dashboard.ts b/lib/dashboard.ts index bd9a286..a4d9889 100644 --- a/lib/dashboard.ts +++ b/lib/dashboard.ts @@ -1,3 +1,4 @@ +import {GetServerSidePropsContext} from 'next' import { getTopRepo, getTotalFollowers, @@ -10,7 +11,7 @@ import {getTopArtist, getTopGenre} from '@/lib/spotify' import {getStats} from '@/lib/statsfm' import {Metric} from '@/types' -export async function getDashboardData() { +export async function getDashboardData(context: GetServerSidePropsContext) { const [totalRepos, totalFollowers] = await Promise.all([ getTotalRepos(), getTotalFollowers() diff --git a/pages/dashboard.tsx b/pages/dashboard.tsx index 38c5483..59213f3 100644 --- a/pages/dashboard.tsx +++ b/pages/dashboard.tsx @@ -1,6 +1,6 @@ import React from 'react' import Head from 'next/head' -import {GetStaticProps} from 'next' +import {GetServerSideProps} from 'next' import useSWR from 'swr' import {SimpleLayout} from '@/components/layouts/SimpleLayout' import {Card} from '@/components/ui/Card' @@ -104,10 +104,10 @@ export default function Dashboard({metrics}: { metrics: MetricGroup }) { ) } -export const getStaticProps: GetStaticProps = async () => { +export const getServerSideProps: GetServerSideProps = async (context) => { return { props: { - metrics: await getDashboardData() + metrics: await getDashboardData(context) } } }