Skip to content

Commit

Permalink
Run this plugin only for gem-based themes
Browse files Browse the repository at this point in the history
  • Loading branch information
ashmaroli committed Dec 13, 2016
1 parent fbdfc58 commit 1d3a9d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
13 changes: 11 additions & 2 deletions lib/jekyll-data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@
require_relative "jekyll/theme"
require_relative "jekyll/drops/unified_payload_drop"

# replace Jekyll::Reader with a subclass Jekyll::ThemeReader
# replace Jekyll::Reader with a subclass Jekyll::ThemeReader only if the site
# uses a gem-based theme else have this plugin disabled.
Jekyll::Hooks.register :site, :after_init do |site|
site.reader = Jekyll::ThemeReader.new(site)
if site.theme
site.reader = Jekyll::ThemeReader.new(site)
else
Jekyll.logger.abort_with(
"JekyllData:",
"Error! This plugin only works with gem-based jekyll-themes. " \
"Please disable this plugin to proceed."
)
end
end
9 changes: 2 additions & 7 deletions lib/jekyll/theme_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,15 @@ def initialize(site)
#
# Returns nothing.
def read
@site.layouts = LayoutReader.new(site).read
read_directories
sort_files!
@site.data = DataReader.new(site).read(site.config["data_dir"])
super
read_theme_data
CollectionReader.new(site).read
ThemeAssetsReader.new(site).read
end

# Read data files within a theme gem and add them to internal data
#
# Returns a hash appended with new data
def read_theme_data
if site.theme && site.theme.data_path
if 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
Expand Down

0 comments on commit 1d3a9d4

Please sign in to comment.