Class: Jekyll::Commands::ComposeCommand::ComposeCommandFileInfo

Inherits:
Jekyll::Compose::FileInfo show all
Defined in:
lib/jekyll/commands/compose.rb

Instance Attribute Summary

Attributes inherited from Jekyll::Compose::FileInfo

#params

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ ComposeCommandFileInfo

Returns a new instance of ComposeCommandFileInfo.



69
70
71
72
# File 'lib/jekyll/commands/compose.rb', line 69

def initialize(params)
  @params = params
  @collection = params.collection
end

Instance Method Details

#content(custom_front_matter = {}) ⇒ Object



91
92
93
94
95
96
# File 'lib/jekyll/commands/compose.rb', line 91

def content(custom_front_matter = {})
  default_front_matter = front_matter_defaults_for(@collection)
  custom_front_matter.merge!(default_front_matter) if default_front_matter.is_a?(Hash)

  super({ "date" => time_stamp }.merge!(custom_front_matter))
end

#file_nameObject



87
88
89
# File 'lib/jekyll/commands/compose.rb', line 87

def file_name
  @collection == "posts" ? "#{date_stamp}-#{super}" : super
end

#pathObject



83
84
85
# File 'lib/jekyll/commands/compose.rb', line 83

def path
  File.join("_#{@collection}", file_name)
end

#resource_typeObject



74
75
76
77
78
79
80
81
# File 'lib/jekyll/commands/compose.rb', line 74

def resource_type
  case @collection
  when "posts"  then "post"
  when "drafts" then "draft"
  else
    "file"
  end
end