class Bridgetown::Builders::DocumentBuilder
Attributes
site[R]
Public Class Methods
new(site, path)
click to toggle source
# File lib/bridgetown-builder/document.rb, line 8 def initialize(site, path) @site = site @path = path @data = HashWithDotAccess::Hash.new end
Public Instance Methods
_add_document_to_site()
click to toggle source
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
# File lib/bridgetown-builder/document.rb, line 19 def _add_document_to_site @collection = (@data[:collection] || :posts).to_s collection = @site.collections[@collection] unless collection collection = Collection.new(@site, @collection) collection.metadata["output"] = true @site.collections[@collection] = collection end doc = Document.new( File.join(collection.directory, @path), site: @site, collection: collection ) doc.send(:merge_defaults) doc.content = @data[:content] @data.delete(:content) if @path.start_with?("/") pathname = Pathname.new(@path) @data[:permalink] = File.join( pathname.dirname, pathname.basename.sub(pathname.extname, "") ) + "/" end doc.merge_data!(@data) doc.send(:read_post_data) collection.docs << doc end
front_matter(data)
click to toggle source
# File lib/bridgetown-builder/document.rb, line 14 def front_matter(data) @data.merge!(data) end
method_missing(key, value = nil)
click to toggle source
rubocop:disable Style/MissingRespondToMissing
Calls superclass method
# File lib/bridgetown-builder/document.rb, line 53 def method_missing(key, value = nil) if respond_to?(key) super else @data[key] = value end end