Sha256: 372374fb64deafb5db41b1488b53768ce0bbbb2e7fd3f4b1892b08e8c74005cd

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

# Frozen-string-literal: true
# Copyright: 2012 - 2018 - MIT License
# Encoding: utf-8

require "jekyll/assets"

module Jekyll
  module Assets
    class Default
      class Favicon < Default
        content_types "image/x-icon"
        internal!

        # --
        def set_rel
          @args[:rel] = "shortcut icon"
        end

        # --
        def set_href
          dpath = @asset.digest_path
          return @args[:href] = @asset.url if @asset.is_a?(Url)
          return @args[:href] = @env.prefix_url(dpath) unless @args[:inline]
          @args[:href] = @asset.data_uri
        end

        # --
        def set_integrity
          return unless integrity?
          @args[:integrity] = @asset.integrity
          unless @args.key?(:crossorigin)
            @args[:crossorigin] = "anonymous"
          end
        end

        # --
        def integrity?
          config[:integrity] && !@asset.is_a?(Url) &&
            !@args.key?(:integrity)
        end
      end
    end
  end
end

# --
Jekyll::Assets::Hook.register :config, :before_merge do |c|
  c.deep_merge!({
    defaults: {
      favicon: {
        integrity: Jekyll.production?,
      },
    },
  })
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jekyll-assets-3.0.12 lib/jekyll/assets/plugins/html/defaults/favicon.rb
jekyll-assets-3.0.11 lib/jekyll/assets/plugins/html/defaults/favicon.rb
jekyll-assets-3.0.10 lib/jekyll/assets/plugins/html/defaults/favicon.rb
jekyll-assets-3.0.9 lib/jekyll/assets/plugins/html/defaults/favicon.rb
jekyll-assets-3.0.8 lib/jekyll/assets/plugins/html/defaults/favicon.rb
jekyll-assets-3.0.7 lib/jekyll/assets/plugins/html/defaults/favicon.rb