class Lookbook::PageCollection
def pages_from_paths(file_paths)
def pages_from_paths(file_paths) entities = file_paths.map { |path| PageCollection.entity(path) } pages, sections = entities.partition { |page| page.type == :page } page_dict = pages.index_by(&:lookup_path) sections.each do |section| parent = page_dict[section.lookup_path] section.parent = parent parent.add_section(section) end pages end