-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Determine active page by considering parent too
Currently the logic that works out which page to highlight as ‘active’ in the top navigation is quite naïve (only compares URLs directly). This commit makes it a bit smarter so that a page can define its `parent`, then the navigation will highlight the matching ‘parent’ navigation item. Adapted from: alphagov/govuk-developer-docs@7e5ac51
- Loading branch information
Showing
3 changed files
with
25 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module GovukTechDocs | ||
class NavigationHelpers | ||
|
||
def initialize(current_page) | ||
@current_page = current_page | ||
end | ||
|
||
def from_path?(page_path) | ||
("/" + @current_page.path) == page_path || @current_page.data.parent == page_path | ||
end | ||
|
||
private | ||
|
||
attr_reader :config, :current_page | ||
|
||
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