Sha256: 0d3e3bcdaf9a53dded179aec1cda7bfb9148cf96fb0971207ba021b7ae4b8bd4

Contents?: true

Size: 878 Bytes

Versions: 1

Compression:

Stored size: 878 Bytes

Contents

# 3rd-party
require "jekyll"


# internal
require "jekyll/assets_plugin/configuration"
require "jekyll/assets_plugin/environment"


module Jekyll
  module AssetsPlugin
    module SitePatch

      def assets_config
        @assets_config ||= Configuration.new(self.config["assets"] || {})
      end


      def assets
        @assets ||= Environment.new self
      end


      def asset_path *args
        asset   = assets[*args]
        baseurl = "#{assets_config.baseurl}/"

        case assets_config.cachebust
        when :none then baseurl << asset.logical_path
        when :soft then baseurl << asset.logical_path << "?cb=#{asset.digest}"
        when :hard then baseurl << asset.digest_path
        else raise "Unknown cachebast strategy: #{assets_config.cachebust}"
        end
      end

    end
  end
end


Jekyll::Site.send :include, Jekyll::AssetsPlugin::SitePatch

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-assets-0.3.2 lib/jekyll/assets_plugin/site_patch.rb