Class: Jekyll::ThemeReader
- Inherits:
-
Reader
- Object
- Reader
- Jekyll::ThemeReader
- Defined in:
- lib/jekyll/theme_reader.rb
Instance Method Summary collapse
-
#initialize(site) ⇒ ThemeReader
constructor
A new instance of ThemeReader.
-
#read ⇒ Object
Read Site data from disk and load it into internal data structures.
-
#read_theme_data ⇒ Object
Read data files within a theme gem and add them to internal data.
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
#read ⇒ Object
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_data ⇒ Object
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 40 41 42 |
# 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 while degugging. # Additionally validate if a data file with the same name as the # theme (= theme config or theme config-override) is a Hash. inspect_theme_data theme_data = ThemeDataReader.new(site).read(site.config["data_dir"]) @site.data = Utils.deep_merge_hashes(theme_data, @site.data) # # check if the merged hash is suitable for generating the site. # Also show contents of merged site.data hash while debugging. inspect_merged_hash end end |