| 1 |
@* A name that links to Spotify when we know its id, and is plain text when we don't. *@ |
| 2 |
@* Plays recorded before an id was stored, or ones RVRB passed through without one, are *@ |
| 3 |
@* ordinary here rather than exceptional - hence one component instead of an @@if per table. *@ |
| 4 |
|
| 5 |
@if (string.IsNullOrEmpty(Id)) |
| 6 |
{ |
| 7 |
@Name |
| 8 |
} |
| 9 |
else |
| 10 |
{ |
| 11 |
<a href="@Url">@Name</a> |
| 12 |
} |
| 13 |
|
| 14 |
@code { |
| 15 |
/// <summary>What the id identifies: <c>track</c>, <c>artist</c>, <c>album</c>.</summary> |
| 16 |
[Parameter] |
| 17 |
[EditorRequired] |
| 18 |
public required string Kind { get; set; } |
| 19 |
|
| 20 |
/// <summary>The Spotify id. Null or empty renders the name unlinked.</summary> |
| 21 |
[Parameter] |
| 22 |
public string? Id { get; set; } |
| 23 |
|
| 24 |
[Parameter] |
| 25 |
[EditorRequired] |
| 26 |
public required string Name { get; set; } |
| 27 |
|
| 28 |
private string Url => $"https://open.spotify.com/{Kind}/{Uri.EscapeDataString(Id!)}"; |
| 29 |
} |