class Lookbook::PageEntity
@api public
Represents a documentation page
def add_section(section)
- Api: - private
def add_section(section) @sections << section @sections.sort_by! { |section| [section.priority, section.label] } end
def data
-
(Hash)
- The resolved data hash
def data return @_data if @_data config_data = fetch_config(:data, {}) @_data ||= config_data.is_a?(Hash) ? Store.new(config_data) : config_data end
def docs_path
-
(String)
- URL path
def docs_path lookbook_page_path(lookup_path) end
def fetch_config(key, fallback = nil, &block)
def fetch_config(key, fallback = nil, &block) value = frontmatter[key] Utils.value_or_fallback(value, fallback, &block) end
def file_contents
def file_contents @_file_contents ||= File.read(file_path) end
def footer?
-
(Boolean)
-
def footer? @_footer ||= fetch_config(:footer, true) end
def frontmatter
def frontmatter @_merged_frontmatter ||= Lookbook.config.page_options.deep_merge(@frontmatter.to_h).deep_symbolize_keys end
def header?
-
(Boolean)
-
def header? @_header ||= fetch_config(:header, true) end
def initialize(file_path)
- Api: - private
def initialize(file_path) @file_path = Pathname(file_path) @base_directories = Engine.page_paths @lookup_path = PathUtils.to_lookup_path(relative_file_path) @frontmatter, @content = FrontmatterExtractor.call(file_contents) @priority_prefixes = true @sections = [] end
def landing?
-
(Boolean)
-
def landing? @_landing ||= fetch_config(:landing, false) end
def markdown?
-
(Boolean)
-
def markdown? @_markdown ||= fetch_config(:markdown) { file_path.to_s.match?(/(.*)\.md\.(.*)$/) } end
def method_missing(method_name, *args, &block)
- Api: - private
def method_missing(method_name, *args, &block) method_name.to_s.end_with?("=") ? super : frontmatter.fetch(method_name, nil) end
def respond_to_missing?(method_name, include_private = false)
- Api: - private
def respond_to_missing?(method_name, include_private = false) frontmatter.key?(method_name) || super end
def search_terms
- Api: - private
def search_terms lookup_path.split("/") << label end
def title
-
(String)
- The title
def title @_title ||= fetch_config(:title, label) end