diff --git a/lib/default.rb b/lib/default.rb index b2743bc..74f1b66 100644 --- a/lib/default.rb +++ b/lib/default.rb @@ -22,33 +22,4 @@ unless defined? LOADED_DEFAULT_CONFIG # javascript concatenation require 'nanoc/filters/javascript_concatenator' - - def articles_by_year - hash = Hash.new { |h, k| h[k] = [] } - sorted_articles.inject(hash) do |output, article| - year = attribute_to_time(article[:created_at]).year - output[year] << article - output - end - end - - module PostHelper - def get_short_date(post) - attribute_to_time(post[:created_at]).strftime('%d %b') - end - - def get_pretty_date(post) - attribute_to_time(post[:created_at]).strftime('%-d %B, %Y') - end - - def get_tags(post) - if post[:tags].nil? || post[:tags].empty? - "(not tagged)" - else - post[:tags].compact.map { |tag| tag.downcase }.sort.join(", ") - end - end - end - - include PostHelper end \ No newline at end of file diff --git a/lib/helpers/post.rb b/lib/helpers/post.rb new file mode 100644 index 0000000..65b7ccb --- /dev/null +++ b/lib/helpers/post.rb @@ -0,0 +1,26 @@ + module PostHelper + def articles_by_year + hash = Hash.new { |h, k| h[k] = [] } + sorted_articles.inject(hash) do |output, article| + year = attribute_to_time(article[:created_at]).year + output[year] << article + output + end + end + + def get_short_date(post) + attribute_to_time(post[:created_at]).strftime('%d %b') + end + + def get_pretty_date(post) + attribute_to_time(post[:created_at]).strftime('%-d %B, %Y') + end + + def get_tags(post) + if post[:tags].nil? || post[:tags].empty? + "(not tagged)" + else + post[:tags].compact.map { |tag| tag.downcase }.sort.join(", ") + end + end + end \ No newline at end of file diff --git a/lib/helpers_.rb b/lib/helpers_.rb new file mode 100644 index 0000000..36ec67f --- /dev/null +++ b/lib/helpers_.rb @@ -0,0 +1 @@ +include PostHelper \ No newline at end of file