Skip to content

Commit

Permalink
chore: delete JS comments from HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
cotes2020 committed Apr 28, 2024
1 parent 796c386 commit 778ebdf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions _includes/comments/disqus.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion _includes/comments/giscus.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions _includes/comments/utterances.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
addEventListener('message', (event) => {
let theme;

/* credit to <https://github.com/utterance/utterances/issues/170#issuecomment-594036347> */
{%- comment -%} credit to <https://github.com/utterance/utterances/issues/170#issuecomment-594036347> {%- 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 {
Expand Down
10 changes: 6 additions & 4 deletions _includes/mermaid.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
let expectedTheme = mode === ModeToggle.DARK_MODE ? 'dark' : 'default';
let config = { theme: expectedTheme };

/* Re-render the SVG › <https://github.com/mermaid-js/mermaid/issues/311#issuecomment-332557344> */
{%- comment -%}
Re-render the SVG <https://github.com/mermaid-js/mermaid/issues/311#issuecomment-332557344>
{%- endcomment -%}
const mermaidList = document.getElementsByClassName('mermaid');

[...mermaidList].forEach((elem) => {
Expand All @@ -37,16 +39,16 @@
}

let mermaidConf = {
theme: initTheme /* <default | dark | forest | neutral> */
theme: initTheme {%- comment -%} <default | dark | forest | neutral> {%- 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);
Expand Down

0 comments on commit 778ebdf

Please sign in to comment.