Sha256: b6c93c01b934fb4dc911e0a42c7231f6e753fe7de8b9dec3a871c1126c0410e2

Contents?: true

Size: 1.16 KB

Versions: 10

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

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

    # Write static files, pages, and documents to the destination folder.
    #
    # @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 all content objects while looping through {#pages},
    #   {#static_files_to_write}, {#docs_to_write}, {#resources_to_write}.
    #
    # @yieldparam item [Document, Page, StaticFile]
    #
    # @return [void]
    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

    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
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bridgetown-core-0.21.5 lib/bridgetown-core/concerns/site/writable.rb
bridgetown-core-0.21.4 lib/bridgetown-core/concerns/site/writable.rb
bridgetown-core-0.21.3 lib/bridgetown-core/concerns/site/writable.rb
bridgetown-core-0.21.2 lib/bridgetown-core/concerns/site/writable.rb
bridgetown-core-0.21.1 lib/bridgetown-core/concerns/site/writable.rb
bridgetown-core-0.21.0 lib/bridgetown-core/concerns/site/writable.rb
bridgetown-core-0.21.0.beta4 lib/bridgetown-core/concerns/site/writable.rb
bridgetown-core-0.21.0.beta3 lib/bridgetown-core/concerns/site/writable.rb
bridgetown-core-0.21.0.beta2 lib/bridgetown-core/concerns/site/writable.rb
bridgetown-core-0.21.0.beta1 lib/bridgetown-core/concerns/site/writable.rb