Skip to content

Instantly share code, notes, and snippets.

@cermakcz

cermakcz/_config.yml

Last active Apr 10, 2016
Embed
What would you like to do?
Simple Jekyll plugin for creating a CDN url Liquid filter
#cdn
cdnurl: 'https://s3-eu-west-1.amazonaws.com/outoftime/'
module Jekyll
module CdnUrlFilter
def cdn_url(input)
resolvedPath = input
# Strip the leading slash if there's any.
if resolvedPath.start_with?('/')
resolvedPath = resolvedPath[1..-1]
end
"#{@context.registers[:site].config['cdnurl']}#{resolvedPath}"
end
end
end
Liquid::Template.register_filter(Jekyll::CdnUrlFilter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment