forked from bump-sh/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nav: set the active item on the top navigation
Based on the three collections “help”, “guides” and “product-updates” this commit adds a CSS property `active` on the active category in the top navigation bar. Visually I've simply added an underlined text decoration (but fill free to suggest something else). Part of bump-sh#193
- Loading branch information
Showing
8 changed files
with
25 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<nav-item> | ||
<nav-item<% if @active %> class="active"<% end %>> | ||
<a href="<%= relative_url @link %>"><%= @title %></a> | ||
</nav-item> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
class Shared::Nav::Item < Bridgetown::Component | ||
def initialize(title:, link:) | ||
@title, @link = title, link | ||
def initialize(title:, link:, active: false) | ||
@title, @link, @active = title, link, active | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
class Shared::Navbar < Bridgetown::Component | ||
def initialize(metadata:, resource:) | ||
def initialize(metadata:, resource:, collection: nil) | ||
@metadata, @resource = metadata, resource | ||
@collection = collection || @resource.collection&.label | ||
@site = Bridgetown::Current.site | ||
end | ||
|
||
def current_item?(item) | ||
item.collection.present? && | ||
item.collection == @collection | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
left_links: | ||
- {title: "Documentation", link: "/help"} | ||
- {title: "Product Updates", link: "/product-updates"} | ||
- {title: "Guides", link: "/guides"} | ||
- {title: "Documentation", link: "/help", collection: "help"} | ||
- {title: "Product Updates", link: "/product-updates", collection: "product-updates"} | ||
- {title: "Guides", link: "/guides", collection: "guides"} | ||
right_links: | ||
- {title: "API Reference", link: "https://developers.bump.sh"} | ||
- {title: "Bump.sh", link: "https://bump.sh"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ | |
layout: guides | ||
title: Guides | ||
page_class: guides | ||
paginate: | ||
collection: guides | ||
--- |