From 3afaa3f1b890d368f635cffb2cf8faada12389e1 Mon Sep 17 00:00:00 2001
From: Muqeet Malik <muqeetamalik@gmail.com>
Date: Wed, 17 Jan 2024 23:44:59 +0000
Subject: [PATCH] Allow users to disable default theme-switching Javascript files (#870)
---
layouts/_default/baseof.html | 6 +++++-
docs/configurations.md | 7 ++++---
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/docs/configurations.md b/docs/configurations.md
index 58f0a5a..4fca945 100644
--- a/docs/configurations.md
+++ b/docs/configurations.md
@@ -111,8 +111,8 @@
| description | string | Yes | Description of the site. | | `"John Doe's personal website"` |
| keywords | string | Yes | Site keywords. | | `"blog,developer,personal"` |
| avatarURL | string | No | Photo of the author. | | `"images/avatar.jpg"` |
-| gravatar | string | No | Gravatar photo of the author | | `"john.doe@example.com"` |
-| faviconSVG | string | No | Custom path to a SCG favicon. | `"/img/favicon.svg"` | `"/img/favicon.svg"` |
+| gravatar | string | No | Gravatar photo of the author | | `"john.doe@example.com"` |
+| faviconSVG | string | No | Custom path to a SCG favicon. | `"/img/favicon.svg"` | `"/img/favicon.svg"` |
| favicon_32 | string | No | Custom path to a 32x32 favicon. | `"/img/favicon-32x32.png"` | `"/img/favicon-32x32.png"` |
| favicon_16 | string | No | Custom path to a 16x16 favicon. | `"/img/favicon-16x16.png"` | `"/img/favicon-16x16.png"` |
| touchIcon | string | No | Custom path to a touch-icon | `"/images/apple-touch-icon.png"` | `"/images/apple-touch-icon.png"` |
@@ -127,8 +127,9 @@
| customCSS | list | No | Add extra CSS files to the website. | [] | `["css/extra-style.css"]` |
| customSCSS | list | No | Add extra SCSS files to the website. | [] | `["scss/extra-style.scss"]` |
| customJS | list | No | Add extra JS files to the website. | [] | `["js/extra-script.js"]` |
-| customRemoteJS | list | No | Add extra remote JS files to the website. | [] | `["https://www.example.com/file.js"]` |
+| customRemoteJS | list | No | Add extra remote JS files to the website. | [] | `["https://www.example.com/file.js"]` |
| enableTwemoji | bool | No | Adds support for Twemoji | `false` | `true` or `false` |
+| disableDefaultJsScripts | bool | No | If true, disables default js scripts (coder.js) | `false` | `true` or `false` |
### Social Icons Configuration
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 9634f9c..732ffd0 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -33,7 +33,11 @@
</script>
{{ end }}
- {{ if .Site.IsServer }}
+ {{ if .Site.Params.disableDefaultJsScripts }}
+ {{ if not .Site.Params.hideColorSchemeToggle }}
+ {{ errorf "Invalid configuration. Default JS scripts are disabled, but 'hideColorSchemeToggle' is false." }}
+ {{end}}
+ {{ else if .Site.IsServer }}
{{ $script := resources.Get "js/coder.js" }}
<script src="{{ $script.RelPermalink }}"></script>
{{ else }}
--
Gitblit v1.10.0