From 028e064b7a2be44c0c340fcd2bfb73d02b2e5750 Mon Sep 17 00:00:00 2001 From: lucperkins Date: Sat, 4 Aug 2018 14:50:46 +0200 Subject: [PATCH] Templatize font import --- exampleSite/config.yaml | 3 +++ layouts/partials/css.html | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 1d372fb..0123f80 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -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. diff --git a/layouts/partials/css.html b/layouts/partials/css.html index fc1c082..241d5bb 100644 --- a/layouts/partials/css.html +++ b/layouts/partials/css.html @@ -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 }} - + {{- if $inServerMode }} {{- $css := resources.Get $sass | toCSS $cssOpts }}