iframely
Version:
oEmbed/2 gateway endpoint. Get embed data for various http links through one self-hosted API
25 lines (22 loc) • 833 B
JavaScript
export default {
getMeta: function(oembed) {
if (oembed.price) { // non-shopify products, per pinterest spec
return {
price: oembed.price && parseFloat(oembed.price),
currency: oembed.currency_code || oembed.currency,
brand: oembed.brand,
availability: oembed.availability,
medium: 'product'
}
} else if (oembed.offers && oembed.offers.length > 0) { // shopify
var offer = oembed.offers[0]; // let's take the first one
return {
price: offer.price && parseFloat(offer.price),
currency: offer.currency_code,
offers: oembed.offers,
brand: oembed.brand,
medium: 'product'
};
}
}
};