Skip to content

Commit

Permalink
audio embed
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeepgera23 committed Nov 16, 2023
1 parent 779a4fb commit fd3189b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions blocks/audio-embed/audio-embed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function extractContainerId(url) {
const urlObj = new URL(url);
const params = new URLSearchParams(urlObj.search);
return params.get('container_id');
}

export default function decorate(block) {
const anchorLink = block.querySelector('a').href;
const containerId = extractContainerId(anchorLink);
const divElement = document.createElement('div');
divElement.setAttribute('id', containerId);
const scriptTag = document.createElement('script');
scriptTag.src = anchorLink;
divElement.appendChild(scriptTag);
block.innerHTML = '';
block.append(divElement);
}

0 comments on commit fd3189b

Please sign in to comment.