2016-12-25 00:01:43 +00:00
|
|
|
# Adds metadata to the post object for linking to the source page.
|
2016-12-25 20:33:55 +00:00
|
|
|
# Also adds metadata linking to the gpg signature file, if it exists.
|
2016-12-25 00:01:43 +00:00
|
|
|
Jekyll::Hooks.register :posts, :pre_render do |post, payload|
|
|
|
|
if post.path =~ /\.md$/
|
|
|
|
post.data['md_file'] = "/#{post.data['category']}/#{post.basename}"
|
2016-12-25 20:33:55 +00:00
|
|
|
|
|
|
|
sig_filename = "#{post.path}.asc"
|
|
|
|
if File.exist?(sig_filename)
|
|
|
|
post.data['sig_file'] = post.data['md_file'] + '.asc'
|
|
|
|
end
|
2016-12-25 00:01:43 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-12-25 20:33:55 +00:00
|
|
|
# Copy all of the source markdown files and signature files
|
|
|
|
# directly into the destination.
|
2016-12-24 22:26:51 +00:00
|
|
|
Jekyll::Hooks.register :site, :post_write do |site|
|
|
|
|
dest = site.dest
|
2016-12-25 00:01:43 +00:00
|
|
|
site.posts.docs.select{|p| p.path =~ /\.md$/}.each do |post|
|
2016-12-25 20:33:55 +00:00
|
|
|
FileUtils.cp(post.path, "#{dest}/#{post.data['md_file']}")
|
|
|
|
|
|
|
|
sig_filename = "#{post.path}.asc"
|
|
|
|
if File.exist?(sig_filename)
|
|
|
|
FileUtils.cp(sig_filename, "#{dest}/#{post.data['sig_file']}")
|
|
|
|
end
|
2016-12-24 22:26:51 +00:00
|
|
|
end
|
|
|
|
end
|