UNPKG

gatsby-remark-embedder

Version:

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

19 lines (18 loc) 550 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.shouldTransform = exports.getHTML = void 0; const shouldTransform = url => { const { host, pathname } = new URL(url); return ['codepen.io', 'www.codepen.io'].includes(host) && pathname.includes('/pen/'); }; exports.shouldTransform = shouldTransform; const getHTML = url => { const iframeUrl = url.replace('/pen/', '/embed/preview/'); return `<iframe src="${iframeUrl}" style="width:100%; height:300px;"></iframe>`; }; exports.getHTML = getHTML;