chore: delete JS comments from HTML
This commit is contained in:
parent
796c386037
commit
778ebdf250
4 changed files with 13 additions and 11 deletions
|
@ -10,7 +10,7 @@
|
||||||
this.page.identifier = '{{ page.url }}';
|
this.page.identifier = '{{ page.url }}';
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Lazy loading */
|
{%- comment -%} Lazy loading {%- endcomment -%}
|
||||||
var disqus_observer = new IntersectionObserver(
|
var disqus_observer = new IntersectionObserver(
|
||||||
function (entries) {
|
function (entries) {
|
||||||
if (entries[0].isIntersecting) {
|
if (entries[0].isIntersecting) {
|
||||||
|
@ -30,10 +30,10 @@
|
||||||
|
|
||||||
disqus_observer.observe(document.getElementById('disqus_thread'));
|
disqus_observer.observe(document.getElementById('disqus_thread'));
|
||||||
|
|
||||||
/* Auto switch theme */
|
{%- comment -%} Auto switch theme {%- endcomment -%}
|
||||||
function reloadDisqus() {
|
function reloadDisqus() {
|
||||||
if (event.source === window && event.data && event.data.direction === ModeToggle.ID) {
|
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') {
|
if (typeof DISQUS === 'undefined') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
event.data &&
|
event.data &&
|
||||||
event.data.direction === ModeToggle.ID
|
event.data.direction === ModeToggle.ID
|
||||||
) {
|
) {
|
||||||
/* global theme mode changed */
|
{%- comment -%} global theme mode changed {%- endcomment -%}
|
||||||
const mode = event.data.message;
|
const mode = event.data.message;
|
||||||
const theme = mode === ModeToggle.DARK_MODE ? darkTheme : lightTheme;
|
const theme = mode === ModeToggle.DARK_MODE ? darkTheme : lightTheme;
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,12 @@
|
||||||
addEventListener('message', (event) => {
|
addEventListener('message', (event) => {
|
||||||
let theme;
|
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) {
|
if (event.origin === origin) {
|
||||||
/* page initial */
|
{%- comment -%} page initial {%- endcomment -%}
|
||||||
theme = initTheme;
|
theme = initTheme;
|
||||||
} else if (event.source === window && event.data && event.data.direction === ModeToggle.ID) {
|
} 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;
|
const mode = event.data.message;
|
||||||
theme = mode === ModeToggle.DARK_MODE ? darkTheme : lightTheme;
|
theme = mode === ModeToggle.DARK_MODE ? darkTheme : lightTheme;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -11,7 +11,9 @@
|
||||||
let expectedTheme = mode === ModeToggle.DARK_MODE ? 'dark' : 'default';
|
let expectedTheme = mode === ModeToggle.DARK_MODE ? 'dark' : 'default';
|
||||||
let config = { theme: expectedTheme };
|
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');
|
const mermaidList = document.getElementsByClassName('mermaid');
|
||||||
|
|
||||||
[...mermaidList].forEach((elem) => {
|
[...mermaidList].forEach((elem) => {
|
||||||
|
@ -37,16 +39,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
let mermaidConf = {
|
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');
|
const basicList = document.getElementsByClassName('language-mermaid');
|
||||||
[...basicList].forEach((elem) => {
|
[...basicList].forEach((elem) => {
|
||||||
const svgCode = elem.textContent;
|
const svgCode = elem.textContent;
|
||||||
const backup = elem.parentElement;
|
const backup = elem.parentElement;
|
||||||
backup.classList.add('d-none');
|
backup.classList.add('d-none');
|
||||||
/* create mermaid node */
|
{%- comment -%} create mermaid node {%- endcomment -%}
|
||||||
let mermaid = document.createElement('pre');
|
let mermaid = document.createElement('pre');
|
||||||
mermaid.classList.add('mermaid');
|
mermaid.classList.add('mermaid');
|
||||||
const text = document.createTextNode(svgCode);
|
const text = document.createTextNode(svgCode);
|
||||||
|
|
Loading…
Reference in a new issue