-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
executable file
·47 lines (39 loc) · 938 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
desc 'Generate tags pages'
task :tags do
puts "Generating tags..."
require 'rubygems'
require 'jekyll'
include Jekyll::Filters
options = Jekyll.configuration({})
site = Jekyll::Site.new(options)
site.read_posts('')
# Remove tags directory before regenerating
FileUtils.rm_rf("tags")
site.tags.each do |tag, posts|
puts "tag: #{tag}"
html = <<-HTML
---
layout: default
title: "tagged: #{tag}"
syntax-highlighting: yes
---
<div id="archive">
<h1 class="title">Archive for <span class="archive-title">#{tag}</span></h1>
<div id="items">
{% for post in site.posts %}
{% for tag in post.tags %}
{%if tag == "#{tag}" %}
{%include post.html%}
{%endif%}
{%endfor%}
{% endfor %}
</div>
</div>
HTML
FileUtils.mkdir_p("tags/#{tag}")
File.open("tags/#{tag}/index.html", 'w+') do |file|
file.puts html
end
end
puts 'Done.'
end