Skip to content

Commit 61d3865

Browse files
committed
Fixed navigation not showing parent content
1 parent fd0499b commit 61d3865

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

Components/Pages/GuidePage.razor

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,18 @@ else
227227

228228
var (doc, _) = await Store.TryGetByRequestAsync(slug, host);
229229
_doc = doc;
230+
var currentSlug = (_doc?.Slug ?? (slug ?? "")).Trim('/');
230231

231-
var normalized = (slug ?? "").Trim('/');
232-
_navRootSlug = Store.GetNavRootSlug(normalized);
233-
_nav = Store.BuildNavTree(_navRootSlug, normalized);
232+
233+
_navRootSlug = Store.GetNavRootSlug(currentSlug);
234+
_nav = Store.BuildNavTree(_navRootSlug, currentSlug);
234235

235236
_notFound = doc is null;
236237

237238
// canonical works even for not-found
238239
_canonical = _notFound
239-
? BuildCanonical(ctx, slug ?? "")
240-
: BuildCanonical(ctx, doc!.Slug, doc.Canonical);
240+
? BuildCanonical(ctx, slug ?? "")
241+
: BuildCanonical(ctx, doc!.Slug, doc.Canonical);
241242

242243
_pageTitleFull = $"{Title} | {Brand.SiteName}";
243244

Services/MarkdownStore.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,23 @@ public string GetNavRootSlug(string? currentSlug)
7575
{
7676
var slug = (currentSlug ?? "").Trim('/');
7777

78+
string? highestWithIndex = null;
79+
7880
while (true)
7981
{
8082
if (HasIndex(slug))
81-
return slug;
83+
highestWithIndex = slug;
8284

8385
var lastSlash = slug.LastIndexOf('/');
8486
if (lastSlash < 0) break;
8587

8688
slug = slug[..lastSlash];
8789
}
8890

89-
return HasIndex("") ? "" : "";
91+
if (highestWithIndex is null)
92+
return HasIndex("") ? "" : "";
93+
94+
return highestWithIndex;
9095
}
9196

9297
private bool HasIndex(string slug)

0 commit comments

Comments
 (0)