hugo-geekblog/src/js/app.js
Robert Kaussow d5f6cfb13e
refator: replace gulp by webpack and npm scripts (#129)
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.
2021-12-29 22:50:13 +01:00

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))
})