mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-29 21:54:19 +01:00
Zen lander (#2907)
Co-authored-by: David Hill <iamdavidhill@gmail.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com> Co-authored-by: Jay V <air@live.ca>
This commit is contained in:
28
packages/console/app/src/lib/github.ts
Normal file
28
packages/console/app/src/lib/github.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { query } from "@solidjs/router"
|
||||
|
||||
export const github = query(async () => {
|
||||
"use server"
|
||||
try {
|
||||
const [meta, releases, contributors] = await Promise.all([
|
||||
fetch("https://api.github.com/repos/sst/opencode").then((res) => res.json()),
|
||||
fetch("https://api.github.com/repos/sst/opencode/releases").then((res) => res.json()),
|
||||
fetch("https://api.github.com/repos/sst/opencode/contributors?per_page=1"),
|
||||
])
|
||||
const [release] = releases
|
||||
const contributorCount = Number.parseInt(
|
||||
contributors.headers
|
||||
.get("Link")!
|
||||
.match(/&page=(\d+)>; rel="last"/)!
|
||||
.at(1)!,
|
||||
)
|
||||
return {
|
||||
stars: meta.stargazers_count,
|
||||
release: {
|
||||
name: release.name,
|
||||
url: release.html_url,
|
||||
},
|
||||
contributors: contributorCount,
|
||||
}
|
||||
} catch {}
|
||||
return undefined
|
||||
}, "github")
|
||||
Reference in New Issue
Block a user