forked from google/docsy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhead-css.html
39 lines (33 loc) · 1.15 KB
/
head-css.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{{ $scssMain := "scss/main.scss" -}}
{{ $css := resources.Get $scssMain
| toCSS (dict "enableSourceMap" (not hugo.IsProduction)) -}}
{{ $bsRtlCss := "vendor/bootstrap/dist/css/bootstrap.rtl.css" -}}
{{ $rtlCSS := "" -}}
{{ if eq .Site.Language.LanguageDirection "rtl" -}}
{{ with resources.Get $bsRtlCss -}}
{{ $rtlCSS = . -}}
{{ else -}}
{{ $msg := printf "Resource not found: %s" $bsRtlCss -}}
{{ warnf $msg -}}
<meta name="docsy-info" content="{{ $msg }}">
{{ end -}}
{{ end -}}
{{ if hugo.IsProduction -}}
{{ with $rtlCSS -}}
{{ $rtlCSS = . | postCSS | minify | fingerprint -}}
{{ end -}}
{{ $css = $css | postCSS | minify | fingerprint -}}
<link rel="preload" href="{{ $css.RelPermalink }}" as="style">
{{- end -}}
{{/* NOTE: when not in production, we don't apply `postCSS`. This makes it
snappier to develop in Chrome, but makes it look sub-optimal in other browsers.
*/ -}}
{{ with $css -}}
<link href="{{ .RelPermalink }}" rel="stylesheet">
{{ else -}}
{{ errorf "Resource not found: %s" $scssMain -}}
{{ end -}}
{{ with $rtlCSS -}}
<link href="{{ $rtlCSS.RelPermalink }}" rel="stylesheet">
{{ end -}}
{{- /**/ -}}