Class: Scribo::ContentDrop
- Inherits:
-
ApplicationDrop
- Object
- Liquid::Drop
- ApplicationDrop
- Scribo::ContentDrop
- Defined in:
- app/drops/scribo/content_drop.rb
Overview
Instance Method Summary collapse
- #[](property) ⇒ Object
- #categories ⇒ Object
-
#collection ⇒ Object
FIXME: This breaks when the collection_path is set (jekyllrb.com/docs/collections/#setup).
- #content ⇒ Object
- #date ⇒ Object
- #id ⇒ Object
-
#initialize(object) ⇒ ContentDrop
constructor
A new instance of ContentDrop.
- #layout ⇒ Object
- #liquid_method_missing(method) ⇒ Object
-
#name ⇒ Object
Find out how to merge properties with this drop.
- #next ⇒ Object
- #previous ⇒ Object
- #tags ⇒ Object
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 |
#categories ⇒ Object
59 60 61 |
# File 'app/drops/scribo/content_drop.rb', line 59 def categories Scribo::ArrayDrop.new(@properties&.[]('categories')) end |
#collection ⇒ Object
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 |
#content ⇒ Object
47 48 49 |
# File 'app/drops/scribo/content_drop.rb', line 47 def content Scribo::ContentRenderService.new(@object, @context.registers['controller'], {}).call end |
#date ⇒ Object
16 17 18 |
# File 'app/drops/scribo/content_drop.rb', line 16 def date @object.date end |
#id ⇒ Object
20 21 22 |
# File 'app/drops/scribo/content_drop.rb', line 20 def id @object.full_path end |
#layout ⇒ Object
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 |
#name ⇒ Object
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 |
#next ⇒ Object
39 40 41 |
# File 'app/drops/scribo/content_drop.rb', line 39 def next @object.right_sibling end |
#previous ⇒ Object
43 44 45 |
# File 'app/drops/scribo/content_drop.rb', line 43 def previous @object.left_sibling end |