Added Genre and Tags

This commit is contained in:
2026-09-25 14:21:54 -04:00
parent d9d19d175f
commit 57b2d8835d
7 changed files with 136 additions and 9 deletions
+24
View File
@@ -117,6 +117,30 @@
}
</div>
@if (show.Genres.Count > 0 || show.Tags.Count > 0)
{
<div class="airing-taxonomy">
@foreach (var genre in show.Genres)
{
<span class="genre-chip">@genre</span>
}
@foreach (var tag in show.VisibleTags)
{
<span class="tag-chip">#@tag</span>
}
@if (show.OverflowTags.Count > 0)
{
<details class="tag-overflow">
<summary class="tag-chip tag-more">+@show.OverflowTags.Count more</summary>
@foreach (var tag in show.OverflowTags)
{
<span class="tag-chip">#@tag</span>
}
</details>
}
</div>
}
@if (show.EpisodeProgressPercent.HasValue)
{
<div class="airing-progress" title="@show.LatestEpisodeNumber of @show.TotalEpisodes episodes aired">
+36
View File
@@ -158,6 +158,42 @@ public class IndexModel : PageModel
}
}
// --- Genres & tags ---------------------------------------------------
/// <summary>How many tags are shown before the rest are tucked behind a "more" toggle.</summary>
public const int VisibleTagCount = 10;
/// <summary>
/// Genres from both sources, AniList first. TMDB's "Animation" genre is dropped since every
/// show on this page is anime, so it carries no information.
/// </summary>
public List<string> Genres => MergeDistinct(AnilistDetails?.Genres, CachedDetails?.Genres)
.Where(g => !string.Equals(g, "Animation", StringComparison.OrdinalIgnoreCase))
.ToList();
/// <summary>AniList tags followed by TMDB keywords, minus anything already listed as a genre.</summary>
public List<string> Tags
{
get
{
var genres = new HashSet<string>(Genres, StringComparer.OrdinalIgnoreCase);
return MergeDistinct(AnilistDetails?.Tags, CachedDetails?.Keywords)
.Where(t => !genres.Contains(t))
.ToList();
}
}
public List<string> VisibleTags => Tags.Take(VisibleTagCount).ToList();
public List<string> OverflowTags => Tags.Skip(VisibleTagCount).ToList();
private static IEnumerable<string> MergeDistinct(params IEnumerable<string>?[] sources) =>
sources
.Where(s => s != null)
.SelectMany(s => s!)
.Where(s => !string.IsNullOrWhiteSpace(s))
.Select(s => s.Trim())
.Distinct(StringComparer.OrdinalIgnoreCase);
/// <summary>Anilist descriptions are HTML fragments; flatten them to plain text for display.</summary>
public string? AnilistDescription
{