-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0b3cd6
commit bd7d560
Showing
7 changed files
with
69 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,4 @@ yarn-error.log* | |
next-env.d.ts | ||
|
||
.early.coverage | ||
*.api.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Issue } from "@/models/github/issue"; | ||
import extractOwnerRepo from "./extractOwnerRepo"; | ||
import { Community } from "@/models/github/community"; | ||
|
||
export default async function getCommunityApi(repoUrl: string) { | ||
const { owner, repo } = extractOwnerRepo(repoUrl); | ||
const res = await fetch( | ||
`https://api.github.com/repos/${owner}/${repo}/community/profile`, | ||
{ | ||
next: { revalidate: 3600 }, | ||
} | ||
); | ||
|
||
const data: Community = await res.json(); | ||
|
||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { Community } from "./github/community"; | ||
import { Issue } from "./github/issue"; | ||
import { Repo } from "./github/repo"; | ||
|
||
export default interface Data { | ||
repo: Repo; | ||
issues: Issue[]; | ||
community: Community; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// To parse this data: | ||
// | ||
// import { Convert, Community } from "./file"; | ||
// | ||
// const community = Convert.toCommunity(json); | ||
// | ||
// These functions will throw an error if the JSON doesn't | ||
// match the expected interface, even if the JSON is valid. | ||
|
||
export interface Community { | ||
health_percentage: number; | ||
description: string; | ||
documentation: null; | ||
files: Files; | ||
updated_at: null; | ||
} | ||
|
||
export interface Files { | ||
code_of_conduct: null; | ||
code_of_conduct_file: null; | ||
contributing: null; | ||
issue_template: null; | ||
pull_request_template: null; | ||
license: null; | ||
readme: Readme; | ||
} | ||
|
||
export interface Readme { | ||
url: string; | ||
html_url: string; | ||
} |