Skip to content

Commit

Permalink
Merge pull request #89 from AaronSadlerUK/feature/menu-item-parent
Browse files Browse the repository at this point in the history
Added a parent property to umbnavitem
  • Loading branch information
AaronSadlerUK authored May 30, 2024
2 parents 4bab6b5 + 50a1ebc commit 0974abc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/UmbNav.Core/Models/UmbNavItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public class UmbNavItem
[JsonProperty("children")]
public IEnumerable<UmbNavItem> Children { get; set; }

[JsonIgnore]
public UmbNavItem Parent { get; set; }

[JsonIgnore]
public IPublishedContent Content { get; set; }

Expand Down
5 changes: 5 additions & 0 deletions src/UmbNav.Core/Services/UmbNavMenuBuilderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public IEnumerable<UmbNavItem> BuildMenu(IEnumerable<UmbNavItem> items, int leve
var children = new List<UmbNavItem>();
if (item.Children != null && item.Children.Any())
{
foreach (var child in item.Children)
{
child.Parent = item;
}

children = item.Children.ToList();
}

Expand Down

0 comments on commit 0974abc

Please sign in to comment.