portfolio/lib/dashboard.ts

42 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-01-28 21:24:05 +00:00
import {getTotalFollowers, getTotalRepos, getTotalStars} from '@/lib/github'
2023-01-28 21:59:01 +00:00
import {getAllArticles} from '@/lib/getAllArticles'
import {getViews} from '@/lib/views'
2023-01-28 21:24:05 +00:00
export async function dashboard() {
const [totalRepos, totalFollowers] = await Promise.all([
getTotalRepos(),
getTotalFollowers()
])
const totalStars = await getTotalStars(totalRepos)
2023-01-29 11:24:06 +00:00
const totalArticles = (await getAllArticles()).length
const totalArticleViews = (await getViews()).views
2023-01-28 21:24:05 +00:00
return [
{
title: "GitHub Repos",
2023-01-29 11:24:06 +00:00
metric: totalRepos,
2023-01-28 23:04:49 +00:00
href: "https://github.com/r-freeman?tab=repositories"
2023-01-28 21:24:05 +00:00
},
{
title: "GitHub Followers",
2023-01-29 11:24:06 +00:00
metric: totalFollowers,
2023-01-28 23:04:49 +00:00
href: "https://github.com/r-freeman?tab=followers"
2023-01-28 21:24:05 +00:00
},
{
title: "GitHub Stars",
2023-01-29 11:24:06 +00:00
metric: totalStars,
2023-01-28 21:24:05 +00:00
href: "https://github.com/r-freeman/"
2023-01-28 21:59:01 +00:00
},
{
title: "Total Articles",
2023-01-29 11:24:06 +00:00
metric: totalArticles,
2023-01-28 21:59:01 +00:00
href: "/writing"
},
{
title: "Total Article Views",
2023-01-29 11:24:06 +00:00
metric: totalArticleViews,
2023-01-28 21:59:01 +00:00
href: "/writing"
2023-01-28 21:24:05 +00:00
}
]
}