docbrown/app/views/layouts/_main_nav.html.erb

30 lines
1.4 KiB
Text

<% navigation_links = Rails.cache.fetch("navigation_links", expires_in: 15.minutes) do
{
default_nav_ids: NavigationLink.default_section.ordered.ids,
other_nav_ids: NavigationLink.other_section.ordered.ids,
}
end %>
<nav class="mb-4 <% unless user_signed_in? %>mt-4<% end %>" data-testid="main-nav" aria-label="<%= community_name %>">
<ul class="default-navigation-links sidebar-navigation-links spec-sidebar-navigation-links">
<%= render partial: "layouts/sidebar_nav_link", collection: NavigationLink.where(id: navigation_links[:default_nav_ids]).ordered, as: :link, cached: true %>
</ul>
</nav>
<%# Reading Note: There's a faulty assumption that all "other_nav_links" are
visible based on the current state (see
ApplicationHelper#display_navigation_link? for details). %>
<% if navigation_links[:other_nav_ids].any? %>
<nav class="mb-4" data-testid="other-nav" aria-labelledby="other-nav-heading-<%= context %>">
<h2 id="other-nav-heading-<%= context %>" class="crayons-subtitle-3 py-2 pl-3">
<%= t("views.main.nav.other") %>
</h2>
<ul class="other-navigation-links sidebar-navigation-links spec-sidebar-navigation-links">
<%= render partial: "layouts/sidebar_nav_link", collection: NavigationLink.where(id: navigation_links[:other_nav_ids]).ordered, as: :link, cached: true %>
</ul>
</nav>
<% end %>
<div class="flex justify-start mb-4">
<%= render partial: "layouts/social_media" %>
</div>