From f6dbc30a2550a21909ec1e6ff1485fdf330f707a Mon Sep 17 00:00:00 2001 From: Derek Severin Date: Mon, 18 Mar 2019 14:03:32 +0700 Subject: Set number of columns for projects as configurable --- exampleSite/config.toml | 6 +++++- layouts/_default/limage.html | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 9fbbf09..2f2e188 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -109,7 +109,11 @@ theme = "hugo-myportfolio-theme" # Format of the "period" field. date_format = "Jan-2006" - # ---------- + # Number of columns in projects grid (OPTIONAL) + #nb_columns = "3" + #nb_columns_small = "2" + + # ---------- # PAGE 404 [params.page404] diff --git a/layouts/_default/limage.html b/layouts/_default/limage.html index 6208469..49d31cf 100644 --- a/layouts/_default/limage.html +++ b/layouts/_default/limage.html @@ -1,4 +1,21 @@ -
+ +{{/* Get the number of columns from config */}} +{{ $.Scratch.Set "col_lg" "col-lg-4" }} +{{ with $.Site.Params.projects.nb_columns }} + {{ $nb_cols := div 12 (int .) }} + {{ $.Scratch.Set "col_lg" (print "col-lg-" $nb_cols) }} +{{ end }} +{{ $col_lg := $.Scratch.Get "col_lg" }} + +{{ $.Scratch.Set "col_sm" "col-sm-6" }} +{{ with $.Site.Params.projects.nb_columns_small }} + {{ $nb_cols := div 12 (int .) }} + {{ $.Scratch.Set "col_sm" (print "col-sm-" $nb_cols) }} +{{ end }} +{{ $col_sm := $.Scratch.Get "col_sm" }} +{{ $class := print $col_lg " " $col_sm }} + +