diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..3e3c2f1 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.1.1 diff --git a/Appraisals b/Appraisals index de38f8d..1d86edc 100644 --- a/Appraisals +++ b/Appraisals @@ -49,3 +49,7 @@ end appraise "jekyll-3.0.3" do gem "jekyll", "3.0.3" end + +appraise "jekyll-3.1.2" do + gem "jekyll", "3.1.2" +end diff --git a/Gemfile b/Gemfile index 7b8c25a..299c383 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'jekyll', '> 1.0.0' +gem 'jekyll', '3.1.2' gem 'appraisal', '1.0.2' gem 'pry' diff --git a/README.md b/README.md index 9e98c26..30ba42c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -# NOTE: Currently does not work with Jekyll 3.1.x -- for a temporary fix, please try using Jekyll 3.0.3 # jekyll-contentblocks Gives you a mechanism in Jekyll to pass content up from pages into their parent @@ -10,7 +9,9 @@ layouts. It's kind of like having Rails' content_for available for Jekyll. Add this line to your Jekyll project's `Gemfile`: ```ruby -gem 'jekyll-contentblocks' + group :jekyll_plugins do + gem 'jekyll-contentblocks' + end ``` Then execute: @@ -18,15 +19,8 @@ Then execute: $ bundle install ``` -Make sure your have a plugin that initializes Bundler: -```ruby -# _plugins/bundler.rb -require "rubygems" -require "bundler/setup" -Bundler.require(:default) -``` - ### Standalone + Execute: ```bash $ gem install jekyll-contentblocks diff --git a/gemfiles/jekyll_3.1.2.gemfile b/gemfiles/jekyll_3.1.2.gemfile new file mode 100644 index 0000000..2d55554 --- /dev/null +++ b/gemfiles/jekyll_3.1.2.gemfile @@ -0,0 +1,12 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "jekyll", "3.1.2" +gem "appraisal", "1.0.2" +gem "pry" +gem "pry-byebug" +gem "rspec", "~> 3.3.0" +gem "nokogiri", "~> 1.6.6.0" + +gemspec :path => "../" diff --git a/lib/jekyll-contentblocks.rb b/lib/jekyll-contentblocks.rb index 555b576..4ae905f 100644 --- a/lib/jekyll-contentblocks.rb +++ b/lib/jekyll-contentblocks.rb @@ -10,9 +10,18 @@ def self.supports_collections? end end -require 'jekyll/content_blocks/convertible' -unless Jekyll.version_less_than?('2.0.0') - require 'jekyll/content_blocks/renderer' +if Jekyll.version_less_than?('3.0.0') + require 'jekyll/content_blocks/convertible' + unless Jekyll.version_less_than?('2.0.0') + require 'jekyll/content_blocks/renderer' + end +else + require 'jekyll/content_blocks/pre_render_hook' + [:documents, :pages, :posts].each do |content_type| + Jekyll::Hooks.register content_type, :pre_render do |doc, payload| + Jekyll::ContentBlocks::PreRenderHook.call(doc, payload) + end + end end require 'jekyll/content_blocks/version' diff --git a/lib/jekyll/content_blocks/pre_render_hook.rb b/lib/jekyll/content_blocks/pre_render_hook.rb new file mode 100644 index 0000000..8ab6303 --- /dev/null +++ b/lib/jekyll/content_blocks/pre_render_hook.rb @@ -0,0 +1,13 @@ +module Jekyll + module ContentBlocks + class PreRenderHook + def self.call(document, payload) + payload['converters'] = document.site.converters.select do |converter| + file_extension = File.extname(document.path) + converter.matches(file_extension) + end + payload['contentblocks'] = {} + end + end + end +end diff --git a/lib/jekyll/content_blocks/version.rb b/lib/jekyll/content_blocks/version.rb index e38142d..9f0f67a 100644 --- a/lib/jekyll/content_blocks/version.rb +++ b/lib/jekyll/content_blocks/version.rb @@ -1,6 +1,6 @@ module Jekyll module ContentBlocks - VERSION = "1.1.0" + VERSION = "1.2.0" end end diff --git a/test/_plugins/bundler.rb b/test/_plugins/bundler.rb deleted file mode 100644 index 0edad96..0000000 --- a/test/_plugins/bundler.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rubygems' -require 'bundler/setup' -Bundler.require(:default) - diff --git a/test/_plugins/require.rb b/test/_plugins/require.rb new file mode 100644 index 0000000..7b6b43a --- /dev/null +++ b/test/_plugins/require.rb @@ -0,0 +1,2 @@ +require 'jekyll-contentblocks' +