module Bridgetown::Site::Writable

Public Instance Methods

cleanup() click to toggle source

Remove orphaned files and empty directories in destination.

@return [void]

# File lib/bridgetown-core/concerns/site/writable.rb, line 8
def cleanup
  @cleaner.cleanup!
end
each_site_file() { |item| ... } click to toggle source

Yields all content objects while looping through {#pages},

{#static_files_to_write}, {#docs_to_write}, {#resources_to_write}.

@yieldparam item [Document, Page, StaticFile]

@return [void]

# File lib/bridgetown-core/concerns/site/writable.rb, line 29
def each_site_file
  %w(pages static_files_to_write docs_to_write resources_to_write).each do |type|
    send(type).each do |item|
      yield item
    end
  end
end
resources_cache_manifest() click to toggle source
# File lib/bridgetown-core/concerns/site/writable.rb, line 37
def resources_cache_manifest
  resources.each_with_object({}) do |resource, hsh|
    next if resource.relative_url == ""

    hsh[resource.relative_url] = {
      id: resource.model.id,
    }
  end
end
write() click to toggle source

Write static files, pages, and documents to the destination folder.

@return [void]

# File lib/bridgetown-core/concerns/site/writable.rb, line 15
def write
  each_site_file do |item|
    item.write(dest) if regenerator.regenerate?(item)
  end
  regenerator.write_metadata
  Bridgetown::Hooks.trigger :site, :post_write, self
end