diff --git a/_includes/head.html b/_includes/head.html index 175fbe5..b40becd 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -1,4 +1,4 @@ - + diff --git a/_plugins/asset_digest.rb b/_plugins/asset_digest.rb new file mode 100644 index 0000000..18acdfe --- /dev/null +++ b/_plugins/asset_digest.rb @@ -0,0 +1,19 @@ +module Jekyll + module AssetDigest + def asset_digest(input) + site = @context.registers[:site] + file_path = site.in_source_dir(input.sub(/^\//, '')) + + if File.exist?(file_path) + content = File.read(file_path) + hash = Digest::MD5.hexdigest(content) + Jekyll.logger.info "AssetDigest", "Generated: #{input} => #{hash}" + "#{input}?v=#{hash}" + else + input + end + end + end +end + +Liquid::Template.register_filter(Jekyll::AssetDigest)