require 'bundler' Bundler.require # Don't reload this file for nanoc autocompile. Otherwise, nanoc will eventually # throw an "ERROR SystemStackError: stack level too deep" exception. unless defined? LOADED_DEFAULT_CONFIG LOADED_DEFAULT_CONFIG = true require 'compass' Compass.add_project_configuration File.expand_path('../../compass-config.rb', __FILE__) include Nanoc3::Helpers::Blogging include Nanoc3::Helpers::Tagging include Nanoc3::Helpers::HTMLEscape include Nanoc3::Helpers::Rendering include Nanoc3::Helpers::LinkTo # cachebuster require 'nanoc/cachebuster' include Nanoc::Helpers::CacheBusting # 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