Add signature detection in addition to markdown inclusion.
This commit is contained in:
@ -1,14 +1,26 @@
|
||||
# Adds metadata to the post object for linking to the source page.
|
||||
# Also adds metadata linking to the gpg signature file, if it exists.
|
||||
Jekyll::Hooks.register :posts, :pre_render do |post, payload|
|
||||
if post.path =~ /\.md$/
|
||||
post.data['md_file'] = "/#{post.data['category']}/#{post.basename}"
|
||||
|
||||
sig_filename = "#{post.path}.asc"
|
||||
if File.exist?(sig_filename)
|
||||
post.data['sig_file'] = post.data['md_file'] + '.asc'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Copy all of the source markdown files directly into the destination.
|
||||
# Copy all of the source markdown files and signature files
|
||||
# directly into the destination.
|
||||
Jekyll::Hooks.register :site, :post_write do |site|
|
||||
dest = site.dest
|
||||
site.posts.docs.select{|p| p.path =~ /\.md$/}.each do |post|
|
||||
FileUtils.cp(post.path, "#{dest}/#{post.data['category']}/#{post.basename}")
|
||||
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
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user