|
| 1 | +<!-- JS Plugins + Main script --> |
| 2 | +{{ $scripts := slice }} |
| 3 | +{{ $scriptsLazy := slice }} |
| 4 | +{{ range site.Params.plugins.js }} |
| 5 | + {{ if findRE "^http" .link }} |
| 6 | + <script |
| 7 | + src="{{ .link | relURL }}" |
| 8 | + type="application/javascript" |
| 9 | + {{ .attributes | safeHTMLAttr }}></script> |
| 10 | + {{ else }} |
| 11 | + {{ if not .lazy }} |
| 12 | + {{ $scripts = $scripts | append (resources.Get .link) }} |
| 13 | + {{ else }} |
| 14 | + {{ $scriptsLazy = $scriptsLazy | append (resources.Get .link) }} |
| 15 | + {{ end }} |
| 16 | + {{ end }} |
| 17 | +{{ end }} |
| 18 | + |
| 19 | + |
| 20 | +<!-- main script --> |
| 21 | +{{ $scripts = $scripts | append (resources.Get "js/main.js") }} |
| 22 | +{{ $scripts = $scripts | resources.Concat "js/script.js" }} |
| 23 | + |
| 24 | +{{ $scriptsLazy = $scriptsLazy | resources.Concat "js/script-lazy.js" }} |
| 25 | + |
| 26 | +{{/* Transpile for old engines such as KaiOS 2.x (Gecko 48), see .babelrc. |
| 27 | + Overrides the theme's partial only to add this step. */}} |
| 28 | +{{ $babelOpts := dict "config" ".babelrc" }} |
| 29 | +{{ $scripts = $scripts | js.Babel $babelOpts }} |
| 30 | +{{ $scriptsLazy = $scriptsLazy | js.Babel $babelOpts }} |
| 31 | + |
| 32 | +{{ if hugo.IsProduction }} |
| 33 | + {{ $scripts = $scripts | minify | fingerprint }} |
| 34 | + {{ $scriptsLazy = $scriptsLazy | minify | fingerprint }} |
| 35 | +{{ end }} |
| 36 | + |
| 37 | +{{/* scripts */}} |
| 38 | +<script |
| 39 | + crossorigin="anonymous" |
| 40 | + integrity="{{ $scripts.Data.Integrity }}" |
| 41 | + src="{{ $scripts.RelPermalink }}"></script> |
| 42 | + |
| 43 | +{{/* scripts lazy */}} |
| 44 | +<script |
| 45 | + defer |
| 46 | + async |
| 47 | + crossorigin="anonymous" |
| 48 | + integrity="{{ $scriptsLazy.Data.Integrity }}" |
| 49 | + src="{{ $scriptsLazy.RelPermalink }}"></script> |
| 50 | + |
| 51 | +<!-- progressive web app --> |
| 52 | +{{ partialCached "pwa.html" . }} |
| 53 | + |
| 54 | + |
| 55 | +<!-- cookie consent --> |
| 56 | +{{ partialCached "cookie-consent.html" . }} |
| 57 | + |
| 58 | + |
| 59 | +<!-- google adsense --> |
| 60 | +{{ partialCached "adsense-script.html" . }} |
| 61 | + |
| 62 | + |
| 63 | +<!-- cookie consent --> |
| 64 | +{{ partialCached "announcement-script.html" . }} |
0 commit comments