@namespace Shared.Pages @page "/docs" Docs

Documentation

Rules, keywords, factions, and more.

@if (selectedDoc == null) {
@foreach (var doc in filteredDocs) {
@doc.Category

@doc.Title

@if (GetField(doc, "description") is { Length: > 0 } desc) {

@desc

}
} @if (!filteredDocs.Any()) {

No documentation found matching your search.

}
} else {
@selectedDoc.Category

@selectedDoc.Title

@{ var fm = selectedDoc.Frontmatter; } @foreach (var kvp in fm) { var key = kvp.Key; var val = kvp.Value; if (string.IsNullOrWhiteSpace(val)) continue;
@GetLabel(key) @if (key == "description") {

@val

} else { @val }
}
}
@code { private string searchQuery = ""; private string? selectedCategory; private DocData? selectedDoc; private List categories = []; private List allDocs = []; protected override void OnInitialized() { allDocs = DocDatabase.Docs.OrderBy(d => d.Category).ThenBy(d => d.Title).ToList(); categories = allDocs.Select(d => d.Category).Distinct().OrderBy(c => c).ToList(); } private IEnumerable filteredDocs => allDocs .Where(d => (selectedCategory == null || d.Category == selectedCategory) && (string.IsNullOrWhiteSpace(searchQuery) || d.Title.Contains(searchQuery, StringComparison.OrdinalIgnoreCase) || (GetField(d, "description")?.Contains(searchQuery, StringComparison.OrdinalIgnoreCase) ?? false))); private void SelectCategory(string? category) { selectedCategory = category; selectedDoc = null; } private void SelectDoc(DocData? doc) { selectedDoc = doc; } private static string? GetField(DocData doc, string key) { return doc.Frontmatter.TryGetValue(key, out var val) && !string.IsNullOrWhiteSpace(val) ? val : null; } private static string GetLabel(string key) => key switch { "category" => "Category", "description" => "Description", "essencePrice" => "Essence Price", "crytalPrice" => "Crystal Price", "coreChargesPrice" => "Core Charges Price", "pricePerPack" => "Price per Pack", "codeCharges" => "Code Charges", "coreCharges" => "Core Charges", "currency" => "Currency", "faction" => "Faction", "exp" => "EXP Reward", "see" => "See Also", _ => string.Concat(key.Select((c, i) => i > 0 && char.IsUpper(c) ? " " + c : c.ToString())), }; }