lib/lookbook/page.rb in lookbook-1.0.0.beta.7 vs lib/lookbook/page.rb in lookbook-1.0.0.beta.8

- old
+ new

@@ -1,8 +1,7 @@ module Lookbook class Page < Entity - FRONTMATTER_FIELDS = [ :id, :label, :title, :hidden, @@ -74,11 +73,11 @@ end def type :page end - + def id options[:id] end def position @@ -123,11 +122,11 @@ file_path: @pathname.to_s, line_number: line_number_match ? line_number_match[1] : false })) end @options = Lookbook.config.page_options.deep_merge(frontmatter).with_indifferent_access - @options[:id] = @options[:id] ? generate_id(@options[:id]) : generate_id(lookup_path) + @options[:id] = generate_id(@options[:id] || lookup_path) @options[:label] ||= name.titleize @options[:title] ||= @options[:label] @options[:hidden] ||= false @options[:landing] ||= false @options[:position] = @options[:position] ? @options[:position].to_i : get_position_prefix(path_name) @@ -157,11 +156,11 @@ def any? all.any? end def all - pages, sections = + pages, sections = Array(page_paths).flat_map do |dir| Dir["#{dir}/**/*.html.*", "#{dir}/**/*.md.*"].sort.map do |path| create(path, dir) end end.partition { |page| page.type == :page } @@ -170,10 +169,10 @@ .uniq { |page| page.path } .sort_by { |page| [page.position, page.label] } page_dict = sorted_pages.index_by(&:path) sorted_sections = sections.sort_by { |section| [section.position, section.label] } - + sorted_sections.each do |section| page_dict[section.path].sections << section end PageCollection.new(sorted_pages)