...
This commit is contained in:
+63
-1
@@ -26,6 +26,7 @@ CopyImages(solutionDir, Path.GetFullPath(Path.Combine(solutionDir, "Web", "wwwro
|
||||
var indexJson = BuildIndex(entries);
|
||||
File.WriteAllText(Path.Combine(Path.GetDirectoryName(dstDir)!, "notes-index.json"), indexJson);
|
||||
GenerateMap(srcDir, Path.GetFullPath(Path.Combine(solutionDir, "Web", "wwwroot", "docs")));
|
||||
GenerateOverviewPage(solutionDir);
|
||||
|
||||
Console.WriteLine("Done.");
|
||||
return 0;
|
||||
@@ -137,6 +138,67 @@ static string BuildIndex(List<object> entries)
|
||||
return JsonSerializer.Serialize(index, new JsonSerializerOptions { WriteIndented = true });
|
||||
}
|
||||
|
||||
static void GenerateOverviewPage(string solutionDir)
|
||||
{
|
||||
var pagesDir = Path.GetFullPath(Path.Combine(solutionDir, "Web", "Pages"));
|
||||
Directory.CreateDirectory(pagesDir);
|
||||
|
||||
var component = """
|
||||
@page "/overview"
|
||||
@inject DocsService DocsService
|
||||
|
||||
<PageTitle>Overview</PageTitle>
|
||||
|
||||
@if (loading)
|
||||
{
|
||||
<div class="d-flex justify-content-center py-5">
|
||||
<div class="spinner-border text-success" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else if (doc == null)
|
||||
{
|
||||
<h1>Overview Not Found</h1>
|
||||
<p>The overview document could not be found.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="section-header d-flex align-items-center mb-4">
|
||||
<h1 class="mb-0">@doc.Title</h1>
|
||||
<div class="ms-3 flex-grow-1 border-bottom opacity-25"></div>
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(doc.FrontmatterHtml))
|
||||
{
|
||||
<details class="frontmatter-section" open>
|
||||
<summary>Frontmatter</summary>
|
||||
@((MarkupString)doc.FrontmatterHtml)
|
||||
</details>
|
||||
}
|
||||
|
||||
<div class="markdown-body overview-markdown">
|
||||
@((MarkupString)doc.HtmlContent)
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
private NoteDocument? doc;
|
||||
private bool loading = true;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
doc = await DocsService.GetNoteAsync("overview");
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
var overviewPagePath = Path.Combine(pagesDir, "Overview.razor");
|
||||
File.WriteAllText(overviewPagePath, component);
|
||||
Console.WriteLine($"Overview page written to: {overviewPagePath}");
|
||||
}
|
||||
|
||||
static void GenerateMap(string srcDir, string dstDir)
|
||||
{
|
||||
var terrainColors = new Dictionary<string, string>
|
||||
@@ -314,4 +376,4 @@ internal class RegionData
|
||||
public int Y { get; set; }
|
||||
public List<string> Connections { get; set; } = new();
|
||||
public List<string> Landmarks { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user