5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/jekyll-oldcomments.rb', line 5
def render(context)
= File.join(context.registers[:site].source, '_comments','*.md')
= Hash.new
Dir[].each do ||
yaml = YAML.load_file()
fd = File.open(,'r')
text = fd.read().split('---')[2]
fd.close
path = yaml['path'].strip
if not .has_key?(path)
[path] = Array.new
end
[path] << { 'meta' => yaml, 'text' => text.gsub(/^(.*)$/, '<p>\1</p>') }
end
.each do |key, value|
[key].sort!{ |a,b| a['meta']['date']<=>b['meta']['date'] }
end
tmpl = File.read File.join Dir.pwd, "_includes", 'comments.html'
(Liquid::Template.parse tmpl).render('comments' => [context.registers[:page]['permalink']])
end
|