Class: Jekyll::ThemeReader

Inherits:
Reader
  • Object
show all
Defined in:
lib/jekyll/theme_reader.rb

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ ThemeReader

Returns a new instance of ThemeReader.



6
7
8
9
10
# File 'lib/jekyll/theme_reader.rb', line 6

def initialize(site)
  @site = site
  @theme_data_files = Dir[File.join(@site.theme.root,
    site.config["data_dir"], "**", "*.{yaml,yml,json,csv}")]
end

Instance Method Details

#readObject

Read Site data from disk and load it into internal data structures.

Returns nothing.



15
16
17
18
19
20
21
22
23
# File 'lib/jekyll/theme_reader.rb', line 15

def read
  @site.layouts = LayoutReader.new(site).read
  read_directories
  sort_files!
  @site.data = DataReader.new(site).read(site.config["data_dir"])
  read_theme_data
  CollectionReader.new(site).read
  ThemeAssetsReader.new(site).read
end

#read_theme_dataObject

Read data files within a theme gem and add them to internal data

Returns a hash appended with new data



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/jekyll/theme_reader.rb', line 28

def read_theme_data
  if site.theme && site.theme.data_path
    #

    # show contents of "<theme>/_data/" dir being read

    debug_theme_reader
    theme_data = ThemeDataReader.new(site).read(site.config["data_dir"])
    @site.data = Utils.deep_merge_hashes(theme_data, @site.data)
    #

    # show site.data hash contents

    debug_theme_data_reader
  end
end