Skip to content

Commit

Permalink
fixing position on scrolling code
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell committed Aug 2, 2024
1 parent 6c75196 commit cd77228
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
31 changes: 8 additions & 23 deletions gen/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,8 @@ function start() {
for (const allPre of allPres) {
const innerCodeBlocks = allPre.getElementsByTagName("code")

for (const innerCodeBlock of innerCodeBlocks) {
codeBlocks.push(innerCodeBlock)
}

}

const codes = []

for (const codeBlock of codeBlocks) {
console.log(codeBlock)
const code = codeBlock.innerText
console.log(code)
codes.push(code)
}

console.log(codes)

console.log("highlighting...")
hljs.highlightAll();
const code = innerCodeBlocks[0].innerText

for (let i = 0; i < codeBlocks.length; i++) {
const codeBlock = codeBlocks[i]
const code = codes[i]

const button = document.createElement("button")
button.classList.add("copy-button")
Expand All @@ -68,8 +47,14 @@ function start() {

}, false)

codeBlock.appendChild(button)
allPre.appendChild(button)

}

console.log("highlighting...")
hljs.highlightAll();




}
5 changes: 4 additions & 1 deletion gen/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,13 @@ li.dropdown.open > ul {

code {
font-weight: bold;
}

pre {
position: relative;
}

code > button {
pre > button {
position: absolute;
top: 12px;
right: 12px;
Expand Down

0 comments on commit cd77228

Please sign in to comment.