File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments