fix: ensure code exists inside pre before adding clipboard
This commit is contained in:
parent
981f1d2b73
commit
63a81aa371
@ -7,6 +7,7 @@ document.addEventListener("nav", () => {
|
||||
const els = document.getElementsByTagName("pre")
|
||||
for (let i = 0; i < els.length; i++) {
|
||||
const codeBlock = els[i].getElementsByTagName("code")[0]
|
||||
if (codeBlock) {
|
||||
const source = codeBlock.innerText.replace(/\n\n/g, "\n")
|
||||
const button = document.createElement("button")
|
||||
button.className = "clipboard-button"
|
||||
@ -28,4 +29,5 @@ document.addEventListener("nav", () => {
|
||||
})
|
||||
els[i].prepend(button)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user