Skip to content

Instantly share code, notes, and snippets.

@kez
Created December 23, 2009 13:13
Show Gist options
  • Select an option

  • Save kez/262512 to your computer and use it in GitHub Desktop.

Select an option

Save kez/262512 to your computer and use it in GitHub Desktop.

Revisions

  1. kez created this gist Dec 23, 2009.
    34 changes: 34 additions & 0 deletions jekyll-create-tag-pages-rakefile.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    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.categories.sort.each do |category, posts|
    html = ''
    html << <<-HTML
    ---
    layout: default
    title: Postings tagged "#{category}"
    ---
    <h1 id="#{category}">Postings tagged "#{category}"</h1>
    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/#{category}.html", 'w+') do |file|
    file.puts html
    end
    end
    puts 'Done.'
    end