//=include clipboard/dist/clipboard.js document.addEventListener('DOMContentLoaded', (event) => { // Clipboard button const clipboardImage = '' const successImage = '' const clipboardButton = `` const codeBlocks = document.querySelectorAll('.highlight') codeBlocks.forEach(codeBlock => { codeBlock.insertAdjacentHTML('afterbegin', clipboardButton) }) const buttons = document.querySelectorAll('.highlight .btn--clipboard') buttons.forEach(button => { const clipboard = new ClipboardJS(button, { target: (trigger) => { return trigger.nextElementSibling; } }) clipboard.on('success', e => { e.trigger.classList.add('success') e.trigger.innerHTML = successImage e.trigger.insertAdjacentHTML('afterend', 'Copied to clipboard') e.clearSelection() }) }) })