module Middleman::Blog::Drafts::DraftArticle

A module that adds draft-article-specific methods to Resources. A {DraftArticle} can be retrieved via {Blog::Drafts::Helpers#current_article} or methods on {Blog::Drafts::Data} (accessible through BlogData#drafts). @see rdoc.info/github/middleman/middleman/Middleman/Sitemap/Resource Middleman::Sitemap::Resource

Public Instance Methods

data() click to toggle source

Extends resource data adding the date field

@return [Thor::CoreExt::HashWithIndifferentAccess]

Calls superclass method
# File lib/middleman-blog-drafts/draft_article.rb, line 42
def data
  super.dup.merge(date: date)
end
date() click to toggle source

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

@return [TimeWithZone]

# File lib/middleman-blog-drafts/draft_article.rb, line 35
def date
  Time.now.in_time_zone
end
path_part(part) click to toggle source

Retrieve a section of the source path @param [String] The part of the path, e.g. “title” @return [String]

# File lib/middleman-blog-drafts/draft_article.rb, line 24
def path_part(part)
  normalized_path = Addressable::URI.parse(path).normalize.to_s
  @_path_parts ||= blog_data.drafts.source_template.extract(normalized_path)
  @_path_parts[part.to_s]
end
slug() click to toggle source

The “slug” of the draft article that shows up in its URL. @return [String]

# File lib/middleman-blog-drafts/draft_article.rb, line 17
def slug
  @_slug ||= path_part("title")
end
title() click to toggle source

The title of the draft article, or “(UNTITLED DRAFT)” if no title was provided @return [String]

# File lib/middleman-blog-drafts/draft_article.rb, line 11
def title
  data["title"] || "(UNTITLED DRAFT)"
end