Sha256: 906cce9f4fa0494338564aba9a06adbf76a12d9ef8cd42f03af006fdc467a34c

Contents?: true

Size: 896 Bytes

Versions: 3

Compression:

Stored size: 896 Bytes

Contents

# encoding: UTF-8

module Bunto
  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 posts
        @site_posts ||= @obj.posts.docs.sort { |a, b| b <=> a }
      end

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bunto-3.0.0 lib/bunto/drops/site_drop.rb
bunto-2.0.0.pre lib/bunto/drops/site_drop.rb
bunto-1.0.0 lib/bunto/drops/site_drop.rb