mirror of
https://github.com/thegeeklab/hugo-geekblog.git
synced 2024-06-24 11:10:59 +02:00
BREAKING CHANGE: We have replaced `gulp` with `webpack` and `npm scripts` to build this theme. If you build it on your own or use build commands during the deployment, you may have to adjust your setup. BREAKING CHANGE: The `GeekblogIcons` font is using the icon name as Unicode now. As a consequence, you have to replace all references to Icons from this font if you have customized the theme.
32 lines
977 B
JavaScript
32 lines
977 B
JavaScript
import { applyTheme } from "./darkmode"
|
|
import { createCopyButton } from "./copycode.js"
|
|
|
|
import Clipboard from "clipboard"
|
|
;(() => {
|
|
applyTheme()
|
|
})()
|
|
|
|
document.addEventListener("DOMContentLoaded", function (event) {
|
|
let clipboard = new Clipboard(".clip")
|
|
|
|
clipboard.on("success", function (e) {
|
|
const trigger = e.trigger
|
|
|
|
if (trigger.hasAttribute("data-copy-feedback")) {
|
|
trigger.classList.add("gblog-post__codecopy--success")
|
|
trigger.querySelector(".icon.copy").classList.add("hidden")
|
|
trigger.querySelector(".icon.check").classList.remove("hidden")
|
|
|
|
setTimeout(function () {
|
|
trigger.classList.remove("gblog-post__codecopy--success")
|
|
trigger.querySelector(".icon.copy").classList.remove("hidden")
|
|
trigger.querySelector(".icon.check").classList.add("hidden")
|
|
}, 3000)
|
|
}
|
|
|
|
e.clearSelection()
|
|
})
|
|
|
|
document.querySelectorAll(".highlight").forEach((highlightDiv) => createCopyButton(highlightDiv))
|
|
})
|