|
1 | 1 | {{- /* layouts/partials/essentials/style.html */ -}}
|
2 |
| -<!-- plugins + stylesheet --> |
3 |
| -{{ $styles := slice }} |
4 |
| -{{ range site.Params.plugins.css }} |
5 |
| -{{ if findRE "^http" .link }} |
6 |
| -<link |
7 |
| - crossorigin="anonymous" |
8 |
| - media="all" |
9 |
| - rel="stylesheet" |
10 |
| - href="{{ .link | relURL }}" |
11 |
| - {{ .attributes | safeHTMLAttr }} /> |
12 |
| -{{ else }} |
13 |
| -{{ $styles = $styles | append (resources.Get .link) }} |
14 |
| -{{ end }} |
15 |
| -{{ end }} |
16 |
| -{{ $styles := $styles | append (resources.Get "scss/main.scss" | toCSS) }} |
17 |
| -{{ $styles := $styles | resources.Concat "css/style.css" }} |
18 |
| -{{ $styles = $styles | css.PostCSS }} |
19 |
| -{{ if hugo.IsProduction }} |
20 |
| -{{ $styles = $styles | resources.ExecuteAsTemplate "css/style.css" . | minify | fingerprint | resources.PostProcess }} |
21 |
| -{{ else }} |
22 |
| -{{ $styles = $styles | resources.ExecuteAsTemplate "css/style.css" . }} |
23 |
| -{{ end }} |
24 |
| -<link |
25 |
| - href="{{ $styles.RelPermalink }}" |
26 |
| - integrity="{{ $styles.Data.Integrity }}" |
27 |
| - rel="stylesheet" /> |
| 2 | +{{- /* |
| 3 | + This partial now links to the CSS that was pre-processed and preloaded in head.html. |
| 4 | + It also handles any external CSS files. |
| 5 | +*/ -}} |
| 6 | + |
| 7 | +{{- /* Link to external stylesheets first */ -}} |
| 8 | +{{- range site.Params.plugins.css -}} |
| 9 | + {{- if findRE `^http` .link -}} |
| 10 | + <link |
| 11 | + crossorigin="anonymous" |
| 12 | + media="all" |
| 13 | + rel="stylesheet" |
| 14 | + href="{{ .link | relURL }}" |
| 15 | + {{ .attributes | safeHTMLAttr }} /> |
| 16 | + {{- end -}} |
| 17 | +{{- end -}} |
| 18 | + |
| 19 | +{{- /* Link to the main stylesheet generated in head.html */ -}} |
| 20 | +{{- with .Scratch.Get "main_css" -}} |
| 21 | + <link |
| 22 | + href="{{ .RelPermalink }}" |
| 23 | + integrity="{{ .Data.Integrity }}" |
| 24 | + rel="stylesheet" /> |
| 25 | +{{- else -}} |
| 26 | + {{- warnf "The 'main_css' resource was not found in .Scratch. The stylesheet might be missing. This can happen if head.html is not called before style.html in baseof.html." -}} |
| 27 | +{{- end -}} |
0 commit comments