mirror of
https://github.com/ForkAwesome/Fork-Awesome.git
synced 2025-01-15 01:30:30 +08:00
2nd attempt: add plugin to calc SRI hash; add CDN to 'Get Started' page
This commit is contained in:
parent
df3e7916c0
commit
73039c316e
20
src/doc/_plugins/sri_hash.rb
Normal file
20
src/doc/_plugins/sri_hash.rb
Normal 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.strip
|
||||||
|
end
|
||||||
|
|
||||||
|
def render(context)
|
||||||
|
sha256 = Digest::SHA256.file(@filename)
|
||||||
|
"sha256-#{sha256.base64digest}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Liquid::Template.register_tag('sri_hash', Jekyll::GetSriHash)
|
@ -69,6 +69,21 @@ relative_path: ../
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</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">
|
<section class="get-started-more margin-top-lg" id="get-started-more">
|
||||||
<h2 class="page-header">More Information</h2>
|
<h2 class="page-header">More Information</h2>
|
||||||
</section>
|
</section>
|
||||||
|
Loading…
Reference in New Issue
Block a user