🐛 fix(hyvor-talk): switch from ID to class selector for initialisation (#196)

main
Óscar Fernández 1 year ago committed by GitHub
parent 228f1ea6e5
commit 040a46dc4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,6 @@
function initHyvorTalk() { function initHyvorTalk() {
// Get the div that will contain the comments. // Get the div that will contain the comments.
const commentsDiv = document.querySelector('#comments'); const commentsDiv = document.querySelector('.comments');
if (commentsDiv) { if (commentsDiv) {
// Get the various settings from data attributes on the div. // Get the various settings from data attributes on the div.
const websiteId = commentsDiv.getAttribute('data-website-id'); const websiteId = commentsDiv.getAttribute('data-website-id');

@ -1 +1 @@
function initHyvorTalk(){var t=document.querySelector("#comments");if(t){var e=t.getAttribute("data-website-id"),a=t.getAttribute("data-page-id"),i=t.getAttribute("data-page-language"),d=t.getAttribute("data-loading"),r=t.getAttribute("data-page-author"),n=document.createElement("script");n.src="https://talk.hyvor.com/embed/embed.js",n.async=!0,n.type="module",document.head.appendChild(n);const o=document.createElement("hyvor-talk-comments");o.setAttribute("website-id",e),o.setAttribute("page-id",a),o.setAttribute("page-language",i),o.setAttribute("loading",d),o.setAttribute("page-author",r);n=document.documentElement.getAttribute("data-theme")||"light";o.setAttribute("colors",n),t.appendChild(o),window.addEventListener("themeChanged",t=>{t=t.detail.theme;o.setAttribute("colors",t)})}}initHyvorTalk(); function initHyvorTalk(){var t=document.querySelector(".comments");if(t){var e=t.getAttribute("data-website-id"),a=t.getAttribute("data-page-id"),i=t.getAttribute("data-page-language"),d=t.getAttribute("data-loading"),r=t.getAttribute("data-page-author"),n=document.createElement("script");n.src="https://talk.hyvor.com/embed/embed.js",n.async=!0,n.type="module",document.head.appendChild(n);const o=document.createElement("hyvor-talk-comments");o.setAttribute("website-id",e),o.setAttribute("page-id",a),o.setAttribute("page-language",i),o.setAttribute("loading",d),o.setAttribute("page-author",r);n=document.documentElement.getAttribute("data-theme")||"light";o.setAttribute("colors",n),t.appendChild(o),window.addEventListener("themeChanged",t=>{t=t.detail.theme;o.setAttribute("colors",t)})}}initHyvorTalk();

Loading…
Cancel
Save