From 778ebdf25077093f80ed6661fff298ba36b19797 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Mon, 29 Apr 2024 03:25:26 +0800 Subject: [PATCH] chore: delete JS comments from HTML --- _includes/comments/disqus.html | 6 +++--- _includes/comments/giscus.html | 2 +- _includes/comments/utterances.html | 6 +++--- _includes/mermaid.html | 10 ++++++---- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/_includes/comments/disqus.html b/_includes/comments/disqus.html index bef843a..2b889a4 100644 --- a/_includes/comments/disqus.html +++ b/_includes/comments/disqus.html @@ -10,7 +10,7 @@ this.page.identifier = '{{ page.url }}'; }; - /* Lazy loading */ + {%- comment -%} Lazy loading {%- endcomment -%} var disqus_observer = new IntersectionObserver( function (entries) { if (entries[0].isIntersecting) { @@ -30,10 +30,10 @@ disqus_observer.observe(document.getElementById('disqus_thread')); - /* Auto switch theme */ + {%- comment -%} Auto switch theme {%- endcomment -%} function reloadDisqus() { if (event.source === window && event.data && event.data.direction === ModeToggle.ID) { - /* Disqus hasn't been loaded */ + {%- comment -%} Disqus hasn't been loaded {%- endcomment -%} if (typeof DISQUS === 'undefined') { return; } diff --git a/_includes/comments/giscus.html b/_includes/comments/giscus.html index f3b8a54..c8d48e6 100644 --- a/_includes/comments/giscus.html +++ b/_includes/comments/giscus.html @@ -47,7 +47,7 @@ event.data && event.data.direction === ModeToggle.ID ) { - /* global theme mode changed */ + {%- comment -%} global theme mode changed {%- endcomment -%} const mode = event.data.message; const theme = mode === ModeToggle.DARK_MODE ? darkTheme : lightTheme; diff --git a/_includes/comments/utterances.html b/_includes/comments/utterances.html index 84818be..5dd78ed 100644 --- a/_includes/comments/utterances.html +++ b/_includes/comments/utterances.html @@ -25,12 +25,12 @@ addEventListener('message', (event) => { let theme; - /* credit to */ + {%- comment -%} credit to {%- endcomment -%} if (event.origin === origin) { - /* page initial */ + {%- comment -%} page initial {%- endcomment -%} theme = initTheme; } else if (event.source === window && event.data && event.data.direction === ModeToggle.ID) { - /* global theme mode changed */ + {%- comment -%} global theme mode changed {%- endcomment -%} const mode = event.data.message; theme = mode === ModeToggle.DARK_MODE ? darkTheme : lightTheme; } else { diff --git a/_includes/mermaid.html b/_includes/mermaid.html index 72dcacb..a3a83ed 100644 --- a/_includes/mermaid.html +++ b/_includes/mermaid.html @@ -11,7 +11,9 @@ let expectedTheme = mode === ModeToggle.DARK_MODE ? 'dark' : 'default'; let config = { theme: expectedTheme }; - /* Re-render the SVG › */ + {%- comment -%} + Re-render the SVG › + {%- endcomment -%} const mermaidList = document.getElementsByClassName('mermaid'); [...mermaidList].forEach((elem) => { @@ -37,16 +39,16 @@ } let mermaidConf = { - theme: initTheme /* */ + theme: initTheme {%- comment -%} {%- endcomment -%} }; - /* Create mermaid tag */ + {%- comment -%} Create mermaid tag {%- endcomment -%} const basicList = document.getElementsByClassName('language-mermaid'); [...basicList].forEach((elem) => { const svgCode = elem.textContent; const backup = elem.parentElement; backup.classList.add('d-none'); - /* create mermaid node */ + {%- comment -%} create mermaid node {%- endcomment -%} let mermaid = document.createElement('pre'); mermaid.classList.add('mermaid'); const text = document.createTextNode(svgCode);