diff options
| author | Alejandro Soto <alejandro@34project.org> | 2025-09-13 15:01:06 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2025-09-13 15:01:06 -0600 |
| commit | f4fcda54638685899c730b3fa90a87d80d6dbef5 (patch) | |
| tree | 0737e627cce304c3a9c4e757bc5f6571a7456091 /sysret.org/themes/tabi-lean/static/js/hyvortalk.js | |
| parent | d8b9cf1f61cc07d625f1c37ccc28adfd58918416 (diff) | |
| parent | 2c13119932765c6d788f08fb53abc244407c0d80 (diff) | |
Merge commit '6a7d3111b31e73fc66af5360149d41f690fbcaa4'
Diffstat (limited to 'sysret.org/themes/tabi-lean/static/js/hyvortalk.js')
| -rw-r--r-- | sysret.org/themes/tabi-lean/static/js/hyvortalk.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/sysret.org/themes/tabi-lean/static/js/hyvortalk.js b/sysret.org/themes/tabi-lean/static/js/hyvortalk.js new file mode 100644 index 0000000..3f9959d --- /dev/null +++ b/sysret.org/themes/tabi-lean/static/js/hyvortalk.js @@ -0,0 +1,44 @@ +function initHyvorTalk() { + // Get the div that will contain the comments. + const commentsDiv = document.querySelector('.comments'); + if (commentsDiv) { + // Get the various settings from data attributes on the div. + const websiteId = commentsDiv.getAttribute('data-website-id'); + const pageId = commentsDiv.getAttribute('data-page-id'); + const pageLanguage = commentsDiv.getAttribute('data-page-language'); + const loading = commentsDiv.getAttribute('data-loading'); + const pageAuthor = commentsDiv.getAttribute('data-page-author'); + + // Create a new script tag that will load the Hyvor Talk script. + const script = document.createElement('script'); + script.src = 'https://talk.hyvor.com/embed/embed.js'; + script.async = true; + script.type = 'module'; + document.head.appendChild(script); + + // Create a new Hyvor Talk comments tag. + const comments = document.createElement('hyvor-talk-comments'); + comments.setAttribute('website-id', websiteId); + comments.setAttribute('page-id', pageId); + comments.setAttribute('page-language', pageLanguage); + comments.setAttribute('loading', loading); + comments.setAttribute('page-author', pageAuthor); + + // Choose the correct theme based on the current theme of the document. + const currentTheme = + document.documentElement.getAttribute('data-theme') || 'light'; + comments.setAttribute('colors', currentTheme); + + // Add the Hyvor Talk comments tag to the div. + commentsDiv.appendChild(comments); + + // Listen for theme changes and update the Hyvor Talk theme when they occur. + window.addEventListener('themeChanged', (event) => { + const selectedTheme = event.detail.theme; + comments.setAttribute('colors', selectedTheme); + }); + } +} + +// Initialize HyvorTalk. +initHyvorTalk(); |
