UNPKG

gatsby-remark-embedder

Version:

Gatsby Remark plugin to embed well known services by their URL.

23 lines (22 loc) 716 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.shouldTransform = exports.name = exports.getHTML = void 0; var _utils = require("./utils"); const shouldTransform = url => { const { host, pathname } = new URL(url); return ['instagr.am', 'www.instagr.am', 'instagram.com', 'www.instagram.com'].includes(host) && pathname.includes('/p/'); }; exports.shouldTransform = shouldTransform; const getHTML = (url, { accessToken }) => (0, _utils.fetchOEmbedData)(`https://graph.facebook.com/v8.0/instagram_oembed?url=${url}&access_token=${accessToken}&omitscript=true`).then(({ html }) => html); exports.getHTML = getHTML; const name = 'Instagram'; exports.name = name;