From 9cf8456d7cc2f31614b45f2369b13a206d7fc5d9 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sat, 24 Dec 2016 19:01:43 -0500 Subject: [PATCH] Rework plugin to work a bit more cleanly. Add metadata and print blurb at bottom of posts. --- _layouts/post.html | 5 +++++ _plugins/markdown_and_sign.rb | 15 +++++++++------ _sass/_custom.scss | 4 ++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/_layouts/post.html b/_layouts/post.html index 5e5b91f..fac08fa 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -12,4 +12,9 @@ layout: default {{ content }} +
+ {% if page.md_file %} + The markdown source for this post is available here: {{page.md_file}}
+ {% endif %} +
diff --git a/_plugins/markdown_and_sign.rb b/_plugins/markdown_and_sign.rb index 939b5eb..7030bfa 100644 --- a/_plugins/markdown_and_sign.rb +++ b/_plugins/markdown_and_sign.rb @@ -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 diff --git a/_sass/_custom.scss b/_sass/_custom.scss index 122f8da..9f7ecb6 100644 --- a/_sass/_custom.scss +++ b/_sass/_custom.scss @@ -36,3 +36,7 @@ font-size: $large-font-size; padding: 0px 10px; } + +.post-verify { + font-size: $small-font-size; +}