diff --git a/pages/anime/anime.pixy b/pages/anime/anime.pixy index 1d9c86d8..91e0ed2a 100644 --- a/pages/anime/anime.pixy +++ b/pages/anime/anime.pixy @@ -41,7 +41,7 @@ component Anime(anime *arn.Anime) .light-button-group each genre in anime.Genres if genre != "" - a.light-button.ajax(href="/genres/" + arn.FixGenre(genre)) + a.light-button.ajax(href="/genres/" + arn.GetGenreIDByName(genre)) Icon(arn.GetGenreIcon(genre)) span= genre diff --git a/pages/genre/genre.go b/pages/genre/genre.go index 3eac53a7..296462fe 100644 --- a/pages/genre/genre.go +++ b/pages/genre/genre.go @@ -9,13 +9,11 @@ import ( // Get ... func Get(ctx *aero.Context) string { genreName := ctx.Get("name") - genreInfo := new(arn.Genre) - - err := arn.GetObject("Genres", genreName, genreInfo) + genre, err := arn.GetGenre(genreName) if err != nil { return err.Error() } - return ctx.HTML(components.Genre(genreInfo.Genre, genreInfo.AnimeList)) + return ctx.HTML(components.Genre(genre.Name, genre.AnimeList)) } diff --git a/pages/genres/genres.go b/pages/genres/genres.go index 84a93d45..310a4b6f 100644 --- a/pages/genres/genres.go +++ b/pages/genres/genres.go @@ -1,11 +1,27 @@ package genres import ( + "fmt" + "github.com/aerogo/aero" + "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components" ) // Get ... func Get(ctx *aero.Context) string { - return ctx.HTML(components.Genres()) + var genres []*arn.Genre + + for _, genreName := range arn.Genres { + genre, err := arn.GetGenre(arn.GetGenreIDByName(genreName)) + + if err == nil { + genre.Name = genreName + genres = append(genres, genre) + } else { + fmt.Println(err) + } + } + + return ctx.HTML(components.Genres(genres)) } diff --git a/pages/genres/genres.pixy b/pages/genres/genres.pixy index e8647639..eff13b2d 100644 --- a/pages/genres/genres.pixy +++ b/pages/genres/genres.pixy @@ -1,10 +1,12 @@ -component Genres +component Genres(genres []*arn.Genre) h2 Genres .grid - each genre in arn.Genres - a.grid-cell.backside-card.ajax(href="/genres/" + arn.FixGenre(genre)) + each genre in genres + a.grid-cell.backside-card.ajax(href="/genres/" + genre.ID) .grid-text.front - GridIcon(arn.GetGenreIcon(genre)) - span= genre - img.grid-image.back(src="https://cdn.anilist.co/img/dir/anime/reg/21519-4I676N0vzuek.jpg", alt="") \ No newline at end of file + GridIcon(arn.GetGenreIcon(genre.Name)) + span= genre.Name + + if len(genre.AnimeList) > 0 + img.grid-image.back(src=genre.AnimeList[0].Image, alt=genre.AnimeList[0].Title.Romaji) \ No newline at end of file