Class: Scribo::ContentDrop

Inherits:
ApplicationDrop show all
Defined in:
app/drops/scribo/content_drop.rb

Overview

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ ContentDrop

Returns a new instance of ContentDrop.



11
12
13
14
# File 'app/drops/scribo/content_drop.rb', line 11

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

Instance Method Details

#[](property) ⇒ Object



51
52
53
54
55
56
57
# File 'app/drops/scribo/content_drop.rb', line 51

def [](property)
  if respond_to?(property)
    send(property)
  elsif @properties.present?
    @properties[property]
  end
end

#categoriesObject



59
60
61
# File 'app/drops/scribo/content_drop.rb', line 59

def categories
  Scribo::ArrayDrop.new(@properties&.[]('categories'))
end

#collectionObject

FIXME: This breaks when the collection_path is set (jekyllrb.com/docs/collections/#setup)



25
26
27
28
# File 'app/drops/scribo/content_drop.rb', line 25

def collection
  base_dir = @object.dir.split('/').first.gsub('_', '')
  base_dir if @object.site.collections.include?(base_dir)
end

#contentObject



47
48
49
# File 'app/drops/scribo/content_drop.rb', line 47

def content
  Scribo::ContentRenderService.new(@object, @context.registers['controller'], {}).call
end

#dateObject



16
17
18
# File 'app/drops/scribo/content_drop.rb', line 16

def date
  @object.date
end

#idObject



20
21
22
# File 'app/drops/scribo/content_drop.rb', line 20

def id
  @object.full_path
end

#layoutObject



35
36
37
# File 'app/drops/scribo/content_drop.rb', line 35

def layout
  @object.layout_name
end

#liquid_method_missing(method) ⇒ Object



67
68
69
70
71
# File 'app/drops/scribo/content_drop.rb', line 67

def liquid_method_missing(method)
  return nil unless @properties

  @properties[method.to_s]
end

#nameObject

Find out how to merge properties with this drop



31
32
33
# File 'app/drops/scribo/content_drop.rb', line 31

def name
  @properties&.[]('name') || @object.path
end

#nextObject



39
40
41
# File 'app/drops/scribo/content_drop.rb', line 39

def next
  @object.right_sibling
end

#previousObject



43
44
45
# File 'app/drops/scribo/content_drop.rb', line 43

def previous
  @object.left_sibling
end

#tagsObject



63
64
65
# File 'app/drops/scribo/content_drop.rb', line 63

def tags
  Scribo::ArrayDrop.new(@properties&.[]('tags'))
end