Sha256: 69878551293d90a13dfe01a948be972374c74c435a6f9c7f3c457a345c146c64
Contents?: true
Size: 607 Bytes
Versions: 32
Compression:
Stored size: 607 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 def render? @menu_item end end end
Version data entries
32 entries across 32 versions & 1 rubygems