More notes and added store precons

This commit is contained in:
6d486f49
2026-06-25 09:45:21 -04:00
parent 89bd1ca1f9
commit 68872f0dac
96 changed files with 61430 additions and 278 deletions
+41 -125
View File
@@ -39,10 +39,7 @@
<div class="doc-card" @onclick="() => SelectDoc(doc)">
<div class="doc-card-category">@doc.Category</div>
<h3 class="doc-card-title">@doc.Title</h3>
@{
var desc = GetDescription(doc);
}
@if (desc != null)
@if (GetField(doc, "description") is { Length: > 0 } desc)
{
<p class="doc-card-desc">@desc</p>
}
@@ -67,37 +64,34 @@
<header class="doc-header">
<div class="doc-meta">@selectedDoc.Category</div>
<h1>@selectedDoc.Title</h1>
@{
var desc = GetDescription(selectedDoc);
}
@if (desc != null)
{
<p class="doc-description">@desc</p>
}
</header>
@if (!string.IsNullOrWhiteSpace(selectedDoc.Content))
{
<div class="doc-body">
@((MarkupString)FormatContent(selectedDoc.Content))
</div>
}
<div class="doc-fields">
@{
var fm = selectedDoc.Frontmatter;
}
@if (HasExtraFrontmatter(selectedDoc))
{
<div class="doc-extra">
<h3>Details</h3>
<div class="doc-frontmatter">
@foreach (var kvp in selectedDoc.Frontmatter.Where(kvp => kvp.Key != "category" && kvp.Key != "description"))
@foreach (var kvp in fm)
{
var key = kvp.Key;
var val = kvp.Value;
if (string.IsNullOrWhiteSpace(val)) continue;
<div class="doc-field">
<span class="doc-field-key">@GetLabel(key)</span>
@if (key == "description")
{
<div class="fm-item">
<span class="fm-key">@kvp.Key</span>
<span class="fm-value">@kvp.Value</span>
</div>
<p class="doc-field-desc">@val</p>
}
else
{
<span class="doc-field-val">@val</span>
}
</div>
</div>
}
}
</div>
</article>
}
</main>
@@ -122,8 +116,7 @@
.Where(d => (selectedCategory == null || d.Category == selectedCategory) &&
(string.IsNullOrWhiteSpace(searchQuery) ||
d.Title.Contains(searchQuery, StringComparison.OrdinalIgnoreCase) ||
(GetDescription(d)?.Contains(searchQuery, StringComparison.OrdinalIgnoreCase) ?? false) ||
d.Content.Contains(searchQuery, StringComparison.OrdinalIgnoreCase)));
(GetField(d, "description")?.Contains(searchQuery, StringComparison.OrdinalIgnoreCase) ?? false)));
private void SelectCategory(string? category)
{
@@ -136,102 +129,25 @@
selectedDoc = doc;
}
private static string? GetDescription(DocData doc)
private static string? GetField(DocData doc, string key)
{
return doc.Frontmatter.TryGetValue("description", out var desc) && !string.IsNullOrWhiteSpace(desc) ? desc : null;
return doc.Frontmatter.TryGetValue(key, out var val) && !string.IsNullOrWhiteSpace(val) ? val : null;
}
private static bool HasExtraFrontmatter(DocData doc)
private static string GetLabel(string key) => key switch
{
var count = doc.Frontmatter.Count;
if (count == 0) return false;
if (count == 1 && doc.Frontmatter.ContainsKey("category")) return false;
if (count == 2 && doc.Frontmatter.ContainsKey("category") && doc.Frontmatter.ContainsKey("description")) return false;
return doc.Frontmatter.Any(kvp => kvp.Key != "category" && kvp.Key != "description");
}
private string FormatContent(string content)
{
if (string.IsNullOrWhiteSpace(content)) return "";
var lines = content.Replace("\r\n", "\n").Split('\n');
var html = new System.Text.StringBuilder();
var inList = false;
foreach (var rawLine in lines)
{
var line = rawLine.TrimEnd();
if (string.IsNullOrWhiteSpace(line))
{
if (inList) { html.AppendLine("</ul>"); inList = false; }
continue;
}
if (line.StartsWith("- "))
{
var item = line[2..].Trim();
if (item.Length > 0)
{
if (!inList) { html.AppendLine("<ul class=\"doc-list-items\">"); inList = true; }
html.Append("<li>");
html.Append(EncodeInline(item));
html.AppendLine("</li>");
}
continue;
}
if (inList) { html.AppendLine("</ul>"); inList = false; }
if (line.EndsWith(":") || line.Contains(":\n"))
{
var trimmed = line.TrimEnd(':');
if (trimmed.Length > 0)
{
html.Append("<p class=\"doc-label\">");
html.Append(System.Web.HttpUtility.HtmlEncode(trimmed));
html.AppendLine("</p>");
}
}
else
{
html.Append("<p>");
html.Append(EncodeInline(line));
html.AppendLine("</p>");
}
}
if (inList) html.AppendLine("</ul>");
return html.ToString();
}
private string EncodeInline(string text)
{
var result = new System.Text.StringBuilder();
var remaining = text;
while (remaining.Length > 0)
{
var boldIdx = remaining.IndexOf("**", StringComparison.Ordinal);
if (boldIdx >= 0)
{
var endBold = remaining.IndexOf("**", boldIdx + 2, StringComparison.Ordinal);
if (endBold >= 0)
{
result.Append(System.Web.HttpUtility.HtmlEncode(remaining[..boldIdx]));
result.Append("<strong>");
result.Append(System.Web.HttpUtility.HtmlEncode(remaining[(boldIdx + 2)..endBold]));
result.Append("</strong>");
remaining = remaining[(endBold + 2)..];
continue;
}
}
result.Append(System.Web.HttpUtility.HtmlEncode(remaining));
break;
}
return result.ToString();
}
"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())),
};
}