Skip to content

Instantly share code, notes, and snippets.

@cermakcz
Last active April 10, 2016 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cermakcz/e4067680e2477fe10c6c5ecc04068c52 to your computer and use it in GitHub Desktop.
Save cermakcz/e4067680e2477fe10c6c5ecc04068c52 to your computer and use it in GitHub Desktop.
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