Class: Jekyll::Drops::SiteDrop

Inherits:
Drop
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/jekyll/drops/site_drop.rb

Constant Summary

Constants inherited from Drop

Drop::NON_CONTENT_METHODS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Drop

#[]=, #content_methods, #each, #each_key, #fetch, #hash_for_json, #initialize, #inspect, #keys, #merge, #merge!, mutable, mutable?, #to_h, #to_json

Constructor Details

This class inherits a constructor from Jekyll::Drops::Drop

Instance Attribute Details

#current_document=(value) ⇒ Object (writeonly)

Sets the attribute current_document

Parameters:

  • value

    the value to set the attribute current_document to.



50
51
52
# File 'lib/jekyll/drops/site_drop.rb', line 50

def current_document=(value)
  @current_document = value
end

Instance Method Details

#[](key) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/jekyll/drops/site_drop.rb', line 16

def [](key)
  if @obj.collections.key?(key) && key != "posts"
    @obj.collections[key].docs
  else
    super(key)
  end
end

#collectionsObject



38
39
40
# File 'lib/jekyll/drops/site_drop.rb', line 38

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

#configObject

return nil for ‘site.config }` even if –config was passed via CLI



53
# File 'lib/jekyll/drops/site_drop.rb', line 53

def config; end

#html_pagesObject



32
33
34
35
36
# File 'lib/jekyll/drops/site_drop.rb', line 32

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

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/jekyll/drops/site_drop.rb', line 24

def key?(key)
  (@obj.collections.key?(key) && key != "posts") || super
end

#postsObject



28
29
30
# File 'lib/jekyll/drops/site_drop.rb', line 28

def posts
  @site_posts ||= @obj.posts.docs.sort { |a, b| b <=> a }
end

‘site.related_posts }` is how posts can get posts related to them, either through LSI if it’s enabled, or through the most recent posts. We should remove this in 4.0 and switch to ‘post.related_posts }`.



46
47
48
49
# File 'lib/jekyll/drops/site_drop.rb', line 46

def related_posts
  return nil unless @current_document.is_a?(Jekyll::Document)
  @current_document.related_posts
end