Sha256: ea7d4b96671ed73229e25dfe447d1b50366c05a4c509f401c3814ebe58574e79

Contents?: true

Size: 936 Bytes

Versions: 2

Compression:

Stored size: 936 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 do |page|
          page.html? || page.url.end_with?("/")
        end
      end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bunto-3.4.5 lib/bunto/drops/site_drop.rb
bunto-3.2.1 lib/bunto/drops/site_drop.rb