Instantly share code, notes, and snippets.
Last active
January 15, 2017 14:37
-
Save williammincy/0ef9ab7d32beeb6993ef0d84aefea8ac to your computer and use it in GitHub Desktop.
Pug Mixins for Social Media metadata within HTML pages
This file contains 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
mixin facebookMetadata(options) | |
if options.admin | |
meta(property="fb:admins", content= options.admin) | |
if options.appid | |
meta(property="fb:app_id", content= options.appid) | |
if options.url | |
meta(property="og:url", content= options.url) | |
if options.type | |
meta(property="og:type", content= options.type) | |
if options.title | |
meta(property="og:title", content= options.title) | |
if options.image | |
meta(name="image", property="og:image", content= options.image) | |
if options.description | |
meta(property="og:description", content= options.description) | |
if options.sitename | |
meta(property="og:site_name", content= options.sitename) | |
if options.author | |
meta(property="article:author", content= options.author) | |
if options.publisher | |
meta(property="article:publisher", content= options.publisher) |
This file contains 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
mixin googleplus(options) | |
if options.author | |
link(rel="author", href= options.author) | |
if options.publisher | |
link(rel="publisher", href= options.publisher) | |
if options.name | |
meta(itemprop="name", content= options.name) | |
if options.description | |
meta(itemprop="description", content= options.description) | |
if options.image | |
meta(itemprop="image", content= options.image) |
This file contains 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
mixin twittercard_gallery(options) | |
meta(name="twitter:card",content="gallery") | |
if options.site | |
meta(name="twitter:site", content= options.site) | |
if options.creator | |
meta(name="twitter:creator", content= options.creator) | |
if options.title | |
meta(name="twitter:title", content= options.title) | |
if options.description | |
meta(name="twitter:description", content= options.description) | |
if options.url | |
meta(name="twitter:url", content= options.url) | |
if options.images.length > 0 | |
-cnt = 0 | |
each image in options.images | |
meta(name="twitter:image"+cnt.toString(), content= image) | |
- cnt++ |
This file contains 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
mixin twittercard_photo(options) | |
meta(name="twitter:card",content="photo") | |
if options.site | |
meta(name="twitter:site", content= options.site) | |
if options.title | |
meta(name="twitter:title", content= options.title) | |
if options.url | |
meta(name="twitter:url", content= options.url) | |
if options.image | |
meta(name="twitter:image", content= options.image) | |
if options.width | |
meta(name="twitter:image:width", content= options.width) | |
if options.height | |
meta(name="twitter:image:height", content= options.height) |
This file contains 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
mixin twittercard_product(options) | |
meta(name="twitter:card",content="product") | |
if options.site | |
meta(name="twitter:site", content= options.site) | |
if options.creator | |
meta(name="twitter:creator", content= options.creator) | |
if options.title | |
meta(name="twitter:title", content= options.title) | |
if options.image | |
meta(name="twitter:image", content= options.image) | |
if options.width | |
meta(name="twitter:image:width", content= options.width) | |
if options.height | |
meta(name="twitter:image:height", content= options.height) | |
if options.label1 | |
meta(name="twitter:label1", content= options.label1) | |
if options.data1 | |
meta(name="twitter:data1", content= options.data1) | |
if options.label2 | |
meta(name="twitter:label2", content= options.label2) | |
if options.data2 | |
meta(name="twitter:data2", content= options.data2) |
This file contains 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
mixin twittercard_summarylarge(options) | |
meta(name="twitter:card",content="summary_large_image") | |
if options.site | |
meta(name="twitter:site", content= options.site) | |
if options.creator | |
meta(name="twitter:creator", content= options.creator) | |
if options.title | |
meta(name="twitter:title", content= options.title) | |
if options.description | |
meta(name="twitter:description", content= options.description) | |
if options.image | |
meta(name="twitter:image", content= options.image) | |
if options.alt | |
meta(name="twitter:image:alt", content= options.alt) |
This file contains 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
mixin twittercard_summary(options) | |
meta(name="twitter:card",content="summary") | |
if options.site | |
meta(name="twitter:site", content= options.site) | |
if options.title | |
meta(name="twitter:title", content= options.title) | |
if options.description | |
meta(name="twitter:description", content= options.description) | |
if options.image | |
meta(name="twitter:image", content= options.image) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment