Rework plugin to work a bit more cleanly. Add metadata and print blurb at bottom of posts.
This commit is contained in:
parent
e50152d3d1
commit
9cf8456d7c
3 changed files with 18 additions and 6 deletions
|
@ -1,11 +1,14 @@
|
|||
# Adds metadata to the post object for linking to the source page.
|
||||
Jekyll::Hooks.register :posts, :pre_render do |post, payload|
|
||||
if post.path =~ /\.md$/
|
||||
post.data['md_file'] = "/#{post.data['category']}/#{post.basename}"
|
||||
end
|
||||
end
|
||||
|
||||
# Copy all of the source markdown files directly into the destination.
|
||||
Jekyll::Hooks.register :site, :post_write do |site|
|
||||
dest = site.dest
|
||||
categories = site.config['category_metadata'].each_key do |category|
|
||||
dir = Dir.new("#{site.source}/_posts/#{category}")
|
||||
dir.each do |filename|
|
||||
next unless filename =~ /\.md$/
|
||||
FileUtils.cp("#{dir.path}/#{filename}", "#{dest}/#{category}/")
|
||||
end
|
||||
site.posts.docs.select{|p| p.path =~ /\.md$/}.each do |post|
|
||||
FileUtils.cp(post.path, "#{dest}/#{post.data['category']}/#{post.basename}")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue