//=include clipboard/dist/clipboard.js document.addEventListener('DOMContentLoaded', (event) => { // Clipboard button const clipboardImage = '' const successImage = '' const clipboardButton = `` const codeBlocks = document.querySelectorAll('div.highlighter-rouge') codeBlocks.forEach(codeBlock => { const language = codeBlock.className.split(' ')[0].replace('language-', '') codeBlock.insertAdjacentHTML('afterbegin', `
${language}
`) const pre = codeBlock.querySelectorAll('div.highlight')[0] pre.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() }) }) })