mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using Markdig;
|
|
using Microsoft.AspNetCore.Components.Routing;
|
|
|
|
namespace Aaru.Server.New.Components.Layout;
|
|
|
|
public partial class NavMenu
|
|
{
|
|
string? _currentUrl;
|
|
string _sidebarMarkup = "";
|
|
|
|
public void Dispose()
|
|
{
|
|
NavigationManager.LocationChanged -= OnLocationChanged;
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
_currentUrl = NavigationManager.ToBaseRelativePath(NavigationManager.Uri);
|
|
NavigationManager.LocationChanged += OnLocationChanged;
|
|
|
|
string? docFolder = Configuration.GetSection("DocumentationFolders").GetValue<string>("Stable");
|
|
|
|
if(docFolder is null) return;
|
|
|
|
string docPath = Path.Combine(HostEnvironment.ContentRootPath, docFolder);
|
|
|
|
if(!Directory.Exists(docPath)) return;
|
|
|
|
string sidebarPath = Path.Combine(docPath, "_sidebar.md");
|
|
|
|
if(!File.Exists(sidebarPath)) return;
|
|
|
|
string sidebarContents = File.ReadAllText(sidebarPath);
|
|
|
|
_sidebarMarkup = Markdown.ToHtml(sidebarContents);
|
|
}
|
|
|
|
void OnLocationChanged(object? sender, LocationChangedEventArgs e)
|
|
{
|
|
_currentUrl = NavigationManager.ToBaseRelativePath(e.Location);
|
|
StateHasChanged();
|
|
}
|
|
} |