From c69dfbd341afaf111b3165dc40e625526c901a4c Mon Sep 17 00:00:00 2001 From: mkelvers Date: Sat, 18 Apr 2026 00:02:40 +0200 Subject: [PATCH] feat: add studio page template --- internal/templates/studio.templ | 116 ++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 internal/templates/studio.templ diff --git a/internal/templates/studio.templ b/internal/templates/studio.templ new file mode 100644 index 0000000..4f87ccc --- /dev/null +++ b/internal/templates/studio.templ @@ -0,0 +1,116 @@ +package templates + +import "mal/internal/jikan" +import "mal/internal/shared/ui" +import "fmt" + +templ StudioDetails(producer jikan.ProducerResponse, animes []jikan.Anime, hasNext bool, nextPage int) { + @Layout("mal - "+getProducerName(producer), true) { +
+
+
+ if producer.Data.Images.Jpg.ImageURL != "" { + { + } +
+

{ getProducerName(producer) }

+ if producer.Data.Established != "" { +

+ Established: { formatEstablishedDate(producer.Data.Established) } +

+ } + if producer.Data.Count > 0 { +

+ { fmt.Sprintf("%d anime", producer.Data.Count) } +

+ } +
+
+ if producer.Data.About != "" { +

{ producer.Data.About }

+ } +
+
+

Anime

+
+ for _, anime := range animes { +
+ @ui.AnimeCard(ui.AnimeCardProps{ + ID: anime.MalID, + Title: anime.DisplayTitle(), + ImageURL: anime.ImageURL(), + }) +
+ } + if hasNext { + @StudioLoadMore(producer.Data.MalID, nextPage) + } +
+
+
+ } +} + +templ StudioLoadMore(studioID int, nextPage int) { +
+} + +templ StudioAnimeItems(animes []jikan.Anime, hasNext bool, studioID int, nextPage int) { + for _, anime := range animes { +
+ @ui.AnimeCard(ui.AnimeCardProps{ + ID: anime.MalID, + Title: anime.DisplayTitle(), + ImageURL: anime.ImageURL(), + }) +
+ } + if hasNext { + @StudioLoadMore(studioID, nextPage) + } + +} + +func getProducerName(producer jikan.ProducerResponse) string { + for _, title := range producer.Data.Titles { + if title.Type == "Default" { + return title.Title + } + } + return "Studio" +} + +func formatEstablishedDate(date string) string { + if len(date) >= 10 { + return date[:10] + } + return date +}