Class: Jekyll::Site
- Inherits:
-
Object
- Object
- Jekyll::Site
- Defined in:
- lib/jekyll/strapi/site.rb
Overview
Add helper methods for dealing with Strapi to the Site class
Instance Method Summary collapse
- #endpoint ⇒ Object
- #has_strapi? ⇒ Boolean
- #has_strapi_collections? ⇒ Boolean
- #parameter ⇒ Object
- #strapi ⇒ Object
- #strapi_collection(collection_name) ⇒ Object
- #strapi_collections ⇒ Object
- #strapi_link_resolver(collection = nil, document = nil) ⇒ Object
Instance Method Details
#endpoint ⇒ Object
21 22 23 |
# File 'lib/jekyll/strapi/site.rb', line 21 def endpoint has_strapi? and @config['strapi']['endpoint'] or "http://localhost:1337/api" end |
#has_strapi? ⇒ Boolean
13 14 15 |
# File 'lib/jekyll/strapi/site.rb', line 13 def has_strapi? @config['strapi'] != nil end |
#has_strapi_collections? ⇒ Boolean
17 18 19 |
# File 'lib/jekyll/strapi/site.rb', line 17 def has_strapi_collections? has_strapi? and @config['strapi']['collections'] != nil end |
#parameter ⇒ Object
25 26 27 |
# File 'lib/jekyll/strapi/site.rb', line 25 def parameter has_strapi? and @config['strapi']['parameter'] or "populate=*" end |
#strapi ⇒ Object
4 5 6 |
# File 'lib/jekyll/strapi/site.rb', line 4 def strapi return nil unless has_strapi? end |
#strapi_collection(collection_name) ⇒ Object
47 48 49 |
# File 'lib/jekyll/strapi/site.rb', line 47 def strapi_collection(collection_name) strapi_collections[collection_name] end |
#strapi_collections ⇒ Object
8 9 10 11 |
# File 'lib/jekyll/strapi/site.rb', line 8 def strapi_collections return Array.new unless has_strapi_collections? @strapi_collections ||= Hash[@config['strapi']['collections'].map {|name, config| [name, Strapi::StrapiCollection.new(self, name, config)]}] end |
#strapi_link_resolver(collection = nil, document = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/jekyll/strapi/site.rb', line 29 def strapi_link_resolver(collection = nil, document = nil) return "/" unless collection != nil and @config['strapi']['collections'][collection]['permalink'] != nil url = Jekyll::URL.new( :template => @config['strapi']['collections'][collection]['permalink'], :placeholders => { :id => document.id.to_s, :uid => document.uid, :slug => document.attributes.slug, :type => document.type, :date => document.attributes.date, :title => document.attributes.title } ) url.to_s end |