Sha256: cb6f3538c77f96fdedb8a6d2f720a4ccc6e39eb5afe0ebb1d5ee4f12fd5088a0

Contents?: true

Size: 1.28 KB

Versions: 18

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require 'jekyll'

module CloudCannonJekyll
  # Processes Jekyll configuration to enable the plugin and fix common issues
  class Setup
    def self.processed?(site)
      site.instance_variable_get(:@_cloudcannon_jekyll_processed) == true
    end

    def self.process(site)
      site.instance_variable_set :@_cloudcannon_jekyll_processed, true
    end

    def self.overridden_config(user_config)
      config = Jekyll::Utils.deep_merge_hashes(Jekyll::Configuration::DEFAULTS, user_config)
      config = config.add_default_collections if config.respond_to? :add_default_collections
      config = config.fix_common_issues if config.respond_to? :fix_common_issues
      config = config.add_default_excludes if config.respond_to? :add_default_excludes

      key = Jekyll::VERSION.start_with?('2.') ? 'gems' : 'plugins'

      config[key] = Array(config[key])
      config[key].push('cloudcannon-jekyll') unless config[key].include? 'cloudcannon-jekyll'

      config
    end

    def self.set(site)
      return if processed? site

      if site.respond_to? :config=
        site.config = overridden_config(site.config)
      else # Jekyll pre 3.5
        site.instance_variable_set :@config, overridden_config(site.config)
      end

      process(site)
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
cloudcannon-jekyll-4.1.0 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-4.0.7 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-4.0.6 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-4.0.5 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-4.0.4 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-4.0.3 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-4.0.2 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-4.0.1 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-4.0.0 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-3.2.4 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-3.2.3 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-3.2.2 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-3.2.1 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-3.2.0 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-3.1.0 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-3.0.2 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-3.0.1 lib/cloudcannon-jekyll/setup.rb
cloudcannon-jekyll-3.0.0 lib/cloudcannon-jekyll/setup.rb