From da681562ad550b5ca74e6f997aaf28b8bcb7eb91 Mon Sep 17 00:00:00 2001 From: John Bowdre Date: Thu, 9 Nov 2023 21:57:47 -0600 Subject: [PATCH] fix attribution --- assets/css/code-copy-button.css | 2 +- assets/js/code-copy-button.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/css/code-copy-button.css b/assets/css/code-copy-button.css index abd37c8..a96ab94 100644 --- a/assets/css/code-copy-button.css +++ b/assets/css/code-copy-button.css @@ -1,4 +1,4 @@ -/* adapted from https://aaronluna.dev/blog/add-copy-button-to-code-blocks-hugo-chroma/ */ +/* adapted from https://digitaldrummerj.me/hugo-add-copy-code-snippet-button/ */ .highlight { position: relative; diff --git a/assets/js/code-copy-button.js b/assets/js/code-copy-button.js index cff2619..80ae37c 100644 --- a/assets/js/code-copy-button.js +++ b/assets/js/code-copy-button.js @@ -1,4 +1,4 @@ -// adapted from https://aaronluna.dev/blog/add-copy-button-to-code-blocks-hugo-chroma/ +// adapted from https://digitaldrummerj.me/hugo-add-copy-code-snippet-button/ function createCopyButton(highlightDiv) { const button = document.createElement("button"); @@ -18,7 +18,7 @@ document.querySelectorAll(".highlight").forEach((highlightDiv) => createCopyButt async function copyCodeToClipboard(button, highlightDiv) { // capture all code lines in the selected block which aren't classed `nocopy` or `line-remove` let codeToCopy = highlightDiv.querySelectorAll(":last-child > .torchlight > code > .line:not(.nocopy, .line-remove)"); - // now remove the first-child of each line which has class `line-number` + // now remove the first-child of each line with class `line-number` codeToCopy = Array.from(codeToCopy).reduce((accumulator, line) => { if (line.firstChild.className != "line-number") { return accumulator + line.innerText + "\n"; }