From 7aba720e7744ecaea04f512f07d8f64c574ee406 Mon Sep 17 00:00:00 2001 From: Vivek R Date: Tue, 31 Dec 2019 10:11:22 +0530 Subject: [PATCH] fix: don't prepend host url to external js if it starts with http:// or https:// --- README.md | 5 +++-- exampleSite/config.toml | 2 +- layouts/partials/header.html | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index be522bc..dddbbec 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,9 @@ paginate = 10 customDarkCSS = "css/custom-dark.css" # Custom list of Javascript files to load. Just like custom CSS you can place js files under - # `static/js` folder and specify path here as `js/script-name.js`. - customJS = ["js/abc.js", "js/xyz.js"] + # `static/js` folder and specify path here as `js/script-name.js`. You can also specify full url, + # for example you may want to include external JS library. + customJS = ["js/abc.js", "js/xyz.js", "https://code.jquery.com/jquery-3.4.1.js"] # Main menu which appears below site header. [[menu.main]] diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 06188ba..5a416fb 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -20,7 +20,7 @@ disqusShortname = "ezhil-demo" mode = "auto" # "dark", "auto", "light" # customCSS = "css/custom.css" # Custom CSS applied to default styles. # customDarkCSS = "css/custom-dark.css" # Custom styles applied to dark mode css. - # customJS = ["js/custom.js", "js/custom1.js"] # Custom JS scripts. + customJS = ["https://code.jquery.com/jquery-3.4.1.js", "js/custom1.js"] # Custom JS scripts. [[menu.main]] name = "Home" diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 3fa8a71..62e9d27 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -42,7 +42,11 @@ {{- if isset .Site.Params "customjs" -}} {{- range .Site.Params.customJS }} + {{- if or (hasPrefix . "http://") (hasPrefix . "https://") }} + + {{- else }} {{- end }} {{- end }} + {{- end }}