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

github.com/kakawait/hugo-tranquilpeak-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibaud LeprĂȘtre <thibaud.lepretre@gmail.com>2017-04-20 10:27:57 +0300
committerThibaud LeprĂȘtre <thibaud.lepretre@gmail.com>2017-04-20 10:46:47 +0300
commit55750035f292fee1f3c9914cfb3e8e0cba358c92 (patch)
treef1fdb755c8a8e08196ac8dffa201c8deaa98c270 /layouts/partials/head.html
parentfdd72bf81575a608766e02b4c17470a4174e9f5a (diff)
Capability to fill other attr than href/src
Until now `customJs` and `customCSS` only create a `script` or `link` tags with `src` or `href`. But there is no way to add/customize more attributes like `integrity`, `rel`, `type`, etc... With new `customJS` and `customCSS` syntaxe is now possible, like following ```toml [[params.customJS]] src = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/languages/go.min.js" integrity = "sha256-LVuWfOU0rWFMCJNl1xb3K2HSWfxtK4IPbqEerP1P83M=" crossorigin = "anonymous" async = true defer = true ``` **ATTENTION** every keys of the map will be converted to tag attribute even if attribute is not part of _HTML_ spec. Futhermore, in order to do not break existing configuration it still possible to use previous syntax: ```toml customJS = ["https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/languages/go.min.js"] ``` **but you can't mix both syntax**, if you want to use new syntax you must first convert previous entries.
Diffstat (limited to 'layouts/partials/head.html')
-rw-r--r--layouts/partials/head.html6
1 files changed, 5 insertions, 1 deletions
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 5e27848..5447278 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -92,7 +92,11 @@
<link rel="stylesheet" href="/css/style-h63bw1xth8vvjaqwlbjvebagy7w4erwpbhxigjixv5z0adzrhcquyjicocub.min.css" />
<!--STYLES END-->
{{ range .Site.Params.customCSS }}
- <link rel="stylesheet" href="{{ . | absURL }}">
+ {{ if isset . "href" }}
+ <link{{ range $key, $value := . }} {{ if eq $key "href" }}{{ (printf "%s=\"%s\"" $key ($value | absURL)) | safeHTMLAttr }}{{ else }}{{ (printf "%s=\"%s\"" $key (string $value)) | safeHTMLAttr }}{{ end }}{{ end }}></script>
+ {{ else }}
+ <link rel="stylesheet" href="{{ . | absURL }}">
+ {{ end }}
{{ end }}
{{ if .Params.ga.async }}