Skip to content

Instantly share code, notes, and snippets.

@jamesslock
Created August 5, 2014 11:14
Show Gist options
  • Save jamesslock/46b7f3c3826e7266de4a to your computer and use it in GitHub Desktop.
Save jamesslock/46b7f3c3826e7266de4a to your computer and use it in GitHub Desktop.
Open Graph Meta Simple as Milk
-# Data Setup -----------------------------------------------------------------
- default_title = "Simple as Milk"
- default_description = "It's data that makes a beautiful experience and it's personality that makes that experience human. You guessed it; we design and build user experiences."
- @title = yield_content(:title).presence || current_page.data.title || default_title
- @description = (yield_content(:meta_description).presence || current_page.data.description || default_description)
- @author = {}
- if current_article.present?
- @author[:name] = current_article.metadata[:page]['post_by']
- if @author[:name].present?
- matched_user = data.team.members.select{|m| "#{m.first_name} #{m.last_name}".downcase == @author[:name].downcase}.first
- if matched_user
- @author[:team_member] = matched_user
- @author[:google_plus] = matched_user.google_plus
- @author[:twitter] = matched_user.twitter
- else
- @author[:name] = 'Simple as Milk'
- @author[:google_plus] = 'http://plus.google.com/105559728573291365462'
- @author[:twitter] = '@simpleasmilk'
-# Meta Data-------------------------------------------------------------------
%title= @title
%meta{description: @description}
%link{ rel: "publisher", href: "http://plus.google.com/105559728573291365462" }
%meta{ name: 'author', content: @author[:name] }
%link{ rel: 'author', href: @author[:google_plus] }
// Google+ Schema Meta
%meta{ itemprop: 'name', content: @title}
%meta{ itemprop: 'description', content: @description}
/ Display a default image, unless specified in page meta (blog posts will have custom for example, maybe other pages like case studies and team pages)
%meta{ itemprop: 'image', content: @data}
// Facebook Opengraph Meta
%meta{ property: 'og:site_name', content: 'Simple as Milk'}
- if current_article.present?
%meta{ property: 'og:type', content: 'blog'}
- elsif current_resource.url.include? '/team/'
%meta{ property: 'og:type', content: 'profile'}
- else
%meta{ property: 'og:type', content: 'website'}
%meta{ property: 'og:local', content: 'en_GB'}
%meta{ property: 'og:title', content: @title}
%meta{ property: 'og:description', content: @description}
/ Link to url
%meta{ property: 'og:url', content: "http://simpleasmilk.com#{current_resource.url}"}
/ Display a default image, unless specified in page meta (blog posts will have custom for example, maybe other pages like case studies and team pages)
%meta{ property: 'og:image', content: @data}
// Twitter Cards Meta
%meta{ property: 'og:twitter:card', content: 'summary_large_image'}
%meta{ property: 'og:twitter:site', content: '@simpleasmilk'}
%meta{ property: 'og:twitter:creator', content: @author[:twitter]}
%meta{ property: 'og:twitter:url', content: 'http://simpleasmilk.com'}
%meta{ property: 'og:twitter:title', content: @title}
%meta{ property: 'og:twitter:description', content: @description}
/ Display a default image, unless specified in page meta (blog posts will have custom for example, maybe other pages like case studies and team pages)
%meta{ property: 'og:twitter:image', content: @data}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment