Sha256: e2767fc726290b598ac53e5b6f53c6f760f73f1b4cc1c7f7ae270920ae5c2356

Contents?: true

Size: 1.31 KB

Versions: 7

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require_dependency 'scribo/application_drop'
require 'pry'
module Scribo
  # See https://jekyllrb.com/docs/variables/#site-variables
  class SiteDrop < ApplicationDrop
    delegate :collections, to: :@object

    def initialize(object)
      @object = object
      @properties = object.properties
    end

    def time
      Time.current
    end

    def pages
      @object.contents.pages.to_a
    end

    def posts
      @object.contents.posts.sort_by { |p| - p.date.to_i }.to_a
    end

    # TODO
    def related_posts
      []
    end

    def static_files
      @object.contents.assets.to_a
    end

    def html_pages
      @object.contents.html_pages.to_a
    end

    def html_files
      @object.contents.html_files.to_a
    end

    def data
      Scribo::DataDrop.new(@object)
    end

    # TODO
    def documents
      []
    end

    # TODO
    def categories
      []
    end

    # TODO
    def tags
      []
    end

    def url
      @properties['url']
    end

    def current_locale
      I18n.locale.to_s
    end

    def locale
      @properties['locale']
    end

    def liquid_method_missing(method)
      if collections.include?(method)
        @object.contents.in_folder("_#{method}").order(:created_at).to_a
      else
        @properties[method.to_s]
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
scribo-1.0.44 app/drops/scribo/site_drop.rb
scribo-1.0.43 app/drops/scribo/site_drop.rb
scribo-1.0.42 app/drops/scribo/site_drop.rb
scribo-1.0.41 app/drops/scribo/site_drop.rb
scribo-1.0.40 app/drops/scribo/site_drop.rb
scribo-1.0.39 app/drops/scribo/site_drop.rb
scribo-1.0.38 app/drops/scribo/site_drop.rb