mirror of
https://github.com/r-freeman/portfolio.git
synced 2024-11-11 18:45:41 +00:00
Changed dashboard to use GetServerSideProps
This commit is contained in:
parent
4c2e1e4749
commit
2b78a4fffe
@ -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()
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user