fix: remove inline script usage (#49)

This commit is contained in:
Robert Kaussow 2021-05-24 15:11:36 +02:00 committed by GitHub
parent 55adaddc30
commit 29b10769b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 12 deletions

View File

@ -1,8 +1,4 @@
{{ if default true .Site.Params.GeekblogAnchorCopy }}
<script defer src="{{ index .Site.Data.assets "js/clipboard.min.js" | relURL }}"></script>
<script>
document.addEventListener("DOMContentLoaded", function(event) {
var clipboard = new ClipboardJS('.clip');
});
</script>
<script defer src="{{ index .Site.Data.assets "js/clipboard-loader.min.js" | relURL }}"></script>
{{ end }}

View File

@ -1,13 +1,7 @@
{{ if not (.Page.Scratch.Get "mermaid") }}
<!-- Include mermaid only first time -->
<script defer src="{{ index .Site.Data.assets "js/mermaid.min.js" | relURL }}"></script>
<script>
document.addEventListener("DOMContentLoaded", function(event) {
mermaid.initialize({
flowchart: { useMaxWidth: true }
});
});
</script>
<script defer src="{{ index .Site.Data.assets "js/mermaid-loader.min.js" | relURL }}"></script>
{{ .Page.Scratch.Set "mermaid" true }}
{{ end }}

View File

@ -0,0 +1,3 @@
document.addEventListener("DOMContentLoaded", function (event) {
var clipboard = new ClipboardJS(".clip");
});

13
src/js/mermaid-loader.js Normal file
View File

@ -0,0 +1,13 @@
document.addEventListener("DOMContentLoaded", function (event) {
let primaryColor = "#ececff";
let darkMode = false;
mermaid.initialize({
flowchart: { useMaxWidth: true },
theme: "base",
themeVariables: {
darkMode: darkMode,
primaryColor: primaryColor,
},
});
});