Module: Middleman::Blog::Drafts::DraftArticle
- Defined in:
- lib/middleman-blog-drafts/draft_article.rb
Instance Method Summary collapse
-
#data ⇒ Thor::CoreExt::HashWithIndifferentAccess
Extends resource data adding the date field.
-
#date ⇒ TimeWithZone
Returns current date as we can’t guess when the article will be published.
-
#path_part(part) ⇒ String
Retrieve a section of the source path.
-
#slug ⇒ String
The “slug” of the draft article that shows up in its URL.
Instance Method Details
#data ⇒ Thor::CoreExt::HashWithIndifferentAccess
Extends resource data adding the date field
32 33 34 |
# File 'lib/middleman-blog-drafts/draft_article.rb', line 32 def data super.dup.merge(date: date) end |
#date ⇒ TimeWithZone
Returns current date as we can’t guess when the article will be published
We need this in place or the layout used for blog posts might blow up
25 26 27 |
# File 'lib/middleman-blog-drafts/draft_article.rb', line 25 def date Time.now.in_time_zone end |
#path_part(part) ⇒ String
Retrieve a section of the source path
14 15 16 17 18 |
# File 'lib/middleman-blog-drafts/draft_article.rb', line 14 def path_part(part) @_path_parts ||= app.blog.drafts.path_matcher.match(path).captures @_path_parts[app.blog.drafts.matcher_indexes[part]] end |
#slug ⇒ String
The “slug” of the draft article that shows up in its URL.
7 8 9 |
# File 'lib/middleman-blog-drafts/draft_article.rb', line 7 def slug @_slug ||= path_part("title") end |