Sha256: c80c5f8284345ff35b9ce8e5ac79c05b94aefa6a21a6a06701a0cf9e8ce72c84

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

module Jekyll
  module Sharelinks
    class SocialTag < Liquid::Tag

      def render(context)
        site_url = context.registers[:site].config['url']
        site_twitter_username = context.registers[:site].config['twitter_username']
        site_facebook_app_id = context.registers[:site].config['facebook']['app_id']
        page_url = context.registers[:page]['url']
        page_title = context.registers[:page]['title']
        full_url = site_url + page_url

        output = ""
        output << "<ul>"
        output << "<li><a href='https://twitter.com/intent/tweet?text=#{page_title}&url=#{full_url}&via=#{site_twitter_username}&related=#{site_twitter_username}' rel='nofollow' target='_blank' title='Share on Twitter'>Twitter</a></li>"
        output << "<li><a href='https://www.facebook.com/dialog/feed?app_id=#{site_facebook_app_id}&link=#{full_url}' rel='nofollow' target='_blank' title='Share on Facebook'>Facebook</a></li>"
        output << "<li><a href='https://plus.google.com/share?url=#{full_url}' rel='nofollow' target='_blank' title='Share on Google+'>Google+</a></li>"
        output << "</ul>"
        output
      end

    end
    Liquid::Template.register_tag('sharelinks', Jekyll::Sharelinks::SocialTag)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-sharelinks-0.1.0 lib/jekyll-sharelinks/social_tag.rb