Forked from mhansen/jekyll-create-tag-pages-rakefile.rb
Created
September 9, 2010 07:38
-
-
Save flaviusb/571536 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc 'Generate tags page' | |
task :tags do | |
puts "Generating tags..." | |
require 'rubygems' | |
require 'jekyll' | |
include Jekyll::Filters | |
options = Jekyll.configuration({}) | |
site = Jekyll::Site.new(options) | |
site.read_posts('') | |
site.tags.sort.each do |tag, posts| | |
html = '' | |
html << <<-HTML | |
--- | |
layout: tag | |
title: Posts tagged "#{tag}" | |
--- | |
<h1 id="#{tag}">Posts tagged "#{tag}"</h1> | |
HTML | |
html << '<ul class="posts">' | |
posts.each do |post| | |
post_data = post.to_liquid | |
html << <<-HTML | |
<li><a href="#{post.url}">#{post_data['title']}</a></li> | |
HTML | |
end | |
html << '</ul>' | |
File.open("tags/#{tag}.html", 'w+') do |file| | |
file.puts html | |
end | |
end | |
puts 'Done.' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment