From 8cc169e208521b0e2d47b0fe6352576f047acd29 Mon Sep 17 00:00:00 2001 From: Olivia206 <olivia.simonet@mmibordeaux.com> Date: Thu, 20 Apr 2023 18:07:29 +0200 Subject: [PATCH] style for alternate posts list --- assets/sass/_theme/blocks/posts.sass | 15 +++++++++++++++ .../blocks/templates/posts/alternate.html | 4 +++- layouts/partials/footer/debug.html | 6 +++--- layouts/partials/posts/post.html | 10 +++++++++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/assets/sass/_theme/blocks/posts.sass b/assets/sass/_theme/blocks/posts.sass index fc6ebdf4..08569056 100644 --- a/assets/sass/_theme/blocks/posts.sass +++ b/assets/sass/_theme/blocks/posts.sass @@ -163,3 +163,18 @@ margin-top: 0 article:first-child margin-top: 0 + &--alternate .alternate + @include media-breakpoint-up(desktop) + margin-left: calc(#{$grid-gutter} * 2) + margin-right: calc(#{$grid-gutter} * 2) + .post + width: col(4, 10) + &.right + margin-left: auto + &:not(:first-child) + &.portrait + margin-top: -30% + &.square + margin-top: -15% + .post .media img + aspect-ratio: unset \ No newline at end of file diff --git a/layouts/partials/blocks/templates/posts/alternate.html b/layouts/partials/blocks/templates/posts/alternate.html index b30b6952..2173bfba 100644 --- a/layouts/partials/blocks/templates/posts/alternate.html +++ b/layouts/partials/blocks/templates/posts/alternate.html @@ -1,9 +1,11 @@ <div class="alternate"> - {{ range $post := .posts -}} + {{ range $i, $post := .posts -}} {{ with site.GetPage (printf "/posts/%s" $post) }} {{ partial "posts/post.html" (dict "post" . "heading" "h3" + "index" $i + "alternate" true ) }} {{ end }} {{ end }} diff --git a/layouts/partials/footer/debug.html b/layouts/partials/footer/debug.html index bb2359ce..b6863c63 100644 --- a/layouts/partials/footer/debug.html +++ b/layouts/partials/footer/debug.html @@ -17,7 +17,7 @@ <div><span>0 (12px) </span></div> <div><span>1 (24px) </span></div> <div><span>2 (48px) </span></div> - <div><span>3 (64px) </span></div> + <div><span>3 (50px) </span></div> <div><span>4 (128px) </span></div> <div><span>5 (256px) </span></div> </div> @@ -25,8 +25,8 @@ <div class="d-cross"></div> <style> :root { - --d-grid-margin: 64px; - --d-grid-sm-margin: 44px; + --d-grid-margin: 50px; + --d-grid-sm-margin: 30px; } .d-grid { bottom: 0; diff --git a/layouts/partials/posts/post.html b/layouts/partials/posts/post.html index 37da4637..3c4fbf0f 100644 --- a/layouts/partials/posts/post.html +++ b/layouts/partials/posts/post.html @@ -1,12 +1,20 @@ {{ $post := .post }} +{{- $direction := "" -}} {{ $heading := .heading | default "h2" }} {{ $heading_tag := (dict "open" ((printf "<%s itemprop='headline'>" $heading) | safeHTML) "close" ((printf "</%s>" $heading) | safeHTML) ) }} +{{ $index := .index}} +{{ $alternate := .alternate}} {{ with $post }} -<article class="post" itemprop="blogPosts" itemscope itemtype="http://schema.org/BlogPosting"> + +{{ if .Params.image }} + {{- $direction = partial "GetImageDirection" .Params.image -}} +{{ end }} + +<article class='post {{ if $alternate }}{{ $direction }} {{if not (modBool $index 2)}}left{{ else}}right{{end}}{{end}}' itemprop="blogPosts" itemscope itemtype="http://schema.org/BlogPosting"> <div class="post-content"> {{- $title := partial "PrepareHTML" .Title -}} -- GitLab