-
-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from vab1997/main
Add: stars count repository
- Loading branch information
Showing
3 changed files
with
23 additions
and
5 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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import type { LayoutServerLoad } from './$types'; | ||
import { fetchGitHubStars } from '@/utils/getStarsRepository'; | ||
|
||
export const load: LayoutServerLoad = async ({ url: { pathname } }) => { | ||
return { pathname }; | ||
const stars = await fetchGitHubStars(); | ||
return { pathname, stars }; | ||
}; |
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,10 @@ | ||
export async function fetchGitHubStars() { | ||
const res = await fetch('https://api.github.com/repos/pheralb/svgl'); | ||
const response = await res.json(); | ||
const starsFormated = | ||
response.stargazers_count > 1000 | ||
? `${(response.stargazers_count / 1000).toFixed(1)}K` | ||
: response.stargazers_count; | ||
|
||
return starsFormated; | ||
} |
0d15934
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
svgl – ./
svgl.vercel.app
svgl-git-main-pheralb.vercel.app
svgl-pheralb.vercel.app