add plugin to calc SRI hash; add CDN to 'Get Started' page

This commit is contained in:
Helmut K. C. Tessarek 2018-02-27 17:03:10 -05:00
parent 2046c03885
commit d564996430
No known key found for this signature in database
GPG key ID: BE0985349D44DD00
2 changed files with 35 additions and 0 deletions

View file

@ -0,0 +1,20 @@
##
# Generate an SRI hash for a given file
require 'digest'
module Jekyll
class GetSriHash < Liquid::Tag
def initialize(tag_name, text, tokens)
super
@filename = text
end
def render(context)
sha256 = Digest::SHA256.file '@filename'
"sha256-#{sha256.base64digest}"
end
end
end
Liquid::Template.register_tag('sri_hash', Jekyll::GetSriHash)

View file

@ -69,6 +69,21 @@ relative_path: ../
</div>
</section>
<section class="get-started-CDN margin-top-lg" id="get-started-CDN">
<h2 class="page-header">Using {{ site.forkawesome.name }} with a CDN</h2>
</section>
<div class="row">
<div class="col-md-12">
<p>Thanks to <a href="https://www.jsdelivr.com">jsDelivr</a>, {{ site.forkawesome.name }} is available via a CDN as well.</p>
<p>
{% highlight html %}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/fork-awesome@{{ site.forkawesome.version }}/css/fork-awesome.min.css" integrity="{% sri_hash /css/fork-awesome.min.css %}" crossorigin="anonymous">
{% endhighlight %}
</p>
</div>
</div>
<section class="get-started-more margin-top-lg" id="get-started-more">
<h2 class="page-header">More Information</h2>
</section>