Templatize font import

This commit is contained in:
lucperkins
2018-08-04 14:50:46 +02:00
parent cedb8aa29f
commit 028e064b7a
2 changed files with 10 additions and 4 deletions

View File

@@ -4,6 +4,9 @@ title: Hugo Fresh Theme
theme: hugo-fresh
params:
font:
name: "Open Sans"
sizes: [400,600]
hero:
# Main hero title
title: Manage. Deploy.

View File

@@ -1,9 +1,12 @@
{{- $inServerMode := .Site.IsServer }}
{{- $sass := "style.sass" }}
{{- $cssTarget := "css/style.css" }}
{{- $cssOpts := cond ($inServerMode) (dict "targetPath" $cssTarget "enableSourceMap" true) (dict "targetPath" $cssTarget "outputStyle" "compressed") }}
{{- $sass := "style.sass" }}
{{- $cssTarget := "css/style.css" }}
{{- $cssOpts := cond ($inServerMode) (dict "targetPath" $cssTarget "enableSourceMap" true) (dict "targetPath" $cssTarget "outputStyle" "compressed") }}
{{- $fontFace := replace .Site.Params.font.name " " "+" }}
{{- $fontSizes := delimit .Site.Params.font.sizes "," }}
{{- $fontUrl := printf "https://fonts.googleapis.com/css?family=%s:%s" $fontFace $fontSizes }}
<link rel="icon" type="image/png" href="{{ "/images/favicon.png" | absURL }}" />
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600" rel="stylesheet">
<link href="{{ $fontUrl }}" rel="stylesheet">
{{- if $inServerMode }}
{{- $css := resources.Get $sass | toCSS $cssOpts }}
<link rel="stylesheet" type="text/css" href="{{ $css.Permalink }}">