From 1ea36729e1d4144d93ebd4d36b10a47597602e74 Mon Sep 17 00:00:00 2001 From: Brett McHargue Date: Thu, 1 Feb 2024 11:41:48 +0000 Subject: [PATCH] Broke navigation menu --- app/controllers/application_controller.rb | 4 ++-- app/controllers/pages_controller.rb | 18 ++++++++++-------- app/helpers/application_helper.rb | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5ee30e29..bab139d9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base include Pundit::Authorization - helper_method :group + helper_method :menu_item def check render json: { status: "OK", version: release_version, sha: ENV["SHA"], environment: Rails.env }, status: :ok @@ -26,7 +26,7 @@ def content @content ||= Rails.configuration.content end - def group + def menu_item :home end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 75a55991..ace86545 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -7,6 +7,10 @@ def show; end private + def menu_item + cms_path_array.first + end + def page_params params.permit(:cms_path) end @@ -39,13 +43,11 @@ def page_name end def load_page(lookup_page: page_name) - if lookup_page.present? - page_attributes = content.send(lookup_page) - @page = if page_attributes - Page.new(page_attributes) - else - PageDelegator.new(ContentPage.find_by_slug(page_name)) - end - end + page_attributes = content.send(lookup_page || :home) + @page = if page_attributes + Page.new(page_attributes) + else + PageDelegator.new(ContentPage.find_by_slug(page_name)) + end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7008e42c..1484104a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -29,7 +29,7 @@ def navigation header.with_navigation_item( text: item[:menu_title], href: ["/", item[:parent_path], item[:slug]].join("/").squeeze("/"), - active: key == group&.to_sym, + active: key == menu_item&.to_sym, classes: %w[dfe-header__navigation-item], ) end