Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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

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