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,6 +22,8 @@ DefaultContentLanguage = "en" # Default language fo
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
[params.projects]
useTwoColumns = false # Use a layout with two columns instead of three
# Share buttons on blog post pages
[params.share]

View file

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

View file

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