Sha256: c7ce281acf931123ed57191e248fc6cedcd7428e5a3b811da1fa7c7abc568bf4
Contents?: true
Size: 869 Bytes
Versions: 4
Compression:
Stored size: 869 Bytes
Contents
export default function oEmbed(elements) { if (!elements) return; // Ensure elements is an array-like collection elements = elements instanceof NodeList ? Array.from(elements) : [elements]; elements.forEach(function(embedViewer) { const embedURL = embedViewer.dataset.embedUrl; // Get the embed URL from the data attribute if (!embedURL) return; // Fetch JSON data from the embed URL fetch(embedURL) .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then(data => { if (data === null) { return; } // Set the inner HTML of the element embedViewer.innerHTML = data.html; }) .catch(error => { console.error('Error fetching embed data:', error); }); }); }
Version data entries
4 entries across 4 versions & 1 rubygems