Sha256: d96a6001b07abbab266e0090df83ce6fd255bf23ad4917b47d39a8bc556d92df

Contents?: true

Size: 1.08 KB

Versions: 9

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Jekyll
  module Drops
    class SiteDrop < Drop
      extend Forwardable

      mutable false

      def_delegator  :@obj, :site_data, :data
      def_delegators :@obj, :time, :pages, :static_files, :documents,
                            :tags, :categories

      def [](key)
        if @obj.collections.key?(key) && key != "posts"
          @obj.collections[key].docs
        else
          super(key)
        end
      end

      def key?(key)
        (@obj.collections.key?(key) && key != "posts") || super
      end

      def posts
        @site_posts ||= @obj.posts.docs.sort { |a, b| b <=> a }
      end

      def html_pages
        @site_html_pages ||= @obj.pages.select do |page|
          page.html? || page.url.end_with?("/")
        end
      end

      def collections
        @site_collections ||= @obj.collections.values.sort_by(&:label).map(&:to_liquid)
      end

      # return nil for `{{ site.config }}` even if --config was passed via CLI
      def config; end

      private
      def_delegator :@obj, :config, :fallback_data
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
jekyll-3.6.3 lib/jekyll/drops/site_drop.rb
jekyll-3.7.4 lib/jekyll/drops/site_drop.rb
jekyll-3.7.3 lib/jekyll/drops/site_drop.rb
jekyll-3.7.2 lib/jekyll/drops/site_drop.rb
jekyll-3.7.0 lib/jekyll/drops/site_drop.rb
jekyll-docs-3.6.2 lib/jekyll/drops/site_drop.rb
jekyll-docs-3.6.1 lib/jekyll/drops/site_drop.rb
jekyll-3.6.2 lib/jekyll/drops/site_drop.rb
jekyll-3.6.1 lib/jekyll/drops/site_drop.rb