diff options
author | Connor Shea <connor.james.shea@gmail.com> | 2016-10-27 10:07:45 +0300 |
---|---|---|
committer | Connor Shea <connor.james.shea@gmail.com> | 2016-10-27 10:07:45 +0300 |
commit | 2fd0e31b1acb8b1f58ce1fc3e0b74ca7233c1193 (patch) | |
tree | cd05dc61e7591a3bf3138085b132d964bd65c3f5 /Rules | |
parent | 5eca43ebf626fecf478a0dc439e6be3f6c7d6b22 (diff) |
Get the titles from the Markdown when preprocessing.
Diffstat (limited to 'Rules')
-rw-r--r-- | Rules | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -1,5 +1,21 @@ #!/usr/bin/env ruby +preprocess do + @items.each do |item| + if item.identifier.to_s.end_with?(".md") && !item.binary? + begin + title = item.raw_content.match(/^[#] .*$/s).to_s + title.gsub!('# ', '') + item[:title] = title + # Encoding errors happen on some files for some reason, so we + # rescue them. + rescue Encoding::CompatibilityError + puts "Encoding error" + end + end + end +end + compile '/**/*.html' do layout '/default.*' end |