2023-01-29 22:16:58 +00:00
import React from 'react'
2023-01-27 23:33:49 +00:00
import Head from 'next/head'
2023-01-28 15:29:17 +00:00
import { GetStaticProps } from 'next'
2023-01-27 23:33:49 +00:00
import { SimpleLayout } from '@/components/SimpleLayout'
import { Card } from '@/components/Card'
2023-01-29 23:04:28 +00:00
import { CardGroup } from '@/components/CardGroup'
2023-01-27 23:33:49 +00:00
import { numberFormat } from '@/lib/numberFormat'
2023-01-29 22:16:58 +00:00
import { getDashboardData } from '@/lib/dashboard'
2023-01-29 23:04:28 +00:00
import type { MetricGroup } from '@/types'
2023-01-27 23:33:49 +00:00
2023-01-29 23:04:28 +00:00
export default function Dashboard ( { metrics } : { metrics : MetricGroup } ) {
2023-01-27 23:33:49 +00:00
return (
< >
< Head >
< title > Dashboard - Ryan Freeman < / title >
< meta
name = "description"
2023-01-29 23:04:28 +00:00
content = "This is my digital life in numbers which is updated daily. I use this dashboard to keep track of various metrics across platforms like Spotify, GitHub, Twitter and more."
2023-01-27 23:33:49 +00:00
/ >
< meta
property = "og:title"
content = "Dashboard - Ryan Freeman"
/ >
< meta
property = "og:description"
2023-01-29 23:04:28 +00:00
content = "This is my digital life in numbers which is updated daily. I use this dashboard to keep track of various metrics across platforms like Spotify, GitHub, Twitter and more."
2023-01-27 23:33:49 +00:00
/ >
< / Head >
< SimpleLayout
title = "Dashboard."
2023-01-29 23:04:28 +00:00
intro = "This is my digital life in numbers which is updated daily. I use this dashboard to keep track of various metrics across platforms like Spotify, GitHub, Twitter and more."
2023-01-27 23:33:49 +00:00
gradient = "bg-gradient-to-r from-orange-300 to-rose-300"
>
2023-01-29 23:04:28 +00:00
{ metrics . map ( ( { groupName , groupItems } ) = > (
< CardGroup title = { groupName } key = { groupName } >
{ groupItems . map ( ( item ) = > (
< Card as = "li" key = { item . title } >
< h2 className = "text-base font-semibold transition group-hover:text-indigo-500 text-zinc-800 dark:text-zinc-400" >
< Card.Link href = { item . href } > { item . title } < / Card.Link >
< / h2 >
< Card.Description className = "text-zinc-800 dark:text-zinc-100 font-semibold text-5xl" >
{ typeof item . value === "number" ? numberFormat ( item . value ) : item . value }
< / Card.Description >
< / Card >
) ) }
< / CardGroup >
2023-01-29 22:16:58 +00:00
) ) }
2023-01-27 23:33:49 +00:00
< / SimpleLayout >
< / >
)
}
export const getStaticProps : GetStaticProps = async ( ) = > {
return {
props : {
2023-01-29 23:04:28 +00:00
metrics : await getDashboardData ( )
2023-01-27 23:33:49 +00:00
}
}
}