fix: remove inline script usage (#133)
parent
ae421f0050
commit
649e3cf752
|
@ -213,10 +213,10 @@ gulp.task("iconfont", function () {
|
||||||
gulp.task("js", function () {
|
gulp.task("js", function () {
|
||||||
return gulp
|
return gulp
|
||||||
.src(["src/js/*.js"])
|
.src(["src/js/*.js"])
|
||||||
.pipe(sourcemaps.init())
|
.pipe(devBuild ? sourcemaps.init() : noop())
|
||||||
.pipe(uglify())
|
.pipe(uglify())
|
||||||
.pipe(rename({ extname: ".min.js" }))
|
.pipe(rename({ extname: ".min.js" }))
|
||||||
.pipe(sourcemaps.write("."))
|
.pipe(devBuild ? sourcemaps.write(".") : noop())
|
||||||
.pipe(gulp.dest(JS_BUILD));
|
.pipe(gulp.dest(JS_BUILD));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,5 @@
|
||||||
|
|
||||||
{{ if default true .Site.Params.GeekdocAnchorCopy }}
|
{{ if default true .Site.Params.GeekdocAnchorCopy }}
|
||||||
<script defer src="{{ index .Site.Data.assets "js/clipboard.min.js" | relURL }}"></script>
|
<script defer src="{{ index .Site.Data.assets "js/clipboard.min.js" | relURL }}"></script>
|
||||||
<script>
|
<script defer src="{{ index .Site.Data.assets "js/clipboard-loader.min.js" | relURL }}"></script>
|
||||||
document.addEventListener("DOMContentLoaded", function(event) {
|
|
||||||
var clipboard = new ClipboardJS('.clip');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -1,30 +1,7 @@
|
||||||
{{ if not (.Page.Scratch.Get "mermaid") }}
|
{{ if not (.Page.Scratch.Get "mermaid") }}
|
||||||
<!-- Include mermaid only first time -->
|
<!-- Include mermaid only first time -->
|
||||||
<script defer src="{{ index .Site.Data.assets "js/mermaid.min.js" | relURL }}"></script>
|
<script defer src="{{ index .Site.Data.assets "js/mermaid.min.js" | relURL }}"></script>
|
||||||
<script>
|
<script defer src="{{ index .Site.Data.assets "js/mermaid-loader.min.js" | relURL }}"></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>
|
|
||||||
{{ .Page.Scratch.Set "mermaid" true }}
|
{{ .Page.Scratch.Set "mermaid" true }}
|
||||||
{{ end }}
|
{{ 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