Module: Middleman::Blog::Helpers
- Defined in:
- lib/middleman-blog/extension_3_0.rb
Overview
Helpers for use within templates and layouts.
Instance Method Summary collapse
-
#blog(options = nil) ⇒ BlogData
Get the BlogData for this site.
-
#blog_day_path(year, month, day) ⇒ String
Get a path to the given day-based calendar page, based on the :day_link setting.
-
#blog_month_path(year, month) ⇒ String
Get a path to the given month-based calendar page, based on the :month_link setting.
-
#blog_year_path(year) ⇒ String
Get a path to the given year-based calendar page, based on the :year_link setting.
-
#current_article ⇒ Middleman::Sitemap::Resource
Get a Resource with mixed in BlogArticle methods representing the current article.
-
#is_blog_article? ⇒ Boolean
Determine whether the currently rendering template is a blog article.
-
#page_articles ⇒ Array<Middleman::Sitemap::Resource>
Returns the list of articles to display on this page.
-
#paginate ⇒ Boolean
Returns true if pagination is turned on for this template; false otherwise.
-
#tag_path(tag) ⇒ String
Get a path to the given tag, based on the :taglink setting.
Instance Method Details
#blog(options = nil) ⇒ BlogData
Get the BlogData for this site.
180 181 182 |
# File 'lib/middleman-blog/extension_3_0.rb', line 180 def blog(=nil) @_blog ||= BlogData.new(self, ) end |
#blog_day_path(year, month, day) ⇒ String
Get a path to the given day-based calendar page, based on the :day_link setting.
224 225 226 |
# File 'lib/middleman-blog/extension_3_0.rb', line 224 def blog_day_path(year, month, day) sitemap.find_resource_by_path(CalendarPages.link(self.blog., year, month, day)).try(:url) end |
#blog_month_path(year, month) ⇒ String
Get a path to the given month-based calendar page, based on the :month_link setting.
215 216 217 |
# File 'lib/middleman-blog/extension_3_0.rb', line 215 def blog_month_path(year, month) sitemap.find_resource_by_path(CalendarPages.link(self.blog., year, month)).try(:url) end |
#blog_year_path(year) ⇒ String
Get a path to the given year-based calendar page, based on the :year_link setting.
207 208 209 |
# File 'lib/middleman-blog/extension_3_0.rb', line 207 def blog_year_path(year) sitemap.find_resource_by_path(CalendarPages.link(self.blog., year)).try(:url) end |
#current_article ⇒ Middleman::Sitemap::Resource
Get a Resource with mixed in BlogArticle methods representing the current article.
193 194 195 |
# File 'lib/middleman-blog/extension_3_0.rb', line 193 def current_article blog.article(current_resource.path) end |
#is_blog_article? ⇒ Boolean
Determine whether the currently rendering template is a blog article. This can be useful in layouts.
187 188 189 |
# File 'lib/middleman-blog/extension_3_0.rb', line 187 def is_blog_article? !current_article.nil? end |
#page_articles ⇒ Array<Middleman::Sitemap::Resource>
Returns the list of articles to display on this page.
239 240 241 242 243 244 245 |
# File 'lib/middleman-blog/extension_3_0.rb', line 239 def page_articles limit = (current_resource.[:page]["per_page"] || 0) - 1 # "articles" local variable is populated by Calendar and Tag page generators # If it's not set then use the complete list of articles (current_resource.[:locals]["articles"] || blog.articles)[0..limit] end |
#paginate ⇒ Boolean
Returns true if pagination is turned on for this template; false otherwise.
235 |
# File 'lib/middleman-blog/extension_3_0.rb', line 235 def paginate; false; end |