Skip to content

Instantly share code, notes, and snippets.

@mclaughj
Created January 28, 2013 00:04
Show Gist options
  • Save mclaughj/4651529 to your computer and use it in GitHub Desktop.
Save mclaughj/4651529 to your computer and use it in GitHub Desktop.
def archives filter = "", tag = nil
entries = ! self.articles.empty??
self.articles.select do |a|
filter !~ /^\d{4}/ || File.basename(a) =~ /^#{filter}/
end.reverse.map do |article|
Article.new article, @config
end : []
if tag.nil?
{ :archives => Archives.new(entries, @config) }
else
tagged = entries.select do |article|
article_tag = article.tags
article_tag && article.tags.gsub(/\s+/, "").split(",").include?(tag)
end
{ :tag => tag, :archives => tagged } if tagged.size > 0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment