mirror of
https://github.com/r-freeman/portfolio.git
synced 2024-11-11 18:45:41 +00:00
Added spotify data to dashboard
This commit is contained in:
parent
7170e786dd
commit
4f435d613d
5
json/data.json
Normal file
5
json/data.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"statsfm": {
|
||||||
|
"top_genre": "modern rock"
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
import {getTotalFollowers, getTotalRepos, getTotalStars} from '@/lib/github'
|
import {getTotalFollowers, getTotalRepos, getTotalStars} from '@/lib/github'
|
||||||
import {getAllArticles} from '@/lib/getAllArticles'
|
import {getAllArticles} from '@/lib/getAllArticles'
|
||||||
import {getViews} from '@/lib/views'
|
import {getViews} from '@/lib/views'
|
||||||
|
import {getLocalData} from '@/lib/localData'
|
||||||
import {Metric} from '@/types'
|
import {Metric} from '@/types'
|
||||||
|
|
||||||
export async function getDashboardData() {
|
export async function getDashboardData() {
|
||||||
@ -12,8 +13,15 @@ export async function getDashboardData() {
|
|||||||
const totalStars = await getTotalStars(totalRepos)
|
const totalStars = await getTotalStars(totalRepos)
|
||||||
const totalArticles = (await getAllArticles()).length
|
const totalArticles = (await getAllArticles()).length
|
||||||
const totalArticleViews = (await getViews()).views
|
const totalArticleViews = (await getViews()).views
|
||||||
|
const {statsfm} = JSON.parse(await getLocalData())
|
||||||
|
|
||||||
const metrics: Metric[] = [
|
const metrics: Metric[] = [
|
||||||
|
{
|
||||||
|
title: "Top genre",
|
||||||
|
value: statsfm.top_genre,
|
||||||
|
group: "Spotify",
|
||||||
|
href: "https://spotify.com/"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "Repos",
|
title: "Repos",
|
||||||
value: totalRepos,
|
value: totalRepos,
|
||||||
@ -33,17 +41,18 @@ export async function getDashboardData() {
|
|||||||
href: "https://github.com/r-freeman/"
|
href: "https://github.com/r-freeman/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Total Articles",
|
title: "Total articles",
|
||||||
value: totalArticles,
|
value: totalArticles,
|
||||||
group: "Website",
|
group: "Website",
|
||||||
href: "/writing"
|
href: "/writing"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Total Article Views",
|
title: "Total article views",
|
||||||
value: totalArticleViews,
|
value: totalArticleViews,
|
||||||
group: "Website",
|
group: "Website",
|
||||||
href: "/writing"
|
href: "/writing"
|
||||||
}
|
},
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
// sort metrics into named groups
|
// sort metrics into named groups
|
||||||
|
7
lib/localData.ts
Normal file
7
lib/localData.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import path from 'path'
|
||||||
|
import {promises as fs} from 'fs'
|
||||||
|
|
||||||
|
export async function getLocalData() {
|
||||||
|
const jsonDirectory = path.join(process.cwd(), 'json')
|
||||||
|
return await fs.readFile(jsonDirectory + '/data.json', 'utf8')
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user