Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pkazmierczak/1554185 to your computer and use it in GitHub Desktop.
Save pkazmierczak/1554185 to your computer and use it in GitHub Desktop.
This fork works for 'tags', not 'categories'.
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: main
title: Posts tagged "#{tag}"
---
<h1 id="#{tag}">Postings tagged "#{tag}"</h1>
HTML
posts.reverse.each do |post|
post_data = post.to_liquid
html << <<-HTML
<div class="section list">
<h1>#{date_to_string(post.date)}</h1>
<p class="line">
<a class="title" href="#{post.url}">#{post_data['title']}</a>
</p>
<p class="excerpt">
#{post_data['excerpt']}
</p>
</div>
HTML
end
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