class Middleman::Cli::BlogPage

This class provides an “article” command for the middleman CLI.

Public Class Methods

exit_on_failure?() click to toggle source

Tell Thor to exit with a nonzero exit code on failure

# File lib/middleman-blog_page/commands/blog_page.rb, line 21
def self.exit_on_failure?
  true
end
source_root() click to toggle source

Template files are relative to this file @return [String]

# File lib/middleman-blog_page/commands/blog_page.rb, line 16
def self.source_root
  File.dirname(__FILE__)
end

Public Instance Methods

blog_page(title) click to toggle source
# File lib/middleman-blog_page/commands/blog_page.rb, line 26
def blog_page(title)
  shared_instance = ::Middleman::Application.server.inst

  # This only exists when the config.rb sets it!
  if shared_instance.respond_to? :blog_pages
    @title = title
    @slug = title.parameterize

    article_path = shared_instance.blog_page.options.sources.
      sub(':title', @slug)

    template "blog_page.tt", File.join(shared_instance.source_dir, article_path + shared_instance.blog.options.default_extension)
  else
    raise Thor::Error.new "You need to activate the blog_page extension in config.rb before you can create an article"
  end
end