This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-site.git
The following commit(s) were added to refs/heads/main by this push:
new a8f8ae6 make `giscus` comment section opt-in to comply with ASF
policy (#106)
a8f8ae6 is described below
commit a8f8ae68d3791f84a93df6caca20b7c60909d0ca
Author: Kevin Liu <[email protected]>
AuthorDate: Mon Sep 8 10:23:18 2025 -0700
make `giscus` comment section opt-in to comply with ASF policy (#106)
* make giscus opt-in to comply with ASF policy
* new line
* Update content/theme/templates/comments.html
Co-authored-by: Andrew Lamb <[email protected]>
* typo
---------
Co-authored-by: Andrew Lamb <[email protected]>
---
content/js/giscus-consent.js | 102 ++++++++++++++++++++++++++++++++++
content/theme/templates/comments.html | 50 +++++++++--------
2 files changed, 129 insertions(+), 23 deletions(-)
diff --git a/content/js/giscus-consent.js b/content/js/giscus-consent.js
new file mode 100644
index 0000000..e675281
--- /dev/null
+++ b/content/js/giscus-consent.js
@@ -0,0 +1,102 @@
+(() => {
+ const container = document.getElementById('comment-thread');
+ const btnLoad = document.getElementById('giscus-load');
+ const btnRevoke = document.getElementById('giscus-revoke');
+ const consentKey = 'apache_datafusion_giscus_consent';
+
+ if (!container || !btnLoad || !btnRevoke) return;
+
+ // Giscus configuration
+ //
+ // <script src="https://giscus.app/client.js"
+ // data-repo="apache/datafusion-site"
+ // data-repo-id="R_kgDOL8FTzw"
+ // data-category="Announcements"
+ // data-category-id="DIC_kwDOL8FTz84Csqua"
+ // data-mapping="title"
+ // data-strict="1"
+ // data-reactions-enabled="1"
+ // data-emit-metadata="0"
+ // data-input-position="bottom"
+ // data-theme="light"
+ // data-lang="en"
+ // data-loading="lazy"
+ // crossorigin="anonymous"
+ // async>
+ // </script>
+
+ function injectGiscus() {
+ // Avoid double-injection if already present
+ if (document.querySelector('script[data-giscus]') ||
+ container.querySelector('iframe.giscus-frame')) {
+ btnLoad.hidden = true;
+ btnRevoke.hidden = false;
+ return;
+ }
+
+ btnLoad.disabled = true;
+
+ const s = document.createElement('script');
+ s.setAttribute('data-giscus', ''); // marker attribute to identify the
script
+ s.src = 'https://giscus.app/client.js';
+ s.setAttribute('data-repo', 'apache/datafusion-site');
+ s.setAttribute('data-repo-id', 'R_kgDOL8FTzw');
+ s.setAttribute('data-category', 'Announcements');
+ s.setAttribute('data-category-id', 'DIC_kwDOL8FTz84Csqua');
+ s.setAttribute('data-mapping', 'title');
+ s.setAttribute('data-strict', '1');
+ s.setAttribute('data-reactions-enabled', '1');
+ s.setAttribute('data-emit-metadata', '0');
+ s.setAttribute('data-input-position', 'bottom');
+ s.setAttribute('data-theme', 'light');
+ s.setAttribute('data-lang', 'en');
+ s.setAttribute('data-loading', 'lazy');
+ s.crossOrigin = 'anonymous';
+ s.async = true;
+
+ s.addEventListener('error', () => {
+ btnLoad.disabled = false;
+ });
+
+ const observer = new MutationObserver(() => {
+ if (container.querySelector('iframe.giscus-frame')) {
+ btnLoad.hidden = true;
+ btnRevoke.hidden = false;
+ btnLoad.disabled = false;
+ observer.disconnect();
+ }
+ });
+ observer.observe(container, { childList: true, subtree: true });
+
+ container.appendChild(s);
+ }
+
+ function removeGiscus() {
+ container.querySelectorAll('iframe.giscus-frame').forEach((el) =>
el.remove());
+ container.querySelectorAll('.giscus').forEach((el) => el.remove());
+ document.querySelectorAll('script[data-giscus],
script[src^="https://giscus.app"]').forEach((el) => el.remove());
+ container.replaceChildren();
+
+ btnLoad.hidden = false;
+ btnLoad.disabled = false;
+ btnRevoke.hidden = true;
+ }
+
+ btnLoad.addEventListener('click', () => {
+ try { localStorage.setItem(consentKey, 'true'); } catch {}
+ injectGiscus();
+ });
+
+ btnRevoke.addEventListener('click', () => {
+ try { localStorage.removeItem(consentKey); } catch {}
+ removeGiscus();
+ });
+
+ try {
+ if (localStorage.getItem(consentKey) === 'true') {
+ injectGiscus();
+ }
+ } catch {
+ // Storage unavailable; require click each time.
+ }
+})();
diff --git a/content/theme/templates/comments.html
b/content/theme/templates/comments.html
index abdca9a..2e74571 100644
--- a/content/theme/templates/comments.html
+++ b/content/theme/templates/comments.html
@@ -1,26 +1,30 @@
- <!--
- Enable giscuss comments: Allows comments on the blogs posted as
- https://github.com/apache/datafusion-site/discussions
+<!--
+ Comments Section
+ Loaded only after explicit visitor consent to comply with ASF policy.
+-->
- More details on https://github.com/apache/datafusion-site/issues/80
- -->
- <div id="article_comments">
- <div id="comment_thread"></div>
+<div id="comments">
+ <hr>
+ <h3>Comments</h3>
- <script src="https://giscus.app/client.js"
- data-repo="apache/datafusion-site"
- data-repo-id="R_kgDOL8FTzw"
- data-category="Announcements"
- data-category-id="DIC_kwDOL8FTz84Csqua"
- data-mapping="title"
- data-strict="1"
- data-reactions-enabled="1"
- data-emit-metadata="0"
- data-input-position="bottom"
- data-theme="preferred_color_scheme"
- data-lang="en"
- data-loading="lazy"
- crossorigin="anonymous"
- async>
- </script>
+ <!-- Local loader script -->
+ <script src="/content/js/giscus-consent.js" defer></script>
+
+ <!-- Consent UI -->
+ <div id="giscus-consent">
+ <p>
+ We use <a href="https://giscus.app/">Giscus</a> for comments, powered
by GitHub Discussions.
+ To respect your privacy, Giscus and comments will load only if you
click "Show Comments"
+ </p>
+
+ <div class="consent-actions">
+ <button id="giscus-load" type="button">Show Comments</button>
+ <button id="giscus-revoke" type="button" hidden>Hide Comments</button>
</div>
+
+ <noscript>JavaScript is required to load comments from Giscus.</noscript>
+ </div>
+
+ <!-- Container where Giscus will render -->
+ <div id="comment-thread"></div>
+</div>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]