diff --git a/assets/sass/_theme/blocks/posts.sass b/assets/sass/_theme/blocks/posts.sass index c73f7f078284e371a77752d3b55e1493814a64ea..f7e8ff91b5db94eb93813195e071439602fc2ead 100644 --- a/assets/sass/_theme/blocks/posts.sass +++ b/assets/sass/_theme/blocks/posts.sass @@ -46,8 +46,20 @@ .post-meta display: block line-height: 0 // Hack pour que les enfants de post-meta soient correctement - .post-categories * + > * + margin-right: $spacing-3 + time + vertical-align: baseline + .post-author + display: inline + p + display: inline + .post-categories display: inline + * + display: inline-block + li + margin-right: $spacing-2 // Désactiver le ratio forcé de la configuration $article-media-aspect-ratio .media &, img @@ -56,13 +68,6 @@ .post + .post margin-top: $spacing-4 - &-meta - .post-author - display: inline - p - display: inline - &::after - content: ' — ' p[itemprop="articleBody"] margin-top: 0 @include media-breakpoint-up(desktop) @@ -76,20 +81,10 @@ @include h2 p[itemprop="articleBody"] margin-top: $spacing-3 - .post-meta - > * - display: inline - &:not(:last-child)::after - content: ' — ' - .post-author - p - display: inline .post-categories li a display: inline - &:not(:last-child) a::after - content: ',' @include in-page-with-sidebar .large @@ -152,13 +147,13 @@ @include in-page-with-sidebar article padding-bottom: $spacing-3 + gap: var(--grid-gutter) // gap plutôt que marge pour l'affichage avec ou sans image + article margin-top: $spacing-3 .media width: columns(2) .post-content width: columns(6) - margin-left: var(--grid-gutter) @include in-page-without-sidebar article @@ -218,12 +213,12 @@ .highlight-post .post flex-direction: row + gap: var(--grid-gutter) // pour le cas où on masque l'image .media width: columns(3) margin-bottom: 0 .post-content width: columns(5) - margin-left: var(--grid-gutter) .list article @include grid(8, desktop, 0, 0) @@ -258,17 +253,29 @@ aspect-ratio: unset @include media-breakpoint-up(desktop) - .post - &.right + &:not(.without-images) + .post + &.right + margin-left: auto + &.portrait + + .portrait + margin-top: -30% + + .square, + + .landscape + margin-top: -15% + + .post:not(.portrait, .square, .landscape) + margin-top: -5% + &.without-images + .right margin-left: auto - &.portrait + .portrait + .portrait - margin-top: -30% + margin-top: 0 + .square, + .landscape - margin-top: -15% - + .post:not(.portrait, .square, .landscape) margin-top: -5% + + .post:not(.portrait, .square, .landscape) + margin-top: -3% @include media-breakpoint-down(desktop) .post diff --git a/layouts/partials/blocks/templates/posts.html b/layouts/partials/blocks/templates/posts.html index c8b0fb9ccfc21e61e700635115669998059c1b46..af9fadeb2e3d1fc4a1a01c61501b4b76b23c591c 100644 --- a/layouts/partials/blocks/templates/posts.html +++ b/layouts/partials/blocks/templates/posts.html @@ -4,6 +4,14 @@ {{- $term := false -}} {{- $layout := .block.data.layout | default "grid" -}} {{- with .block.data }} + {{- $options := dict + "hide_image" .hide_image + "hide_summary" .hide_summary + "hide_category" .hide_category + "hide_author" .hide_author + "hide_date" .hide_date + -}} + {{ if .category }} {{- $term = site.GetPage (printf "/posts_categories%s" .category) -}} {{ end }} @@ -39,6 +47,7 @@ {{ partial (printf "blocks/templates/posts/%s.html" $layout) (dict "posts" .posts "heading_level" $block.ranks.children + "options" $options )}} {{ end }} diff --git a/layouts/partials/blocks/templates/posts/alternate.html b/layouts/partials/blocks/templates/posts/alternate.html index 840bb3872560a4e9a43ac01322a9f6ef924a5f1b..7cd853422ac54c4e5dd6cf4e17a038843a00c104 100644 --- a/layouts/partials/blocks/templates/posts/alternate.html +++ b/layouts/partials/blocks/templates/posts/alternate.html @@ -1,6 +1,9 @@ {{ $heading_level := .heading_level | default 3 }} {{ $heading := printf "h%d" $heading_level }} -<div class="alternate"> +{{ $options := .options }} +{{ $hide_image := .options.hide_image }} + +<div class="alternate {{- if $hide_image }} without-images{{ end }}"> {{ range $i, $post := .posts -}} {{ with site.GetPage (printf "/posts/%s" $post) }} {{ partial "posts/post.html" (dict @@ -8,6 +11,7 @@ "heading" $heading "index" $i "alternate" true + "options" $options ) }} {{ end }} {{ end }} diff --git a/layouts/partials/blocks/templates/posts/carousel.html b/layouts/partials/blocks/templates/posts/carousel.html index df63993734923de3d7540d0fe99b159564eb0ca0..aa5376305a7403db3e5102d273bcc85f84d4e39a 100644 --- a/layouts/partials/blocks/templates/posts/carousel.html +++ b/layouts/partials/blocks/templates/posts/carousel.html @@ -1,5 +1,6 @@ {{ $heading_level := .heading_level | default 3 }} {{ $heading := printf "h%d" $heading_level }} +{{ $options := .options }} <div class="carousel draggable-container"> <div class="carousel-posts draggable-content"> @@ -9,6 +10,7 @@ <li class="draggable-item"> {{ partial "posts/post.html" (dict "post" . + "options" $options "heading" $heading) }} </li> {{ end }} diff --git a/layouts/partials/blocks/templates/posts/grid.html b/layouts/partials/blocks/templates/posts/grid.html index b09828e5d0440ea603f7451c4662da55e8b01734..0d6bc38dec162251a99c383bd4cd2740b82c2f23 100644 --- a/layouts/partials/blocks/templates/posts/grid.html +++ b/layouts/partials/blocks/templates/posts/grid.html @@ -1,11 +1,14 @@ {{ $heading_level := .heading_level | default 3 }} {{ $heading := printf "h%d" $heading_level }} +{{ $options := .options }} + <div class="grid"> {{ range $post := .posts -}} {{ with site.GetPage (printf "/posts/%s" $post) }} {{ partial "posts/post.html" (dict "post" . "heading" $heading + "options" $options ) }} {{ end }} {{ end }} diff --git a/layouts/partials/blocks/templates/posts/highlight.html b/layouts/partials/blocks/templates/posts/highlight.html index 082a9b00f2c5d48cb468781fbf64f38f4ee89c2f..de4d08ae900e4d51941b51130315cf883e1708ce 100644 --- a/layouts/partials/blocks/templates/posts/highlight.html +++ b/layouts/partials/blocks/templates/posts/highlight.html @@ -4,6 +4,8 @@ "open" ((printf "<%s class='post-title' itemprop='headline'>" $heading) | safeHTML) "close" ((printf "</%s>" $heading) | safeHTML) ) }} +{{ $options := .options }} + <div class="highlight"> {{ $highlight := index .posts 0 }} {{ $highlight = site.GetPage (printf "/posts/%s" $highlight)}} @@ -14,6 +16,7 @@ {{ partial "posts/post" (dict "post" . "heading" $heading + "options" $options ) }} </div> {{ end }} @@ -29,10 +32,10 @@ <a href="{{ .Permalink }}" title="{{ safeHTML (i18n "commons.more_aria" (dict "Title" $title)) }}">{{ $title }}</a> {{ $heading_tag.close }} - {{ if site.Params.posts.index.show_categories }} + {{ if and site.Params.posts.index.show_categories (eq $options.hide_cathegory false) }} {{- partial "posts/categories" . -}} {{ end }} - {{ if site.Params.posts.index.show_description }} + {{ if and site.Params.posts.index.show_description (eq $options.hide_summary false) }} {{- if (partial "GetTextFromHTML" .Params.summary) -}} <p itemprop="articleBody">{{ partial "GetTruncateContent" ( dict "text" .Params.summary @@ -40,13 +43,16 @@ ) }}</p> {{- end -}} {{- end -}} - - <div class="post-meta"> - <time itemprop="datePublished" datetime="{{ .Date.Format "2006-01-02T15:04" }}">{{ .Date | time.Format site.Params.posts.date_format }}</time> - {{ if site.Params.posts.index.show_author }} - {{- partial "posts/author" . -}} - {{ end }} - </div> + {{- if or (eq $options.hide_author false) (eq $options.hide_date false) -}} + <div class="post-meta"> + {{- if eq $options.hide_date false -}} + <time itemprop="datePublished" datetime="{{ .Date.Format "2006-01-02T15:04" }}">{{ .Date | time.Format site.Params.posts.date_format }}</time> + {{ end }} + {{ if and site.Params.posts.index.show_author (eq $options.hide_author false) }} + {{- partial "posts/author" . -}} + {{ end }} + </div> + {{ end }} </article> {{ end }} {{ end }} diff --git a/layouts/partials/blocks/templates/posts/large.html b/layouts/partials/blocks/templates/posts/large.html index c434aa6606cf8706eff3be0506158ea2354b1bcd..d1279d2142cab4c1816abe60c383ff0fcbd90f0c 100644 --- a/layouts/partials/blocks/templates/posts/large.html +++ b/layouts/partials/blocks/templates/posts/large.html @@ -5,13 +5,13 @@ "attributes" "class='post-title' itemprop='headline'" )}} {{ $index := .index}} - +{{ $options := .options }} <div class="large"> {{ range .posts }} {{ with site.GetPage (printf "/posts/%s" .) }} - {{ if .Params.image }} + {{ if and .Params.image (eq $options.hide_image false) }} {{- $direction = partial "GetImageDirection" .Params.image -}} {{ end }} @@ -24,17 +24,19 @@ {{ $heading_tag.close }} <div class="post-meta"> - {{ if site.Params.posts.index.show_author }} + {{ if and site.Params.posts.index.show_author (eq $options.hide_author false) }} {{- partial "posts/author" . -}} {{ end }} - <time itemprop="datePublished" datetime="{{ .Date.Format "2006-01-02T15:04" }}">{{ .Date | time.Format site.Params.posts.date_format }}</time> - {{ if site.Params.posts.index.show_categories }} + {{ if eq $options.hide_date false }} + <time itemprop="datePublished" datetime="{{ .Date.Format "2006-01-02T15:04" }}">{{ .Date | time.Format site.Params.posts.date_format }}</time> + {{ end }} + {{ if and site.Params.posts.index.show_categories (eq $options.hide_cathegory false) }} {{- partial "posts/categories" . -}} {{ end }} </div> - {{ if site.Params.posts.index.show_description }} + {{ if and site.Params.posts.index.show_description (eq $options.hide_summary false) }} {{- if (partial "GetTextFromHTML" .Params.summary) -}} <p itemprop="articleBody">{{ partial "GetTruncateContent" ( dict "text" .Params.summary @@ -44,18 +46,19 @@ {{- end -}} <p class="more meta" aria-hidden="true">{{- i18n "commons.more" -}}</p> </div> - - <div class="media"> - {{- if .Params.image -}} - {{- partial "commons/image.html" - (dict - "image" .Params.image - "sizes" site.Params.image_sizes.sections.posts.item - ) -}} - {{- else -}} - {{- partial "commons/image-default.html" "posts" -}} - {{- end -}} - </div> + {{ if eq $options.hide_image false }} + <div class="media"> + {{- if .Params.image -}} + {{- partial "commons/image.html" + (dict + "image" .Params.image + "sizes" site.Params.image_sizes.sections.posts.item + ) -}} + {{- else -}} + {{- partial "commons/image-default.html" "posts" -}} + {{- end -}} + </div> + {{- end -}} </article> {{ end }} {{ end }} diff --git a/layouts/partials/blocks/templates/posts/list.html b/layouts/partials/blocks/templates/posts/list.html index 50ab8eb6f4670e98d084638ed11dc60be816dfe3..ef9714db536bcdac59a9b1c62324c9ac5f0537be 100644 --- a/layouts/partials/blocks/templates/posts/list.html +++ b/layouts/partials/blocks/templates/posts/list.html @@ -1,10 +1,14 @@ {{ $heading_level := .heading_level | default 3 }} {{ $heading := printf "h%d" $heading_level }} +{{ $alternate := .alternate }} +{{ $options := .options }} + <div class="list"> {{ range $post := .posts -}} {{ with site.GetPage (printf "/posts/%s" $post) }} {{ partial "posts/post.html" (dict "post" . + "options" $options "heading" $heading) }} {{ end }} {{ end }} diff --git a/layouts/partials/posts/post.html b/layouts/partials/posts/post.html index eb9f661498990a25fe620c8d05ae53db427a3329..3173d943b7194a332bd86d583c061259ce093b69 100644 --- a/layouts/partials/posts/post.html +++ b/layouts/partials/posts/post.html @@ -7,6 +7,11 @@ ) }} {{ $index := .index}} {{ $alternate := .alternate }} +{{- $show_image := (eq .options.hide_image false) -}} +{{- $show_summary := (eq .options.hide_summary false) -}} +{{- $show_category := (eq .options.hide_category false) -}} +{{- $show_author := (eq .options.hide_author false) -}} +{{- $show_date := (eq .options.hide_date false) -}} {{ with $post }} @@ -22,11 +27,11 @@ <a href="{{ .Permalink }}" title="{{ safeHTML (i18n "commons.more_aria" (dict "Title" $title)) }}">{{ $title }}</a> {{ $heading_tag.close }} - {{ if site.Params.posts.index.show_categories }} + {{ if and site.Params.posts.index.show_categories $show_category }} {{- partial "posts/categories" . -}} {{ end }} - {{ if site.Params.posts.index.show_description }} + {{ if and site.Params.posts.index.show_description $show_summary }} {{- if (partial "GetTextFromHTML" .Params.summary) -}} <p itemprop="articleBody">{{ partial "GetTruncateContent" ( dict "text" .Params.summary @@ -35,25 +40,31 @@ {{- end -}} {{- end -}} - <div class="post-meta"> - <time itemprop="datePublished" datetime="{{ .Date.Format "2006-01-02T15:04" }}">{{ .Date | time.Format site.Params.posts.date_format }}</time> - {{ if site.Params.posts.index.show_author }} - {{- partial "posts/author" . -}} - {{ end }} - </div> + {{ if or $show_author $show_date }} + <div class="post-meta"> + {{ if $show_date }} + <time itemprop="datePublished" datetime="{{ .Date.Format "2006-01-02T15:04" }}">{{ .Date | time.Format site.Params.posts.date_format }}</time> + {{ end }} + {{ if and site.Params.posts.index.show_author $show_author }} + {{- partial "posts/author" . -}} + {{ end }} + </div> + {{ end }} </div> - <div class="media"> - {{- if .Params.image -}} - {{- partial "commons/image.html" - (dict - "image" .Params.image - "sizes" site.Params.image_sizes.sections.posts.item - ) -}} - {{- else -}} - {{- partial "commons/image-default.html" "posts" -}} - {{- end -}} - </div> + {{ if $show_image }} + <div class="media"> + {{- if and .Params.image -}} + {{- partial "commons/image.html" + (dict + "image" .Params.image + "sizes" site.Params.image_sizes.sections.posts.item + ) -}} + {{- else -}} + {{- partial "commons/image-default.html" "posts" -}} + {{- end -}} + </div> + {{- end -}} </article> {{ end }} \ No newline at end of file