Skip to content

Instantly share code, notes, and snippets.

@gr4y
Last active February 11, 2018 10:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gr4y/7934642 to your computer and use it in GitHub Desktop.
Save gr4y/7934642 to your computer and use it in GitHub Desktop.
Liquid-Tag for embedding Instagram into your Jekyll Posts
module Jekyll
class InstagramTag < Liquid::Tag
def initialize(tag_name, hash, tokens)
super
@hash = hash.strip!
end
def render(context)
"<div class='embed instagram'>#{iframe_for(@hash)}</div>"
end
def iframe_for(hash)
url = "//instagram.com/p/#{hash}/embed/"
"<iframe src='#{url}' frameborder='0' scrolling='no' allowtransparency='true'></iframe>"
end
end
end
Liquid::Template.register_tag('instagram', Jekyll::InstagramTag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment