Skip to content

Commit

Permalink
fix: remove inline script usage (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxys authored May 24, 2021
1 parent 55adadd commit 29b1076
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
6 changes: 1 addition & 5 deletions layouts/partials/foot.html
Original file line number Diff line number Diff line change
@@ -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 }}
8 changes: 1 addition & 7 deletions layouts/shortcodes/mermaid.html
Original file line number Diff line number Diff line change
@@ -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 }}

Expand Down
3 changes: 3 additions & 0 deletions src/js/clipboard-loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
document.addEventListener("DOMContentLoaded", function (event) {
var clipboard = new ClipboardJS(".clip");
});
13 changes: 13 additions & 0 deletions src/js/mermaid-loader.js
Original file line number Diff line number Diff line change
@@ -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,
},
});
});

0 comments on commit 29b1076

Please sign in to comment.