class Bridgetown::Site

Attributes

cache_dir[R]
components_load_paths[R]
config[R]
converters[RW]
data[RW]
dest[R]
file_read_opts[RW]
generated_pages[RW]

@return [Array<Page>]

generators[RW]
includes_load_paths[R]
layouts[RW]

@return [Array<Layout>]

liquid_renderer[R]
pages[RW]

@return [Array<Page>]

plugin_manager[RW]
reader[RW]
regenerator[R]
root_dir[R]
source[R]
static_files[RW]

All files not pages/documents or structured data in the source folder @return [Array<StaticFile>]

time[RW]

Public Class Methods

new(config) click to toggle source

Initialize a new Site.

config - A Hash containing site configuration details.

# File lib/bridgetown-core/site.rb, line 40
def initialize(config)
  self.config = config
  locale

  @plugin_manager  = PluginManager.new(self)
  @cleaner         = Cleaner.new(self)
  @reader          = Reader.new(self)
  @regenerator     = Regenerator.new(self)
  @liquid_renderer = LiquidRenderer.new(self)

  ensure_not_in_dest

  Bridgetown::Current.site = self
  Bridgetown::Hooks.trigger :site, :after_init, self

  reset   # Processable
  setup   # Extensible
end

Public Instance Methods

ensure_not_in_dest() click to toggle source

Check that the destination dir isn't the source dir or a directory parent to the source dir.

# File lib/bridgetown-core/site.rb, line 61
def ensure_not_in_dest
  dest_pathname = Pathname.new(dest)
  Pathname.new(source).ascend do |path|
    if path == dest_pathname
      raise Errors::FatalException,
            "Destination directory cannot be or contain the Source directory."
    end
  end
end
inspect() click to toggle source
# File lib/bridgetown-core/site.rb, line 71
def inspect
  "#<Bridgetown::Site #{metadata.inspect.delete_prefix("{").delete_suffix("}")}>"
end