feat: add more plausible events
| | |
| | | .style("cursor", "pointer") |
| | | .on("click", (_, d) => { |
| | | // SPA navigation |
| | | window.Million.navigate(new URL(`${baseUrl}${decodeURI(d.id).replace(/\s+/g, "-")}/`), ".singlePage") |
| | | const targ = `${baseUrl}${decodeURI(d.id).replace(/\s+/g, "-")}/` |
| | | window.Million.navigate(new URL(targ), ".singlePage") |
| | | plausible("Link Click", { |
| | | props: { |
| | | href: targ, |
| | | broken: false, |
| | | internal: true, |
| | | graph: true, |
| | | } |
| | | }) |
| | | }) |
| | | .on("mouseover", function (_, d) { |
| | | d3.selectAll(".node").transition().duration(100).attr("fill", "var(--g-node-inactive)") |
| | |
| | | }) |
| | | |
| | | el.classList.add("visible") |
| | | plausible("Popover Hover", { |
| | | props: { |
| | | href: li.dataset.src |
| | | } |
| | | }) |
| | | }) |
| | | li.addEventListener("mouseout", () => { |
| | | el.classList.remove("visible") |
| | |
| | | } |
| | | |
| | | const render = () => requestAnimationFrame(rerender) |
| | | |
| | | window.addEventListener("DOMContentLoaded", () => { |
| | | apply((doc) => init(doc)) |
| | | init() |
| | |
| | | ".singlePage", |
| | | ) |
| | | closeSearch() |
| | | plausible("Search", { |
| | | props: { |
| | | term |
| | | } |
| | | }) |
| | | } |
| | | |
| | | function openSearch() { |
| | |
| | | throwOnError : false |
| | | }); |
| | | {{end}} |
| | | |
| | | // analytics |
| | | function clickHandler(evt) { |
| | | const target = evt.target |
| | | const classNames = target.className.split(" ") |
| | | const broken = classNames.includes("broken") |
| | | const internal = classNames.includes("internal-link") |
| | | plausible("Link Click", { |
| | | props: { |
| | | href: target.href, |
| | | broken, |
| | | internal, |
| | | graph: false, |
| | | } |
| | | }) |
| | | } |
| | | |
| | | const links = document.querySelectorAll("a") |
| | | for (link of links) { |
| | | link.addEventListener('click', clickHandler) |
| | | link.addEventListener('auxclick', clickHandler) |
| | | } |
| | | }; |
| | | </script> |
| | | {{if $data.enableSPA | default $.Site.Data.config.enableSPA}} |
| | |
| | | {{end}} |
| | | {{ $trimmedURL := trim (index (split .Site.BaseURL "://") 1) "/" }} |
| | | <script defer data-domain="{{$trimmedURL}}" src="https://plausible.io/js/script.js"></script> |
| | | <script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script> |
| | | </head> |