diff options
author | Benedikt T <datacobra@thinkbot.de> | 2021-07-07 13:04:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-07 13:04:09 +0300 |
commit | ab85b865392aea7b1ce632b33323c6045302416d (patch) | |
tree | ffe4f7c041165080047217447e8117fcfc00a78c | |
parent | fc4713b129b1961a649e8a0b5992cdeddd6f0bce (diff) | |
parent | e641da55f4ef03383bd7a399bf2aa47ad2f2f6bd (diff) |
Merge pull request #59 from davidkaufmann/customjs
Possibility to add customJS
-rw-r--r-- | CONTRIBUTORS.md | 1 | ||||
-rw-r--r-- | exampleSite/config.toml | 19 | ||||
-rw-r--r-- | features.txt | 10 | ||||
-rw-r--r-- | layouts/partials/head.html | 16 |
4 files changed, 43 insertions, 3 deletions
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 588c1dc..de6b885 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -14,3 +14,4 @@ collaboration of others. * [Bernardo Ayala](https://github.com/nardoyala) * [Mattia Panzeri](https://github.com/panz3r) * [Jörg Thalheim](https://github.com/Mic92) +* [David Kaufmann](https://github.com/davidkaufmann) 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 e5e50be..8d7ca82 100644 --- a/features.txt +++ b/features.txt @@ -2,7 +2,15 @@ .Site.Params.keywords # Add meta keywords in head part (Site Keywords or Tags of Page) .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.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 8201a85..682a1ab 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -53,8 +53,20 @@ }); </script> {{- end -}} - <!-- Use customcss if you like --> - {{- if isset .Site.Params "customcss" -}} + <!-- 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 }}" /> {{- end -}} <!-- Use a SEO friendly title tag--> |