diff --git a/layouts/partials/style.html b/assets/css/style.css
similarity index 59%
rename from layouts/partials/style.html
rename to assets/css/style.css
index 9e16279..75019fb 100644
--- a/layouts/partials/style.html
+++ b/assets/css/style.css
@@ -1,5 +1,4 @@
-
+}
\ No newline at end of file
diff --git a/assets/js/darkmode.js b/assets/js/darkmode.js
new file mode 100644
index 0000000..109db12
--- /dev/null
+++ b/assets/js/darkmode.js
@@ -0,0 +1,23 @@
+if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches && localStorage.getItem('dark-mode') === null) {
+ localStorage.setItem('dark-mode', 'true');
+}
+
+function darkmode() {
+ if (localStorage.getItem('dark-mode') === 'false') {
+ darkmode_enable();
+ } else if (localStorage.getItem('dark-mode') === null) {
+ darkmode_enable();
+ } else {
+ darkmode_disable();
+ }
+}
+
+function darkmode_enable() {
+ document.body.classList.add("dark-mode");
+ localStorage.setItem('dark-mode', 'true');
+}
+
+function darkmode_disable() {
+ document.body.classList.remove("dark-mode");
+ localStorage.setItem('dark-mode', 'false');
+}
\ No newline at end of file
diff --git a/assets/js/darkmode_load.js b/assets/js/darkmode_load.js
new file mode 100644
index 0000000..cf35254
--- /dev/null
+++ b/assets/js/darkmode_load.js
@@ -0,0 +1,5 @@
+/* darkmode_enable is defined in darkmode.js(should be in the same directory as this file) */
+/* Must be executed after document.body is finished, else there would be error :) */
+if (localStorage.getItem('dark-mode') === 'true') {
+ darkmode_enable()
+}
\ No newline at end of file
diff --git a/assets/js/random_color.js b/assets/js/random_color.js
new file mode 100644
index 0000000..617defd
--- /dev/null
+++ b/assets/js/random_color.js
@@ -0,0 +1,25 @@
+const links = document.querySelectorAll('.random-color');
+
+// To avoid too bright and too dark color being generated
+function getRandomColor(minBrightness = 100, maxBrightness = 230) {
+ // Generate random color components within a specific brightness range
+ let red = Math.floor(Math.random() * (maxBrightness - minBrightness) + minBrightness);
+ let green = Math.floor(Math.random() * (maxBrightness - minBrightness) + minBrightness);
+ let blue = Math.floor(Math.random() * (maxBrightness - minBrightness) + minBrightness);
+
+ // Convert components to hexadecimal string format
+ red = red.toString(16).padStart(2, '0');
+ green = green.toString(16).padStart(2, '0');
+ blue = blue.toString(16).padStart(2, '0');
+
+ return `#${red}${green}${blue}`;
+}
+
+
+function setRandomColors() {
+ links.forEach(link => {
+ link.style.color = getRandomColor();
+ });
+}
+
+window.onload = setRandomColors;
\ No newline at end of file
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index d175160..2c3c000 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -15,9 +15,14 @@
{{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}
- {{- partial "style.html" . -}}
- {{- partial "script.html" . -}}
+ {{- /* CSS stylesheet */}}
+ {{- $stylesheet := (resources.Get "css/style.css") | resources.Minify | fingerprint }}
+
+ {{- /* Javascript */}}
+ {{- $darkmode_script := (resources.Get "js/darkmode.js") | resources.Minify | fingerprint}}
+
+
@@ -35,10 +40,13 @@
{{- partial "footer.html" . -}}
+ {{- /* Bottom Javascript */}}
+ {{- $darkmode_load_script := (resources.Get "js/darkmode_load.js") | resources.Minify | fingerprint}}
+
+
- {{- partial "script_bottom.html" -}}
{{- partial "custom_body.html" . -}}