Skip to content

Commit

Permalink
fix: checking for undefined menu items menu priority when sorting nav…
Browse files Browse the repository at this point in the history
…igation
  • Loading branch information
Benj0s committed Jan 23, 2025
1 parent 154216b commit a7b2c77
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions components/cms-modern/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,11 @@ const Navigation = ({ pages, style }: NavigationProps) => {
<nav className="navigation" style={style}>
<ul className="navigation__list">
{pages
.sort((p1, p2) =>
p1.content?.menu.priority > p2.content?.menu.priority
? 1
: p1.content?.menu.priority < p2.content?.menu.priority
? -1
: 0,
)
.sort((p1, p2) => {
const menu1Priority = p1.content?.menu?.priority || 0;
const menu2Priority = p2.content?.menu?.priority || 0;
return menu1Priority > menu2Priority ? 1 : menu1Priority < menu2Priority ? -1 : 0;
})
.map(({ title, href = '', children = [], content, category }, index) => {
return (
<li
Expand Down

0 comments on commit a7b2c77

Please sign in to comment.