Class: Locomotive::Steam::Adapters::Filesystem::YAMLLoaders::Site

Inherits:
Object
  • Object
show all
Includes:
Locomotive::Steam::Adapters::Filesystem::YAMLLoader
Defined in:
lib/locomotive/steam/adapters/filesystem/yaml_loaders/site.rb

Instance Attribute Summary

Attributes included from Locomotive::Steam::Adapters::Filesystem::YAMLLoader

#env, #site_path

Instance Method Summary collapse

Methods included from Locomotive::Steam::Adapters::Filesystem::YAMLLoader

#_load, #initialize, #safe_json_file_load, #safe_json_load, #safe_yaml_load, #template_extensions

Instance Method Details

#load(scope) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/locomotive/steam/adapters/filesystem/yaml_loaders/site.rb', line 11

def load(scope)
  attributes = _load(File.join(site_path, 'config', 'site.yml'))

  # NOTE: we can't use the locales and default_local methods here
  # since the loading is not done yet.
  locales, default_locale = attributes[:locales], attributes[:locales].first

  (attributes[:domains] ||= []).concat(%w(0.0.0.0 localhost))

  attributes[:picture] = File.expand_path(File.join(site_path, 'icon.png'))

  attributes[:metafields_schema] = load_metafields_schema

  attributes.merge!(load_from_env)

  # special treatment for the sections_content which may or may not be translated
  sections_content = attributes[:sections_content]
  if sections_content.present? && locales.size == 1 && sections_content[default_locale].nil?
    attributes[:sections_content] = { default_locale => sections_content }
  end

  [attributes]
end