Sha256: 7275eec41ad3722f13b3aed8ae74fa1090462012c086d6afba76db916c4fbb4c
Contents?: true
Size: 566 Bytes
Versions: 2
Compression:
Stored size: 566 Bytes
Contents
# frozen_string_literal: true module PandaCms class PageMenuComponent < ViewComponent::Base attr_accessor :menu_item attr_accessor :children def initialize(page:, start_depth:) start_page = if page.depth == start_depth page else page.ancestors.find { |anc| anc.depth == start_depth } end menu = PandaCms::Menu.find_by(kind: "auto", start_page: start_page) @menu_item = menu.menu_items.order(:lft)&.first unless menu.nil? @children = menu_item&.descendants unless menu_item.nil? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
panda_cms-0.5.9 | app/components/panda_cms/page_menu_component.rb |
panda_cms-0.5.8 | app/components/panda_cms/page_menu_component.rb |