Skip to content

Instantly share code, notes, and snippets.

@denisdefreyne
Created October 23, 2010 09:46
Show Gist options
  • Save denisdefreyne/642006 to your computer and use it in GitHub Desktop.
Save denisdefreyne/642006 to your computer and use it in GitHub Desktop.
preprocess do
# Find items to put in archives
items_to_archive = items.select { |i| i.identifier =~ /^\/files/ }
# Group them by extension
item_groups = items_to_archive.group_by { |i| i[:extension] }
# For each extension (and their items)...
item_groups.each_pair do |extension, items|
# ... create a new item
items << Nanoc3::Item.new(
'',
{ :identifiers => items.map { |i| i.identifier } },
"/archives/#{extension}.tar.bz2"
)
end
compile '/archives/*/' do
filter :tar
end
route '/archives/*/' do
item.identifier.chop + '.tar.b2'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment