Added Genre and Tags
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user