Sha256: e2c607bb8fcda96b04c61a66587704ef3974df5fd785813f01ba615c519bfee4

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

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

require "jekyll/assets"

module Jekyll
  module Assets
    class Default
      class CSS < Default
        content_types "text/css"
        static rel: "stylesheet", type: "text/css"
        internal!

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

        # --
        def set_integrity
          return unless integrity?
          @args[:integrity] = @asset.integrity
          if !@args.key?(:crossorigin) && @args[:integrity]
            @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: {
      css: {
        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/css.rb
jekyll-assets-3.0.11 lib/jekyll/assets/plugins/html/defaults/css.rb
jekyll-assets-3.0.10 lib/jekyll/assets/plugins/html/defaults/css.rb
jekyll-assets-3.0.9 lib/jekyll/assets/plugins/html/defaults/css.rb
jekyll-assets-3.0.8 lib/jekyll/assets/plugins/html/defaults/css.rb
jekyll-assets-3.0.7 lib/jekyll/assets/plugins/html/defaults/css.rb