Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dataCobra/hugo-vitae.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kaufmann <mail@davidkaufmann.de>2021-07-02 00:31:37 +0300
committerDavid Kaufmann <mail@davidkaufmann.de>2021-07-02 00:40:44 +0300
commitdf80e8aafaedbb3de6df557fceeb1caf5e5c72d5 (patch)
treee9c235ac9c79910759d6b092018f450762940c9e
parentb945fcdd5d7ca2ca0ad372c67405f963e0dd986e (diff)
added possibility to add custom js file
-rw-r--r--exampleSite/config.toml19
-rw-r--r--features.txt8
-rw-r--r--layouts/partials/head.html12
3 files changed, 39 insertions, 0 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index bc5fef0..1992639 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -60,6 +60,25 @@ googleAnalytics = ""
# Custom CSS applied to default styles. (Path could be "static/css/")
#customCSS = "css/custom.css"
+# Custom JavaScript
+[params.customJS]
+# enable Javascript by setting to true
+#enabled = true
+# add a filepath (could be "static/js/")
+#src = "js/main.js"
+# specifies which referrer information to send when fetching the script
+#referrerpolicy = "no-referrer"
+# specifies that the script should not be executed in browsers supporting ES2015 modules
+#nomodule = false
+# Allows a browser to check for integrity to ensure the code hasn't been manipulated
+#integrity= ""
+# execute the script when page has finished parsing (external only)
+#defer = true
+# sets the mode of the request to an http cors request
+#crossorigin=true
+# executes the script asynchronously (external only)
+#async = true
+
# Comments
[params.comments]
# Enable Comments with "true"
diff --git a/features.txt b/features.txt
index cd8d21c..8d7ca82 100644
--- a/features.txt
+++ b/features.txt
@@ -3,6 +3,14 @@
.Site.Params.description # Add meta description in head part (Site Description or Description of Page)
.Site.Params.math # Add math typesetting with KaTeX (Global with this param)
.Site.Params.customCSS # Add path to customCSS you want to add to the theme
+.Site.Params.customJS.enabled # Enable/Disable customJS
+.Site.Params.customJS.src # add the source path
+.Site.Params.customJS.referrerpolicy # specifies which referrer information to send when fetching the script
+.Site.Params.customJS.nomodule # specifies that the script should not be executed in browsers supporting ES2015 modules
+.Site.Params.customJS.integrity # allows a browser to check for integrity to ensure the code hasn't been manipulated
+.Site.Params.customJS.defer # execute the script when page has finished parsing (external only)
+.Site.Params.customJS.crossorigin # sets the mode of the request to an http cors request
+.Site.Params.customJS.async # executes the script asynchronously (external only)
.Site.Params.pagetitle # Add pagetitle to homepage <title> tag
.Site.Params.avatar # Add a avatar to your website
.Site.Params.subtitle # Add a subtitle to your website
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index db64c47..682a1ab 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -53,6 +53,18 @@
});
</script>
{{- end -}}
+ <!-- Use customJS if you like -->
+ {{- if .Site.Params.customJS.enabled -}}
+ <script
+ {{ if eq .Site.Params.customJS.async true }} {{ "async" | safeHTMLAttr}}{{ end }}
+ {{ if eq .Site.Params.customJS.defer true }} {{ "defer" | safeHTMLAttr}}{{ end }}
+ {{ if eq .Site.Params.customJS.nomodule true }} {{ "nomodule" | safeHTMLAttr}}{{ end }}
+ {{ if isset .Site.Params.customJS "crossorigin" }} {{ printf "crossorigin=%q" .Site.Params.customJs.crossorigin | safeHTMLAttr }}{{ end }}
+ {{ if isset .Site.Params.customJS "integrity" }} {{ printf "integrity=%q" .Site.Params.customJs.integrity | safeHTMLAttr }}{{ end }}
+ {{ if isset .Site.Params.customJS "referrerpolicy" }} {{ printf "referrerpolicy=%q" .Site.Params.customJs.referrerpolicy | safeHTMLAttr }}{{ end }}
+ {{ printf "src=%q" (.Site.Params.customJS.src | relURL) | safeHTMLAttr }}>
+ </script>
+ {{- end -}}
<!-- Use customCSS if you like -->
{{- if isset .Site.Params "customCSS" -}}
<link rel="stylesheet" type="text/css" media="screen" href="{{ relURL .Site.Params.customCSS }}" />