mirror of
https://github.com/System-End/site.git
synced 2026-04-19 22:05:11 +00:00
Automatically pull in repo data for showcase projects
This commit is contained in:
parent
2baf00335e
commit
34cae036e1
1 changed files with 9 additions and 0 deletions
|
|
@ -21,9 +21,18 @@ export default async function handler(req, res) {
|
|||
return res.status(400).json({ error: 'No code link provided' })
|
||||
}
|
||||
|
||||
const org = req.body.codeLink?.split('/')?.[3]
|
||||
const name = req.body.codeLink?.split('/')?.slice(-1)?.[0]
|
||||
const ghData = await fetch(`https://api.github.com/repos/${org}/${name}`).then(r => r.json())
|
||||
const description = ghData.description || ''
|
||||
const playLink = ghData.homepage || ''
|
||||
|
||||
const project = await airtable.create({
|
||||
"User": [user.id],
|
||||
"Code Link": req.body.codeLink,
|
||||
"Name": name,
|
||||
"Description": description,
|
||||
"Play Link": playLink,
|
||||
})
|
||||
|
||||
return res.status(200).json(project)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue