Add projects.useTwoColumns option

This commit is contained in:
Hanzei 2018-07-22 07:24:01 +02:00
parent 9b08324593
commit 389ac2a34b
No known key found for this signature in database
GPG key ID: 69A2DEFD98937BA0
3 changed files with 14 additions and 9 deletions

View file

@ -22,13 +22,15 @@ DefaultContentLanguage = "en" # Default language fo
localTime = true # Show your current local time in contact section localTime = true # Show your current local time in contact section
timeZone = "America/Los_Angeles" # Your timezone as in the TZ* column of this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones timeZone = "America/Los_Angeles" # Your timezone as in the TZ* column of this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
[params.projects]
useTwoColumns = false # Use a layout with two columns instead of three
# Share buttons on blog post pages # Share buttons on blog post pages
[params.share] [params.share]
twitter = true twitter = true
facebook = true facebook = true
googlePlus = true googlePlus = true
pinterest = true pinterest = true
# Social icons appear in introduction and contact section. Add as many more as you like. # Social icons appear in introduction and contact section. Add as many more as you like.
# Find icon names here: https://fontawesome.com/cheatsheet/ # Find icon names here: https://fontawesome.com/cheatsheet/

View file

@ -5,12 +5,12 @@
<h2 class="title is-2 has-text-centered"> <h2 class="title is-2 has-text-centered">
{{ .Title }} {{ .Title }}
</h2> </h2>
<div class="section is-small"> <div class="section">
<div class="columns is-multiline"> <div class="columns is-multiline">
{{ $totalProjects := (len .Pages) }} {{ $totalProjects := (len .Pages) }}
{{ $numberOfProjectsToShow := .Site.Params.home.numberOfProjectsToShow | default $totalProjects }} {{ $numberOfProjectsToShow := .Site.Params.home.numberOfProjectsToShow | default $totalProjects }}
{{ range $index, $element := .Pages.ByWeight | first $numberOfProjectsToShow }} {{ range $index, $element := .Pages.ByWeight | first $numberOfProjectsToShow }}
{{ if eq (mod $numberOfProjectsToShow 2) 0 }} {{ if .Site.Params.projects.useTwoColumns }}
{{ .Scratch.Set "width" "490x" }} {{ .Scratch.Set "width" "490x" }}
<div class="column is-half"> <div class="column is-half">
{{ else }} {{ else }}

View file

@ -3,22 +3,25 @@
{{ .Content }} {{ .Content }}
</div> </div>
<div class="container"> <div class="container">
<div class="section is-small"> <div class="section">
<div class="columns is-multiline"> <div class="columns is-multiline">
{{ $numberOfPages := len .Pages}} {{ $numberOfPages := len .Pages}}
{{ range .Pages.ByWeight }} {{ range .Pages.ByWeight }}
{{ if eq (mod $numberOfPages 2) 0 }} {{ if .Site.Params.projects.useTwoColumns }}
{{ .Scratch.Set "width" "490x" }}
<div class="column is-half"> <div class="column is-half">
{{ else }} {{ else }}
{{ .Scratch.Set "width" "302x" }}
<div class="column is-one-third"> <div class="column is-one-third">
{{ end }} {{ end }}
<div class="card"> <div class="card">
<div class="card-image"> <div class="card-image">
<figure class="image is-3by2"> <figure class="image is-3by2">
<a href="{{ if .Params.external_link }}{{ .Params.external_link }}{{ else }}{{ .Permalink }}{{ end }}"> <a href="{{ if .Params.external_link }}{{ .Params.external_link }}{{ else }}{{ .Permalink }}{{ end }}">
{{ $width := ( .Scratch.Get "width" ) }}
{{ with .Resources.ByType "image" }} {{ with .Resources.ByType "image" }}
{{ range first 1 (sort . "Params.weight") }} {{ range first 1 (sort . "Params.weight") }}
{{ $image := .Resize "302x" }} {{ $image := .Resize $width }}
<img src="{{ $image.Permalink }}" alt ="{{ $image.Name }}"> <img src="{{ $image.Permalink }}" alt ="{{ $image.Name }}">
{{ end }} {{ end }}
{{ end }} {{ end }}