mirror of
https://github.com/jbowdre/runtimeterror.git
synced 2024-11-21 22:42:19 +00:00
fix attribution
This commit is contained in:
parent
1c98fbb2db
commit
da681562ad
2 changed files with 3 additions and 3 deletions
|
@ -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 {
|
.highlight {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
|
@ -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) {
|
function createCopyButton(highlightDiv) {
|
||||||
const button = document.createElement("button");
|
const button = document.createElement("button");
|
||||||
|
@ -18,7 +18,7 @@ document.querySelectorAll(".highlight").forEach((highlightDiv) => createCopyButt
|
||||||
async function copyCodeToClipboard(button, highlightDiv) {
|
async function copyCodeToClipboard(button, highlightDiv) {
|
||||||
// capture all code lines in the selected block which aren't classed `nocopy` or `line-remove`
|
// 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)");
|
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) => {
|
codeToCopy = Array.from(codeToCopy).reduce((accumulator, line) => {
|
||||||
if (line.firstChild.className != "line-number") {
|
if (line.firstChild.className != "line-number") {
|
||||||
return accumulator + line.innerText + "\n"; }
|
return accumulator + line.innerText + "\n"; }
|
||||||
|
|
Loading…
Reference in a new issue