From b7ecf0c08c110f11cc215b7154fb1349263ca106 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linh=20T=2E=20T=C3=B4?=
<31973230+linhtto@users.noreply.github.com>
Date: Sat, 8 Aug 2020 10:52:35 -0400
Subject: [PATCH] Allow for Custom JavaScript files (#233)
---
README.md | 6 +++++-
exampleSite/config.toml | 1 +
layouts/partials/footer/scripts.html | 6 ++++++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 27e73b2..ecc7de4 100644
--- a/README.md
+++ b/README.md
@@ -184,7 +184,11 @@ Set `disqusshortname` in `config.toml` to activate Hugo's [internal Disqus templ
## Custom CSS
-You can add custom CSS files by placing them under `assets/` and adding the path to the file to `customCSS` in `config.toml`.
+You can add custom CSS files by placing them under `assets/` and adding the paths to the files to the `customCSS` list in `config.toml`.
+
+## Custom JavaScript
+
+You can add custom JavaScript files by placing them under `assets/` and adding the paths to the files to the `customJS` list in `config.toml`.
## Issues
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 13e9bf6..e5e2d74 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -13,6 +13,7 @@ DefaultContentLanguage = "en" # Default language fo
dateFormat = "Jan 2, 2006"
email = "youremail@email.com" # E-mail address for contact section
# customCSS = ["foo.css"] # Include custom css files placed under assets/
+ # customJS = ["foo.js"] # Include custom JavaScript files placed under assets/
# Configure the home page
[params.home]
diff --git a/layouts/partials/footer/scripts.html b/layouts/partials/footer/scripts.html
index 6142f3d..7454f32 100644
--- a/layouts/partials/footer/scripts.html
+++ b/layouts/partials/footer/scripts.html
@@ -4,3 +4,9 @@
{{ template "_internal/google_analytics_async.html" . }}
+
+
+{{ range .Site.Params.customJS -}}
+ {{ $script := resources.Get . | minify }}
+
+{{- end }}