Class: Site

Inherits:
Object
  • Object
show all
Defined in:
lib/mr_hyde/jekyll_ext/site.rb

Instance Method Summary collapse

Instance Method Details

#in_source_dir(*paths) ⇒ Object

First try to find the file referenced in the jekyll folder (by default _config.yml), in case is not there, then try to find it in the mrhyde folder (by default _config.yml)



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mr_hyde/jekyll_ext/site.rb', line 11

def in_source_dir(*paths)
  file_path = paths.reduce(source) do |base, path|
    Jekyll.sanitized_path(base, path)
  end
  unless File.exist? file_path
    file_path = paths.reduce(MrHyde.source) do |base, path|
      Jekyll.sanitized_path(base, path)
    end
  end
  file_path
end

#pristine_site_payloadObject



7
# File 'lib/mr_hyde/jekyll_ext/site.rb', line 7

alias_method :pristine_site_payload, :site_payload

#site_payloadObject

This patching ensures that if the site is the main, then adds to the payload the sites value containing the sites payloads info within sources sites.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/mr_hyde/jekyll_ext/site.rb', line 26

def site_payload
  payload = pristine_site_payload

  if source == MrHyde.main_site
    site_names = MrHyde.built_list

    unless site_names.empty?
      sites_payload = site_names.map do |site_name|
        opts = MrHyde.site_configuration(site_name)
        opts = Jekyll.configuration(opts)
        site = Site.new opts

        Utils.deep_merge_hashes site.site_payload['site'], { 'name' => site_name }
      end
      payload['site'] = Utils.deep_merge_hashes(payload['site'], { 'sites' => sites_payload })
    end
  end

  payload
end