portfolio/lib/dashboard.ts

42 lines
1.1 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-28 21:59:01 +00:00
const articles = await getAllArticles()
const {views} = await getViews()
2023-01-28 21:24:05 +00:00
return [
{
title: "GitHub Repos",
total: 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",
total: 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",
total: totalStars,
href: "https://github.com/r-freeman/"
2023-01-28 21:59:01 +00:00
},
{
title: "Total Articles",
total: articles.length,
href: "/writing"
},
{
title: "Total Article Views",
total: views,
href: "/writing"
2023-01-28 21:24:05 +00:00
}
]
}