mirror of
https://github.com/System-End/site.git
synced 2026-04-20 00:25:19 +00:00
github graphql
This commit is contained in:
parent
ffd587f796
commit
249ebe4d82
2 changed files with 9 additions and 80 deletions
|
|
@ -1,17 +1,9 @@
|
|||
import { graphql } from '@octokit/graphql'
|
||||
import { createAppAuth } from '@octokit/auth-app'
|
||||
|
||||
const auth = createAppAuth({
|
||||
appId: process.env.GITHUB_APP_ID,
|
||||
privateKey: 'process.env.GITHUB_PRIVATE_KEY',
|
||||
installationId: process.env.GITHUB_INSTALLATION_ID
|
||||
})
|
||||
|
||||
export default async function handler(req, res) {
|
||||
const { organization } = await graphql(
|
||||
!req.query.admin
|
||||
? `
|
||||
query {
|
||||
`
|
||||
{
|
||||
organization(login: "hackclub") {
|
||||
sinerider: repository(name: "sinerider") {
|
||||
stargazerCount
|
||||
|
|
@ -20,20 +12,10 @@ export default async function handler(req, res) {
|
|||
stargazerCount
|
||||
}
|
||||
}
|
||||
}`
|
||||
: `query {
|
||||
organization(login: "hackclub") {
|
||||
sinerider: repository(name: "sinerider") {
|
||||
stargazerCount
|
||||
},
|
||||
sprig: repository(name: "sprig") {
|
||||
stargazerCount
|
||||
}
|
||||
}
|
||||
}`,
|
||||
}`,
|
||||
{
|
||||
request: {
|
||||
hook: auth.hook
|
||||
headers: {
|
||||
authorization: `token ${process.env.GITHUB_TOKEN}`
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -39,13 +39,6 @@ import Inspect from '../components/inspect'
|
|||
import AssembleImgFile from '../public/home/assemble.jpg'
|
||||
import RelativeTime from 'react-relative-time'
|
||||
import { get } from 'lodash'
|
||||
import {
|
||||
ApolloClient,
|
||||
InMemoryCache,
|
||||
gql,
|
||||
createHttpLink
|
||||
} from '@apollo/client'
|
||||
import { setContext } from '@apollo/client/link/context'
|
||||
|
||||
let Highlight = styled(Text)`
|
||||
color: inherit;
|
||||
|
|
@ -725,56 +718,10 @@ export async function getStaticProps() {
|
|||
|
||||
gameTitle = game.map(r => r.title)
|
||||
|
||||
// let stars = await fetch('https://hackclub.com/api/stars').then(
|
||||
// res => res.json
|
||||
// )
|
||||
let stars = await fetch('https://hackclub.com/api/stars').then(
|
||||
res => res.json
|
||||
)
|
||||
|
||||
let stars = {
|
||||
"data": {
|
||||
"organization": {
|
||||
"sinerider": {
|
||||
"stargazerCount": 186
|
||||
},
|
||||
"sprig": {
|
||||
"stargazerCount": 515
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// const httpLink = createHttpLink({
|
||||
// uri: 'https://api.github.com/graphql',
|
||||
// });
|
||||
|
||||
// const authLink = setContext(() => {
|
||||
// return {
|
||||
// headers: {
|
||||
// authorization: `Bearer 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`
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
|
||||
// const client = new ApolloClient({
|
||||
// link: authLink.concat(httpLink),
|
||||
// cache: new InMemoryCache()
|
||||
// });
|
||||
|
||||
// const { githubStars } = await client.query({
|
||||
// query: gql`
|
||||
// query {
|
||||
// organization(login: "hackclub") {
|
||||
// sinerider: repository(name: "sinerider") {
|
||||
// stargazerCount
|
||||
// },
|
||||
// sprig: repository(name: "sprig") {
|
||||
// stargazerCount
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// `
|
||||
// })
|
||||
|
||||
// console.log('g', githubStars)
|
||||
return {
|
||||
props: {
|
||||
dataPieces,
|
||||
|
|
@ -786,7 +733,7 @@ export async function getStaticProps() {
|
|||
hackathonsData,
|
||||
bankData,
|
||||
slackData,
|
||||
stars: stars.data.organization
|
||||
stars: stars.data
|
||||
},
|
||||
revalidate: 30
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue