|
1 | | - |
2 | | -<nav> |
| 1 | +<nav class="primary-nav"> |
| 2 | + <% current_path = resource.respond_to?(:relative_url) ? resource.relative_url : resource.relative_permalink %> |
| 3 | + <% current_path = current_path.sub(%r{/+$}, '') if current_path %> |
| 4 | + <% current_path = '/' if current_path.nil? || current_path.empty? %> |
| 5 | + <% nav_items = [ |
| 6 | + { path: '/', label: 'Home', icon: 'bi-house' }, |
| 7 | + { path: '/about/', label: 'About', icon: 'bi-person' }, |
| 8 | + { path: '/posts/', label: 'Posts', icon: 'bi-pencil-square' }, |
| 9 | + { path: '/wiki/', label: 'Wiki', icon: 'bi-book' }, |
| 10 | + { path: "/hackerspub/", label: "Hackers' Pub", icon: 'bi-globe2' } |
| 11 | + ] %> |
3 | 12 | <ul> |
4 | | - <li><a href="/">/home</a></li> |
5 | | - <li><a href="/about">/about</a></li> |
6 | | - <li><a href="/posts">/posts</a></li> |
7 | | - <li><a href="/wiki">/wiki</a></li> |
8 | | - <li><a href="/hackerspub">/hackerspub</a></li> |
| 13 | + <% nav_items.each do |item| %> |
| 14 | + <% item_path = item[:path].sub(%r{/+$}, '') %> |
| 15 | + <% item_path = '/' if item_path.empty? %> |
| 16 | + <% active = current_path == item_path %> |
| 17 | + <li class="<%= 'is-active' if active %>"> |
| 18 | + <a href="<%= item[:path] %>" aria-label="<%= item[:label] %>" <%= 'aria-current="page"' if active %>> |
| 19 | + <i class="bi <%= item[:icon] %>" aria-hidden="true"></i> |
| 20 | + <span class="nav-label"><%= item[:label] %></span> |
| 21 | + </a> |
| 22 | + </li> |
| 23 | + <% end %> |
9 | 24 | </ul> |
10 | 25 | </nav> |
0 commit comments