Place custom css under assets

This commit is contained in:
Hanzei 2018-07-20 18:27:34 +02:00
parent 80c0c42f93
commit 452913c1fa
No known key found for this signature in database
GPG key ID: 69A2DEFD98937BA0
2 changed files with 9 additions and 7 deletions

View file

@ -11,7 +11,7 @@ DefaultContentLanguage = "en" # Default language fo
fadeIn = true # Turn on/off the fade-in effect
dateFormat = "Jan 2, 2006"
email = "youremail@email.com" # E-mail address for contact section
# customCSS = ["foo.css"] # Include custom css files
# customCSS = ["foo.css"] # Include custom css files placed under assets/
# Configure the home page
[params.home]

View file

@ -1,16 +1,18 @@
{{ $file := "sass/style.sass" }}
{{ $bundleRaw := resources.Get "sass/style.sass" | resources.ExecuteAsTemplate "style/main.tmp.css" . }}
{{ if .Site.IsServer }}
{{ $cssOpts := (dict "targetPath" "styles/main.css" "enableSourceMap" true ) }}
{{ $styles := resources.Get $file | resources.ExecuteAsTemplate "style/main.tmp.css" . | toCSS $cssOpts }}
<link rel="stylesheet" href="{{ $styles.Permalink }}" media="screen">
{{ $bundle := $bundleRaw | toCSS $cssOpts }}
<link rel="stylesheet" href="{{ $bundle.Permalink }}" media="screen">
{{ else }}
{{ $cssOpts := (dict "targetPath" "styles/main.css" ) }}
{{ $postCSSOpts := (dict "use" "autoprefixer" ) }}
{{ $styles := resources.Get $file | resources.ExecuteAsTemplate "style/main.tmp.css" . | toCSS $cssOpts | postCSS $postCSSOpts | minify | fingerprint }}
<link rel="stylesheet" href="{{ $styles.Permalink }}" integrity="{{ $styles.Data.Integrity }}" media="screen">
{{ $bundle := $bundleRaw | toCSS $cssOpts | postCSS $postCSSOpts | minify | fingerprint }}
<link rel="stylesheet" href="{{ $bundle.Permalink }}" integrity="{{ $bundle.Data.Integrity }}" media="screen">
{{ end }}
<!-- Custom css -->
{{ range .Site.Params.customCSS -}}
<link rel="stylesheet" href="{{ . | absURL }}">
{{ $style := resources.Get . }}
<link rel="stylesheet" href="{{ $style.Permalink }}" integrity="{{ $style.Data.Integrity }}" media="screen">
{{- end }}