2023-05-03 01:59:10 +02:00
|
|
|
% my $categories = stash 'categories';
|
|
|
|
% my $current_category_slug = stash 'current_category_slug';
|
|
|
|
<nav class="desktop"><%
|
|
|
|
my @sorted_categories = sort {
|
|
|
|
$categories->{$a}{priority} <=> $categories->{$b}{priority}
|
|
|
|
} keys %$categories;
|
|
|
|
my $target_category_slug = $current_category_slug;
|
|
|
|
my $current_category = $categories->{$current_category_slug};
|
|
|
|
if (defined $current_category) {
|
|
|
|
my $possible_parent = $current_category->{parent};
|
|
|
|
if (defined $possible_parent && defined $categories->{$possible_parent}) {
|
|
|
|
$target_category_slug = $categories->{$possible_parent}{slug};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for my $category_key (@sorted_categories) {
|
|
|
|
my $category = $categories->{$category_key};
|
|
|
|
if (defined $category->{parent}) {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
my $selected = defined($target_category_slug) && $category->{slug} eq $target_category_slug;
|
|
|
|
%><a class="<%=$selected && "selected" %>" href="<%= '/'.$category->{slug} %>"><%==$category->{menu_text}%></a><%
|
|
|
|
}
|
2023-09-08 01:43:38 +02:00
|
|
|
%><a href="#" class="search-icon"><img alt="" src="/img/search.svg"/></a></nav>
|
2023-05-03 01:59:10 +02:00
|
|
|
|