# frozen_string_literal: true module C module StorefrontHelper def menu(menu_item_name, depth=1) return unless (menu_item = C::MenuItem.find_by(machine_name: menu_item_name)) return unless menu_item.children.any? content_tag :ul do render partial: 'c/front/application/menu_item', collection: menu_item.children.includes(:page), cached: true, locals: { depth: depth } end end def menu_items_for(menu_item_name, depth=1) return unless (menu_item = C::MenuItem.find_by(machine_name: menu_item_name)) return unless menu_item.children.any? render partial: 'c/front/application/menu_item', collection: menu_item.children.includes(:page), cached: true, locals: { depth: depth } end def category_root_menu content_tag :ul do render partial: 'c/front/application/category_item', collection: C::Category.find_all_by_generation(0) end end def meta_tags safe_join([page_title, meta_description]) if @page_info end def page_title if @page_info.title.blank? if @page_info.fallback_title.blank? content_tag(:title, C.store_name) else content_tag(:title, @page_info.fallback_title) end else content_tag(:title, @page_info.title) end end def meta_description return unless @page_info&.meta_description&.present? tag :meta, name: :description, content: @page_info.meta_description end def slideshow(slideshow_name, klass=nil) return 'No slideshow found' unless (slide_show = C::Slideshow.find_by(machine_name: slideshow_name)) content_tag :div, class: :slideshow do content_tag :ul do render partial: 'c/front/application/slide', collection: slide_show.slides.ordered, cached: true, locals: { klass: klass } end end end def sales_highlights(page) case page when :home render partial: 'c/front/application/sales_highlight', collection: C::SalesHighlight.first(4), cached: true when :store render partial: 'c/front/application/sales_highlight', collection: C::SalesHighlight.first(3), cached: true end end end end