Created
April 13, 2014 16:13
-
-
Save MichaelEvans/10590514 to your computer and use it in GitHub Desktop.
Plugin to embed G+ posts inside Octopress posts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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