Rework plugin to work a bit more cleanly. Add metadata and print blurb at bottom of posts.

This commit is contained in:
Anna Rose 2016-12-24 19:01:43 -05:00
parent e50152d3d1
commit 9cf8456d7c
No known key found for this signature in database
GPG Key ID: 682893DD0448ED78
3 changed files with 18 additions and 6 deletions

View File

@ -12,4 +12,9 @@ layout: default
{{ content }}
</div>
<div class="post-verify">
{% if page.md_file %}
The markdown source for this post is available here: <a href="{{page.md_file}}">{{page.md_file}}</a> <br/>
{% endif %}
</div>
</article>

View File

@ -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

View File

@ -36,3 +36,7 @@
font-size: $large-font-size;
padding: 0px 10px;
}
.post-verify {
font-size: $small-font-size;
}