Skip to content

Instantly share code, notes, and snippets.

@MichaelEvans
Created April 13, 2014 16:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MichaelEvans/10590514 to your computer and use it in GitHub Desktop.
Save MichaelEvans/10590514 to your computer and use it in GitHub Desktop.
Plugin to embed G+ posts inside Octopress posts
module Jekyll
class GooglePlusEmbedTag < Liquid::Tag
@post = nil
@height = ''
@width = ''
def initialize(tag_name, markup, tokens)
if markup =~ /(https:\/\/plus.google.com\/\d+\/posts\/\w+)/i
@url = $1
end
super
end
def render(context)
"<div align='center'><div class='g-post' data-href='#{@url}'></div></div>"
end
end
end
Liquid::Template.register_tag('google_plus', Jekyll::GooglePlusEmbedTag)
@sandeshdamkondwar
Copy link

Works like charm but newer Google+ posts can have different format,
like "https://plus.google.com/+LarryPage/posts/MtVcQaAi684"

You need to change that regex to
/(https:\/\/plus.google.com\/\+\w+\/posts\/\w+)/i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment