1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-22 17:23:22 +01:00
portfolio/scripts/github.js
Matthias Kretschmann b315f5bbb0
Migrate to Framer Motion (#656)
* migrate to Framer Motion

* animation tweaks

* faster animations

* handle reduced motion

* handle SSR
2021-09-11 21:37:38 +02:00

43 lines
1014 B
JavaScript

const axios = require('axios')
//
// Get GitHub repos
//
const gitHubConfig = {
headers: {
'User-Agent': 'kremalicious/portfolio',
Authorization: `token ${process.env.GATSBY_GITHUB_TOKEN}`
}
}
async function getGithubRepos(data) {
let repos = []
let holder = {}
for (let item of data) {
const user = item.split('/')[0]
const repoName = item.split('/')[1]
const repo = await axios.get(
`https://api.github.com/repos/${user}/${repoName}`,
gitHubConfig
)
holder.name = repo.data.name
holder.full_name = repo.data.full_name
holder.description = repo.data.description
holder.html_url = repo.data.html_url
holder.homepage = repo.data.homepage
holder.stargazers_count = repo.data.stargazers_count
holder.pushed_at = repo.data.pushed_at
repos.push(holder)
holder = {}
}
// sort by pushed to, newest first
repos = repos.sort((a, b) => b.pushed_at.localeCompare(a.pushed_at))
return repos
}
module.exports = { getGithubRepos }