Files
2025-10-27 21:39:50 -04:00

43 lines
1.0 KiB
Plaintext

@using System.Text.Json
@if (_documents.Count > 0)
{
<div class="product-docs mt-4">
<h5 class="mb-3">Documents</h5>
<ul class="list-unstyled mb-0">
@foreach (var doc in _documents)
{
<li class="mb-2">
<a href="@doc.Url" target="_blank" rel="noopener noreferrer">@doc.Title</a>
</li>
}
</ul>
</div>
}
@code {
[Parameter]
public string Json { get; set; } = "[]";
private static readonly JsonSerializerOptions SerializerOptions = new()
{
PropertyNameCaseInsensitive = true
};
private List<DocumentLink> _documents { get; set; } = new();
protected override void OnParametersSet()
{
try
{
_documents = JsonSerializer.Deserialize<List<DocumentLink>>(Json, SerializerOptions) ?? new List<DocumentLink>();
}
catch
{
_documents = new List<DocumentLink>();
}
}
private sealed record DocumentLink(string Title, string Url);
}