fix: remove inline script usage (#133)
parent
ae421f0050
commit
649e3cf752
|
@ -213,10 +213,10 @@ gulp.task("iconfont", function () {
|
|||
gulp.task("js", function () {
|
||||
return gulp
|
||||
.src(["src/js/*.js"])
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(devBuild ? sourcemaps.init() : noop())
|
||||
.pipe(uglify())
|
||||
.pipe(rename({ extname: ".min.js" }))
|
||||
.pipe(sourcemaps.write("."))
|
||||
.pipe(devBuild ? sourcemaps.write(".") : noop())
|
||||
.pipe(gulp.dest(JS_BUILD));
|
||||
});
|
||||
|
||||
|
|
|
@ -8,9 +8,5 @@
|
|||
|
||||
{{ if default true .Site.Params.GeekdocAnchorCopy }}
|
||||
<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 }}
|
||||
|
|
|
@ -1,30 +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) {
|
||||
let currentMode = localStorage.getItem(THEME);
|
||||
let darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
let primaryColor = "#ececff";
|
||||
let darkMode = false;
|
||||
|
||||
console.log(currentMode)
|
||||
|
||||
if (currentMode === DARK_MODE || (currentMode === AUTO_MODE && darkModeQuery.matches)) {
|
||||
primaryColor = "#6C617E";
|
||||
darkMode = true;
|
||||
}
|
||||
|
||||
mermaid.initialize({
|
||||
flowchart: { useMaxWidth: true },
|
||||
theme: "base",
|
||||
themeVariables: {
|
||||
darkMode: darkMode,
|
||||
primaryColor: primaryColor,
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script defer src="{{ index .Site.Data.assets "js/mermaid-loader.min.js" | relURL }}"></script>
|
||||
{{ .Page.Scratch.Set "mermaid" true }}
|
||||
{{ end }}
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
document.addEventListener("DOMContentLoaded", function (event) {
|
||||
var clipboard = new ClipboardJS(".clip");
|
||||
});
|
|
@ -0,0 +1,25 @@
|
|||
document.addEventListener("DOMContentLoaded", function (event) {
|
||||
let currentMode = localStorage.getItem(THEME);
|
||||
let darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
let primaryColor = "#ececff";
|
||||
let darkMode = false;
|
||||
|
||||
console.log(currentMode);
|
||||
|
||||
if (
|
||||
currentMode === DARK_MODE ||
|
||||
(currentMode === AUTO_MODE && darkModeQuery.matches)
|
||||
) {
|
||||
primaryColor = "#6C617E";
|
||||
darkMode = true;
|
||||
}
|
||||
|
||||
mermaid.initialize({
|
||||
flowchart: { useMaxWidth: true },
|
||||
theme: "base",
|
||||
themeVariables: {
|
||||
darkMode: darkMode,
|
||||
primaryColor: primaryColor,
|
||||
},
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue