Sha256: 744be49f5fc9e3983bb36edb2712e222103b3e2769e1205b67f81b60e7560ff4

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Bridgetown
  module Site::Writable
    # Remove orphaned files and empty directories in destination.
    #
    # @return [void]
    def cleanup
      @cleaner.cleanup!
    end

    # Write static files, pages, and posts.
    #
    # @return [void]
    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

    # Yields the pages from {#pages}, {#static_files}, and {#docs_to_write}.
    #
    # @yieldparam item [Document, Page, StaticFile] Yields a
    # {#Bridgetown::Page}, {#Bridgetown::StaticFile}, or
    # {#Bridgetown::Document} object.
    #
    # @return [void]
    #
    # @see #pages
    # @see #static_files
    # @see #docs_to_write
    # @see Page
    # @see StaticFile
    # @see Document
    def each_site_file
      %w(pages static_files docs_to_write).each do |type|
        send(type).each do |item|
          yield item
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bridgetown-core-0.17.1 lib/bridgetown-core/concerns/site/writable.rb
bridgetown-core-0.17.0 lib/bridgetown-core/concerns/site/writable.rb
bridgetown-core-0.16.0 lib/bridgetown-core/concerns/site/writable.rb
bridgetown-core-0.16.0.beta2 lib/bridgetown-core/concerns/site/writable.rb
bridgetown-core-0.16.0.beta1 lib/bridgetown-core/concerns/site/writable.rb