summaryrefslogtreecommitdiffstats
path: root/assets/js/copy-code.js
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-04-22 12:42:56 +0200
committerDanilo M. <danix@danix.xyz>2026-04-22 12:42:56 +0200
commit631547a75142326a7c71bdf123e1475217a5ad73 (patch)
treef3cfef6b3c5b42bf626fc823ddcf63b8dcf4cdbb /assets/js/copy-code.js
parent77ccbe72fad5a4870185fff374f75471c16a9043 (diff)
downloaddanixxyz-theme-631547a75142326a7c71bdf123e1475217a5ad73.tar.gz
danixxyz-theme-631547a75142326a7c71bdf123e1475217a5ad73.zip
chore: replace with extracted danix.xyz-hacker theme (danix2-hugo-theme)
Diffstat (limited to 'assets/js/copy-code.js')
-rw-r--r--assets/js/copy-code.js42
1 files changed, 0 insertions, 42 deletions
diff --git a/assets/js/copy-code.js b/assets/js/copy-code.js
deleted file mode 100644
index a18bf6c..0000000
--- a/assets/js/copy-code.js
+++ /dev/null
@@ -1,42 +0,0 @@
-// copy-code.js
-(function() {
- // Add copy button to all code blocks
- const codeBlocks = document.querySelectorAll('pre, .highlight');
-
- codeBlocks.forEach(block => {
- // Create copy button
- const btn = document.createElement('button');
- btn.className = 'code-copy-btn';
- btn.textContent = 'copy';
- btn.type = 'button';
- btn.setAttribute('aria-label', 'Copy code');
-
- // Get code text
- const code = block.querySelector('code');
- const text = code ? code.textContent : block.textContent;
-
- // Copy on click
- btn.addEventListener('click', async function() {
- try {
- await navigator.clipboard.writeText(text);
-
- // Show feedback
- const originalText = btn.textContent;
- btn.textContent = 'copied!';
- btn.classList.add('copied');
-
- setTimeout(() => {
- btn.textContent = originalText;
- btn.classList.remove('copied');
- }, 2000);
- } catch (err) {
- console.error('Failed to copy:', err);
- btn.textContent = 'error';
- }
- });
-
- // Add button to block
- block.style.position = 'relative';
- block.appendChild(btn);
- });
-})();