1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2026-06-29 20:06:00 -04:00

bump some deps and fix some lints

This commit is contained in:
2021-11-22 10:52:02 -05:00
parent d8a552cf5a
commit be7b2a4bba
9 changed files with 93 additions and 107 deletions
+9 -9
View File
@@ -11,20 +11,20 @@ document.querySelectorAll("div.highlight").forEach((highlightDiv) => {
const button = document.createElement("button");
button.className = "copy-button";
button.textContent = defaultText;
button.addEventListener("click", () => {
button.addEventListener("click", async () => {
// prevent unintentional double-clicks by unfocusing button
button.blur();
// actual code element will have class "language-*", even if plaintext
if (copy(trimNewlines(highlightDiv.querySelector('code[class^="language-"]').textContent))) {
// show a subtle indication of success
button.textContent = successText;
await copy(trimNewlines(highlightDiv.querySelector('code[class^="language-"]').textContent));
// reset button to original text after 2 seconds
setTimeout(() => {
button.textContent = defaultText;
}, 2000);
}
// show a subtle indication of success
button.textContent = successText;
// reset button to original text after 2 seconds
setTimeout(() => {
button.textContent = defaultText;
}, 2000);
});
// add Hugo's code block to a new wrapper element, and insert the copy button as a sibling to it