UNPKG

embed-plugin-facebook

Version:

An embed-js plugin to embed facebook posts and videos.

28 lines (22 loc) 974 B
'use strict'; function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var extend = _interopDefault(require('just-extend')); var embedPluginUtilities = require('embed-plugin-utilities'); var base = _interopDefault(require('embed-plugin-base')); const id = "facebook"; function facebook(opts) { const defaultOptions = { id, regex: /(https?:\/\/)?www\.facebook\.com\/(?:(videos|posts)\.php\?v=\d+|.*?\/(videos|posts)\/\d+\/?)/gi, height: 225, template(args, options, {height}) { const url = args[0]; const type = url.indexOf("/videos/") < 0 ? "post" : "video"; return embedPluginUtilities.withoutDetailsTemplate(`https://www.facebook.com/plugins/${type}.php?href=${url}`, height, id); } }; const pluginOptions = extend({}, defaultOptions, opts); return base(pluginOptions); } facebook.id = id; module.exports = facebook;