Fix customJS and customCSS feature (#606)

* Fix customJS function

In the current state the customJS feature doesn't work, because an asset will only be generated to `/public` when `.RelPermalink` is used as mentioned in the [document](https://gohugo.io/hugo-pipes/introduction/#asset-publishing).

* Update CONTRIBUTORS.md

* Fix customCSS as well
This commit is contained in:
Simon Pai
2021-11-03 01:48:03 +08:00
committed by GitHub
parent 1f34f6827a
commit 1cdbe4f14a
2 changed files with 15 additions and 2 deletions

View File

@@ -103,3 +103,4 @@
- [Kirill Feoktistov](https://feoktistoff.org) - [Kirill Feoktistov](https://feoktistoff.org)
- [leins275](https://github.com/LanskovNV) - [leins275](https://github.com/LanskovNV)
- [Michael Weiss](https://mweiss.ch) - [Michael Weiss](https://mweiss.ch)
- [Simon Pai](https://github.com/simonpai)

View File

@@ -61,7 +61,13 @@
{{ end }} {{ end }}
{{ range .Site.Params.customCSS }} {{ range .Site.Params.customCSS }}
<link rel="stylesheet" href="{{ . | relURL }}" /> {{ if $.Site.IsServer }}
{{ $styles := resources.Get . }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" media="screen">
{{ else }}
{{ $styles := resources.Get . | minify | fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Integrity }}" crossorigin="anonymous" media="screen" />
{{ end }}
{{ end }} {{ end }}
{{ range .Site.Params.customSCSS }} {{ range .Site.Params.customSCSS }}
@@ -123,7 +129,13 @@
{{ end }} {{ end }}
{{ range .Site.Params.customJS }} {{ range .Site.Params.customJS }}
<script src="{{ . | relURL }}"></script> {{ if $.Site.IsServer }}
{{ $script := resources.Get . }}
<script src="{{ $script.RelPermalink }}"></script>
{{ else }}
{{ $script := resources.Get . | minify | fingerprint }}
<script src="{{ $script.RelPermalink }}" integrity="{{ $script.Data.Integrity }}"></script>
{{ end }}
{{ end }} {{ end }}
{{ template "_internal/google_analytics.html" . }} {{ template "_internal/google_analytics.html" . }}