2022-11-06 04:34:34 +09:00
package pages
import (
"github.com/gofiber/fiber/v2"
2022-12-01 02:47:59 +09:00
"codeberg.org/gothub/gothub/utils"
2022-11-06 04:34:34 +09:00
)
type Items struct {
Fullname string
Description string
HtmlUrl string
Stars int64
Forks int64
Watchers int64
Language string
License string
}
func HandleExplore ( c * fiber . Ctx ) error {
// get trending repos
trendingRepos := utils . GetRequest ( "https://api.github.com/search/repositories?q=code&sort=stars&order=desc&per_page=25" )
2022-12-11 03:58:16 +09:00
bruh2 := trendingRepos . Get ( "items" ) . Array ( ) // gjson.Result when I ask for an array. idiots, anyway so I have to do jank shit like this and I hate it. at least it works and is fast enough
2022-11-06 04:34:34 +09:00
var trendingReposArray [ ] Items
for _ , item := range bruh2 {
trendingReposArray = append ( trendingReposArray , Items {
Fullname : item . Get ( "full_name" ) . String ( ) ,
Description : item . Get ( "description" ) . String ( ) ,
HtmlUrl : item . Get ( "html_url" ) . String ( ) ,
Stars : item . Get ( "stargazers_count" ) . Int ( ) ,
Forks : item . Get ( "forks_count" ) . Int ( ) ,
Watchers : item . Get ( "watchers_count" ) . Int ( ) ,
Language : item . Get ( "language" ) . String ( ) ,
License : item . Get ( "license" ) . Get ( "name" ) . String ( ) ,
} )
}
return c . Render ( "explore" , fiber . Map {
2023-01-06 04:58:41 +09:00
"title" : "Explore" ,
2022-11-06 04:34:34 +09:00
"repos" : trendingReposArray ,
} )
}