-
Notifications
You must be signed in to change notification settings - Fork 1
/
_utterances.html
29 lines (26 loc) · 1.15 KB
/
_utterances.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!-- Adapted from https://github.com/MilesMcBain/milesmcbain.com/blob/master/utterances.html and https://github.com/rstudio/distill/issues/155#issuecomment-694296957 -->
<script>
document.addEventListener("DOMContentLoaded", function () {
if (!/posts/.test(location.pathname)) {
return;
}
var script = document.createElement("script");
script.src = "https://utteranc.es/client.js";
script.setAttribute("repo", "mikemc/qmm");
script.setAttribute("issue-term", "pathname");
script.setAttribute("crossorigin", "anonymous");
script.setAttribute("label", "comment_thread");
/* wait for article to load, append script to article element */
var observer = new MutationObserver(function (mutations, observer) {
// change "d-appendix" to "d-article" to place between the article and appendix
var article = document.querySelector("d-appendix");
if (article) {
observer.disconnect();
/* HACK: article scroll */
article.setAttribute("style", "overflow-y: hidden");
article.appendChild(script);
}
});
observer.observe(document.body, { childList: true });
});
</script>