From b4019091a647a7258cc5bb35d46a78aecd54ba4b Mon Sep 17 00:00:00 2001 From: Jack Hickey <133868041+nginx-jack@users.noreply.github.com> Date: Tue, 25 Mar 2025 15:26:30 +0000 Subject: [PATCH] CodeCopy: Pass codeBlockId via function call Pass codeBlockId via function call instead of pulling from a data attribute. Reduces code complexity a tiny bit. --- assets/js/code-copy-v2.js | 3 +-- .../_default/_markup/render-codeblock.html | 4 ++-- .../example-site-screenshot.png | Bin 3090775 -> 3136762 bytes .../example-site-screenshot.png | Bin 4682609 -> 4850926 bytes .../example-site-screenshot.png | Bin 4455124 -> 4569311 bytes 5 files changed, 3 insertions(+), 4 deletions(-) diff --git a/assets/js/code-copy-v2.js b/assets/js/code-copy-v2.js index d1fe2c7..023032a 100644 --- a/assets/js/code-copy-v2.js +++ b/assets/js/code-copy-v2.js @@ -1,6 +1,5 @@ // Tightly coupled to `render-codeblock.html` for element targeting -const copyToClipBoard = ((clipboard) => async (button) => { - const codeBlockId = button.getAttribute('data-id-codeblock'); +const copyToClipBoard = ((clipboard) => async (button, codeBlockId) => { const codeBlock = document .getElementById(codeBlockId) .getElementsByClassName('highlight')[0]; diff --git a/layouts/_default/_markup/render-codeblock.html b/layouts/_default/_markup/render-codeblock.html index 657c92b..00350d8 100644 --- a/layouts/_default/_markup/render-codeblock.html +++ b/layouts/_default/_markup/render-codeblock.html @@ -6,7 +6,7 @@ {{- if $isSingleLine -}}