Class: Jekyll::Drops::SiteDrop
- Extended by:
- Forwardable
- Defined in:
- lib/jekyll/drops/site_drop.rb
Constant Summary
Constants inherited from Drop
Instance Attribute Summary collapse
-
#current_document ⇒ Object
writeonly
Sets the attribute current_document.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #collections ⇒ Object
-
#config ⇒ Object
return nil for ‘site.config }` even if –config was passed via CLI.
-
#documents ⇒ Object
‘Site#documents` cannot be memoized so that `Site#docs_to_write` can access the latest state of the attribute.
- #html_pages ⇒ Object
- #key?(key) ⇒ Boolean
- #posts ⇒ Object
-
#related_posts ⇒ Object
‘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.
Methods inherited from Drop
#[]=, #content_methods, data_delegator, data_delegators, delegate_method, delegate_method_as, delegate_methods, #each, #each_key, #fetch, getter_method_names, #hash_for_json, #initialize, #inspect, #keys, #merge, #merge!, mutable, mutable?, private_delegate_methods, #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
60 61 62 |
# File 'lib/jekyll/drops/site_drop.rb', line 60 def current_document=(value) @current_document = value end |
Instance Method Details
#[](key) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/jekyll/drops/site_drop.rb', line 15 def [](key) if key != "posts" && @obj.collections.key?(key) @obj.collections[key].docs else super(key) end end |
#collections ⇒ Object
37 38 39 |
# File 'lib/jekyll/drops/site_drop.rb', line 37 def collections @site_collections ||= @obj.collections.values.sort_by(&:label).map(&:to_liquid) end |
#config ⇒ Object
return nil for ‘site.config }` even if –config was passed via CLI
63 |
# File 'lib/jekyll/drops/site_drop.rb', line 63 def config; end |
#documents ⇒ Object
‘Site#documents` cannot be memoized so that `Site#docs_to_write` can access the latest state of the attribute.
Since this method will be called after ‘Site#pre_render` hook, the `Site#documents` array shouldn’t thereafter change and can therefore be safely memoized to prevent additional computation of ‘Site#documents`.
47 48 49 |
# File 'lib/jekyll/drops/site_drop.rb', line 47 def documents @documents ||= @obj.documents end |
#html_pages ⇒ Object
31 32 33 34 35 |
# File 'lib/jekyll/drops/site_drop.rb', line 31 def html_pages @site_html_pages ||= @obj.pages.select do |page| page.html? || page.url.end_with?("/") end end |
#key?(key) ⇒ Boolean
23 24 25 |
# File 'lib/jekyll/drops/site_drop.rb', line 23 def key?(key) (key != "posts" && @obj.collections.key?(key)) || super end |
#posts ⇒ Object
27 28 29 |
# File 'lib/jekyll/drops/site_drop.rb', line 27 def posts @site_posts ||= @obj.posts.docs.sort { |a, b| b <=> a } end |
#related_posts ⇒ Object
‘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 }`.
55 56 57 58 59 |
# File 'lib/jekyll/drops/site_drop.rb', line 55 def return nil unless @current_document.is_a?(Jekyll::Document) @current_document. end |