From 77d27fc8bad64c9eb50332cf872720928b1a35cb Mon Sep 17 00:00:00 2001 From: alexisben <alex@noesya.coop> Date: Tue, 23 Jan 2024 10:58:10 +0100 Subject: [PATCH] handle new layout block page layout list --- assets/sass/_theme/blocks/pages.sass | 76 +++++++++++++------- layouts/partials/GetTruncateContent | 10 +-- layouts/partials/blocks/templates/pages.html | 16 +++-- 3 files changed, 63 insertions(+), 39 deletions(-) diff --git a/assets/sass/_theme/blocks/pages.sass b/assets/sass/_theme/blocks/pages.sass index 6a5065f9..0a3bd92f 100644 --- a/assets/sass/_theme/blocks/pages.sass +++ b/assets/sass/_theme/blocks/pages.sass @@ -167,12 +167,16 @@ .block-content .top margin-bottom: $spacing1 + .description + margin-bottom: $spacing2 ul.title-only @include grid(2, desktop) grid-row-gap: $spacing0 !important grid-column-gap: half($grid-gutter) !important li margin-top: 0 + a + @include meta article gap: half($grid-gutter) .media @@ -184,38 +188,56 @@ .block-title a @include stretched-link(before) - .block-content - @include grid - .top - align-items: initial - grid-column: 1 / 8 - margin-bottom: 0 - display: grid - grid-template-rows: subgrid - grid-row: span 2 - .block-title - width: auto - .description - @include body-text - margin-top: 0 - // Default behavior (without page description) + .top + .description + p + @include h2 + article + .media + width: col(4) + .page-content + width: col(8) + &:not(.with-description) ul.title-only - @include grid(4, desktop) + @include grid(4, desktop, space(2)) grid-column: 1 / 13 li margin-top: 0 - // If page description - .top + ul - grid-column: 9 / 13 - grid-row: 2 - display: block + ul:not(.title-only) + @include grid(2, desktop) li + li - margin-top: $spacing0 - article - .media - width: col(2, 6) - .page-content - width: col(4, 6) + margin-top: 0 + &.with-description + .block-content + @include grid(12, desktop, $spacing2) + row-gap: half($grid-gutter) + .top + align-items: initial + grid-column: 1 / 8 + margin-bottom: 0 + display: grid + grid-template-rows: subgrid + grid-row: span 2 + .block-title + width: auto + .description + @include body-text + margin-top: 0 + // If page description + .top + ul + grid-column: 9 / 13 + grid-row: 2 + display: block + li + li + margin-top: $spacing0 + article + margin-top: $spacing3 + &.with-images + .top + grid-column: 1 / 7 + .top + ul + grid-column: 7 / 13 + &--alternate .top diff --git a/layouts/partials/GetTruncateContent b/layouts/partials/GetTruncateContent index e540e620..23bd565a 100644 --- a/layouts/partials/GetTruncateContent +++ b/layouts/partials/GetTruncateContent @@ -1,9 +1,9 @@ {{ $length := .length | default 150 }} -{{ $text := replace .text "<" " <" }} +{{ $text := .text }} {{ if gt .length 0 }} + {{ $text = replace .text "<" " <" }} {{ $text = chomp (truncate $length "…" (safeHTML (plainify $text))) }} - {{ return $text }} -{{ else }} - {{ return .text }} -{{ end }} \ No newline at end of file +{{ end }} + +{{ return $text }} \ No newline at end of file diff --git a/layouts/partials/blocks/templates/pages.html b/layouts/partials/blocks/templates/pages.html index 8c76cce8..226dd0e9 100644 --- a/layouts/partials/blocks/templates/pages.html +++ b/layouts/partials/blocks/templates/pages.html @@ -4,8 +4,6 @@ {{- $layout := .block.data.layout | default "grid" -}} {{- with .block.data -}} - - {{- $show_main_page := false -}} {{- $show_main_description := .show_main_description -}} {{- $show_descriptions := .show_descriptions -}} {{- $show_images := .show_images -}} @@ -19,7 +17,6 @@ {{ end }} {{- with $page }} - {{- $show_main_page = true -}} {{- $page_link = $page.Permalink }} {{ if eq $title "" }} {{ $title = .Title }} @@ -39,13 +36,18 @@ {{ end }} {{ end -}} + {{ if $main_description }} + {{/* SHOULD BE FIXED WITH ORTHOTYPO */}} + {{ $main_description = printf "<p>%s</p>" $main_description }} + {{ $block_class = printf "%s %s" $block_class "with-description" }} + {{ end }} + {{ if $show_images }} + {{ $block_class = printf "%s %s" $block_class "with-images" }} + {{ end }} + <div class="{{ $block_class }} {{ $page_class }}"> <div class="container"> <div class="block-content"> - {{ if $main_description }} - {{ $main_description = printf "<p>%s</p>" $main_description }} - {{ end }} - {{ partial "blocks/top.html" (dict "title" $title "link" $page_link -- GitLab