From d114c65d4058cbece13312d31eec3499a26d7c3e Mon Sep 17 00:00:00 2001 From: alexisben <alex@noesya.coop> Date: Tue, 10 Jan 2023 11:54:15 +0100 Subject: [PATCH] configuration wip --- config.yaml | 96 +++++++++++++++++++ layouts/partials/GetLightboxUrl | 2 +- .../blocks/templates/call_to_action.html | 4 +- .../partials/blocks/templates/chapter.html | 4 +- .../blocks/templates/gallery/carousel.html | 4 +- .../blocks/templates/gallery/grid.html | 4 +- layouts/partials/blocks/templates/image.html | 4 +- .../blocks/templates/organization_chart.html | 4 +- .../partials/blocks/templates/partners.html | 4 +- .../blocks/templates/testimonials.html | 4 +- layouts/partials/commons/image.html | 20 ++-- layouts/partials/diplomas/hero-single.html | 4 +- layouts/partials/diplomas/image.html | 17 ---- layouts/partials/header/hero.html | 4 +- layouts/partials/organizations/logo.html | 4 +- .../partials/organizations/organization.html | 4 +- layouts/partials/pages/children.html | 2 - layouts/partials/pages/page-media.html | 4 +- layouts/partials/pages/page.html | 13 +-- layouts/partials/pages/pages.html | 2 - layouts/partials/persons/hero-single.html | 12 +-- layouts/partials/persons/hero.html | 1 + layouts/partials/persons/image.html | 17 ---- layouts/partials/persons/person.html | 6 +- layouts/partials/posts/image.html | 17 ---- layouts/partials/posts/post.html | 4 +- layouts/partials/programs/image.html | 4 +- layouts/partials/programs/program.html | 18 ---- layouts/partials/volumes/image.html | 13 --- layouts/partials/volumes/volume.html | 4 +- layouts/volumes/term.html | 1 - 31 files changed, 137 insertions(+), 164 deletions(-) delete mode 100644 layouts/partials/diplomas/image.html delete mode 100644 layouts/partials/persons/image.html delete mode 100644 layouts/partials/posts/image.html delete mode 100644 layouts/partials/volumes/image.html diff --git a/config.yaml b/config.yaml index 4e605329..499f3e3e 100644 --- a/config.yaml +++ b/config.yaml @@ -17,3 +17,99 @@ params: logo: header: "/assets/images/logo.svg" footer: "/assets/images/logo.svg" + + image_sizes: + design_system: + lightbox: + # TODO mobile et tablet + mobile: 1920x2560 + tablet: 1920x2560 + desktop: 1920x2560 + hero: + mobile: 400 + tablet: 800 + desktop: 900 + blocks: + call_to_action: + mobile: 164 + tablet: 350 + desktop: 415 + chapter: + mobile: 350 + tablet: 450 + desktop: 1280 + image: + mobile: 480x850 + tablet: 768x1360 + desktop: 1400x1820 + organization_chart: + mobile: 80 + tablet: 100 + desktop: 255 + partners: + mobile: 164 + tablet: 216 + desktop: 196 + testimonials: + desktop: 200 + gallery: + carousel: + mobile: 400 + tablet: 600 + desktop: 1024 + grid: + mobile: 170 + tablet: 350 + desktop: 415 + sections: + diplomas: + hero_single: + mobile: 351 + tablet: 456 + desktop: 856 + organizations: + logo: + mobile: 331 + tablet: 196 + desktop: 396 + item: + mobile: 144 + tablet: 196 + desktop: 176 + pages: + hero: + mobile: 400 + tablet: 800 + desktop: 900 + item: + mobile: 350 + tablet: 400 + desktop: 900 + persons: + hero: + mobile: 200 + tablet: 200 + desktop: 415 + hero_single: + mobile: 200 + tablet: 200 + desktop: 415 + item: + mobile: 80 + tablet: 100 + desktop: 255 + posts: + item: + mobile: 350 + tablet: 450 + desktop: 900 + programs: + image: + mobile: 351x168 + tablet: 456x219 + desktop: 856x410 + volumes: + item: + mobile: 327x388 + tablet: 208x247 + desktop: 300x356 \ No newline at end of file diff --git a/layouts/partials/GetLightboxUrl b/layouts/partials/GetLightboxUrl index e4993a61..7ea489ee 100644 --- a/layouts/partials/GetLightboxUrl +++ b/layouts/partials/GetLightboxUrl @@ -2,7 +2,7 @@ {{ if isset . "id" }} {{ $id = .id }} {{ end }} -{{ $lightbox_sizes := "1920x2560" }} +{{ $lightbox_sizes := site.Params.image_sizes.design_system.lightbox.desktop }} {{ $image := partial "GetMedia" $id }} {{ $url := "" }} diff --git a/layouts/partials/blocks/templates/call_to_action.html b/layouts/partials/blocks/templates/call_to_action.html index 2fae0fcd..a4bba7c4 100644 --- a/layouts/partials/blocks/templates/call_to_action.html +++ b/layouts/partials/blocks/templates/call_to_action.html @@ -43,9 +43,7 @@ (dict "image" .image.file "alt" .image.alt - "mobile" "164x164" - "tablet" "336x336" - "desktop" "416x416" + "sizes" site.Params.image_sizes.blocks.call_to_action )}} </div> diff --git a/layouts/partials/blocks/templates/chapter.html b/layouts/partials/blocks/templates/chapter.html index bb0c6750..3f7f11c7 100644 --- a/layouts/partials/blocks/templates/chapter.html +++ b/layouts/partials/blocks/templates/chapter.html @@ -46,9 +46,7 @@ {{ partial "commons/image.html" (dict "image" .image - "mobile" "350x350" - "tablet" "450x450" - "desktop" "1280x1280" + "sizes" site.Params.image_sizes.blocks.chapter )}} </a> {{ if partial "GetTextFromHTML" .credit }} diff --git a/layouts/partials/blocks/templates/gallery/carousel.html b/layouts/partials/blocks/templates/gallery/carousel.html index 67fdbeb1..a787ab3f 100644 --- a/layouts/partials/blocks/templates/gallery/carousel.html +++ b/layouts/partials/blocks/templates/gallery/carousel.html @@ -23,9 +23,7 @@ (dict "image" .id "alt" .alt - "mobile" "400" - "tablet" "600" - "desktop" "1024" + "sizes" site.Params.image_sizes.blocks.gallery.carousel )}} </a> {{ if or .text .credit }} diff --git a/layouts/partials/blocks/templates/gallery/grid.html b/layouts/partials/blocks/templates/gallery/grid.html index b8764523..fe5a4a1c 100644 --- a/layouts/partials/blocks/templates/gallery/grid.html +++ b/layouts/partials/blocks/templates/gallery/grid.html @@ -13,9 +13,7 @@ (dict "image" .file "alt" .alt - "mobile" "164" - "tablet" "336" - "desktop" "416" + "sizes" site.Params.image_sizes.blocks.gallery.grid )}} </a> {{ if .text }} diff --git a/layouts/partials/blocks/templates/image.html b/layouts/partials/blocks/templates/image.html index f27221ff..0ef25bc1 100644 --- a/layouts/partials/blocks/templates/image.html +++ b/layouts/partials/blocks/templates/image.html @@ -36,9 +36,7 @@ (dict "image" . "alt" .alt - "mobile" "480x850" - "tablet" "768x1360" - "desktop" "1400x1820" + "sizes" site.Params.image_sizes.blocks.image )}} </a> <figcaption> diff --git a/layouts/partials/blocks/templates/organization_chart.html b/layouts/partials/blocks/templates/organization_chart.html index 131ef46c..05cb54c6 100644 --- a/layouts/partials/blocks/templates/organization_chart.html +++ b/layouts/partials/blocks/templates/organization_chart.html @@ -51,9 +51,7 @@ {{ partial "commons/image.html" (dict "image" $person.Params.image - "mobile" "80x80" - "tablet" "100x100" - "desktop" "255x255" + "sizes" site.Params.image_sizes.blocks.organization_chart )}} {{ end -}} </div> diff --git a/layouts/partials/blocks/templates/partners.html b/layouts/partials/blocks/templates/partners.html index 072f9dee..34034755 100644 --- a/layouts/partials/blocks/templates/partners.html +++ b/layouts/partials/blocks/templates/partners.html @@ -51,9 +51,7 @@ (dict "image" .logo "alt" $title - "mobile" "164" - "tablet" "216" - "desktop" "196" + "sizes" site.Params.image_sizes.blocks.partners ) -}} {{- end -}} </div> diff --git a/layouts/partials/blocks/templates/testimonials.html b/layouts/partials/blocks/templates/testimonials.html index d86ba153..b45b99ff 100644 --- a/layouts/partials/blocks/templates/testimonials.html +++ b/layouts/partials/blocks/templates/testimonials.html @@ -51,9 +51,7 @@ (dict "image" .photo "alt" .author - "mobile" "192x192" - "tablet" "192x192" - "desktop" "192x192" + "sizes" site.Params.image_sizes.blocks.testimonials ) -}} </div> {{- end }} diff --git a/layouts/partials/commons/image.html b/layouts/partials/commons/image.html index 8c43d6fc..2cc6d1ba 100644 --- a/layouts/partials/commons/image.html +++ b/layouts/partials/commons/image.html @@ -24,6 +24,14 @@ {{- if .crop -}} {{- $crop = true -}} {{- end -}} + {{ $desktop := .desktop }} + {{ $tablet := .tablet }} + {{ $mobile := .mobile }} + {{- if .sizes -}} + {{ $desktop = .sizes.desktop }} + {{ $tablet = .sizes.tablet }} + {{ $mobile = .sizes.mobile }} + {{- end -}} <picture> {{- if strings.HasSuffix $image.name "svg" -}} @@ -39,32 +47,32 @@ {{- else -}} - {{ with .desktop -}} + {{ with $desktop -}} <source srcset="{{ partial "GetImageUrl" (dict "url" $url "size" . "format" "webp" "crop" $crop ) }}, {{ partial "GetImageUrl" (dict "url" $url "size" . "format" "webp" "scale" 2 "crop" $crop) }} 2x" media="(min-width: 1024px)" type="image/webp"> {{- end }} - {{ with .tablet -}} + {{ with $tablet -}} <source srcset="{{ partial "GetImageUrl" (dict "url" $url "size" . "format" "webp" "crop" $crop) }}, {{ partial "GetImageUrl" (dict "url" $url "size" . "format" "webp" "scale" 2 "crop" $crop) }} 2x" media="(min-width: 768px)" type="image/webp"> {{- end }} - {{ with .mobile -}} + {{ with $mobile -}} <source srcset="{{ partial "GetImageUrl" (dict "url" $url "size" . "format" "webp" "crop" $crop) }}, {{ partial "GetImageUrl" (dict "url" $url "size" . "format" "webp" "scale" 2 "crop" $crop) }} 2x" type="image/webp"> {{- end }} - {{ with .desktop -}} + {{ with $desktop -}} <source srcset="{{ partial "GetImageUrl" (dict "url" $url "size" . "crop" $crop ) }}, {{ partial "GetImageUrl" (dict "url" $url "size" . "scale" 2 "crop" $crop) }} 2x" media="(min-width: 1024px)"> {{- end }} - {{ with .tablet -}} + {{ with $tablet -}} <source srcset="{{ partial "GetImageUrl" (dict "url" $url "size" . "crop" $crop ) }}, {{ partial "GetImageUrl" (dict "url" $url "size" . "scale" 2 "crop" $crop) }} 2x" media="(min-width: 768px)"> {{- end }} - {{ with .mobile -}} + {{ with $mobile -}} <source srcset="{{ partial "GetImageUrl" (dict "url" $url "size" . "crop" $crop ) }}, {{ partial "GetImageUrl" (dict "url" $url "size" . "scale" 2 "crop" $crop) }} 2x"> {{- end }} diff --git a/layouts/partials/diplomas/hero-single.html b/layouts/partials/diplomas/hero-single.html index 4577aee8..6bd1f431 100644 --- a/layouts/partials/diplomas/hero-single.html +++ b/layouts/partials/diplomas/hero-single.html @@ -11,9 +11,7 @@ {{ partial "commons/image.html" (dict "image" .image - "mobile" "351" - "tablet" "456" - "desktop" "856" + "sizes" site.Params.image_sizes.sections.diplomas.hero_single ) }} {{ if .image.credit }} <figcaption> diff --git a/layouts/partials/diplomas/image.html b/layouts/partials/diplomas/image.html deleted file mode 100644 index 40868e72..00000000 --- a/layouts/partials/diplomas/image.html +++ /dev/null @@ -1,17 +0,0 @@ -{{ if . }} - <figure class="featured-image"> - {{ partial "commons/image.html" - (dict - "image" . - "mobile" "351x168" - "tablet" "456x219" - "desktop" "856x410" - "itemprop" true - )}} - {{- if isset . "credit" -}} - {{ if partial "GetTextFromHTML" .credit }} - <figcaption>{{ partial "PrepareHTML" .credit }}</figcaption> - {{ end }} - {{- end -}} - </figure> -{{ end }} diff --git a/layouts/partials/header/hero.html b/layouts/partials/header/hero.html index 9cb3207e..3630d446 100644 --- a/layouts/partials/header/hero.html +++ b/layouts/partials/header/hero.html @@ -27,9 +27,7 @@ {{ partial "commons/image.html" (dict "image" .image - "mobile" "400" - "tablet" "800" - "desktop" "900" + "sizes" ( .sizes | default site.Params.image_sizes.design_system.hero ) "lazy" false ) }} {{ if .image.credit }} diff --git a/layouts/partials/organizations/logo.html b/layouts/partials/organizations/logo.html index b4fff2e0..5019960a 100644 --- a/layouts/partials/organizations/logo.html +++ b/layouts/partials/organizations/logo.html @@ -5,9 +5,7 @@ (dict "image" .Params.logo "alt" .Title - "mobile" "331" - "tablet" "196" - "desktop" "396" + "sizes" site.Params.image_sizes.sections.organizations.logo ) -}} </figure> {{- end -}} diff --git a/layouts/partials/organizations/organization.html b/layouts/partials/organizations/organization.html index 0891de6d..e434c3d8 100644 --- a/layouts/partials/organizations/organization.html +++ b/layouts/partials/organizations/organization.html @@ -9,9 +9,7 @@ (dict "image" .Params.logo "alt" $title - "mobile" "144" - "tablet" "196" - "desktop" "176" + "sizes" site.Params.image_sizes.sections.organizations.item ) -}} {{- end -}} </div> diff --git a/layouts/partials/pages/children.html b/layouts/partials/pages/children.html index a028a1c4..891d769c 100644 --- a/layouts/partials/pages/children.html +++ b/layouts/partials/pages/children.html @@ -6,9 +6,7 @@ <div> {{ $page := partial "GetPageByUrl" . }} {{ with $page }} - {{ .Scratch.Set "show_description" true }} {{ partial "pages/page.html" . }} - {{ .Scratch.Delete "show_description" }} {{ end }} </div> {{ end }} diff --git a/layouts/partials/pages/page-media.html b/layouts/partials/pages/page-media.html index 989f6d41..1f6e6e06 100644 --- a/layouts/partials/pages/page-media.html +++ b/layouts/partials/pages/page-media.html @@ -3,9 +3,7 @@ {{- partial "commons/image.html" (dict "image" .Params.image - "mobile" "350x350" - "tablet" "400x400" - "desktop" "900x900" + "sizes" site.Params.image_sizes.sections.pages.item ) -}} {{- else -}} {{- partial "commons/image-default.html" -}} diff --git a/layouts/partials/pages/page.html b/layouts/partials/pages/page.html index 95cb478b..a21cff2d 100644 --- a/layouts/partials/pages/page.html +++ b/layouts/partials/pages/page.html @@ -16,17 +16,8 @@ {{- partial "PrepareHTML" .Title -}} </a> {{- partial "PrepareHTML" (printf "</%s>" $heading) -}} - - {{- if .Scratch.Get "show_description" }} - {{- if .Params.description_short }} - <p>{{ partial "PrepareHTML" .Params.description_short }}</p> - {{ end -}} - {{ end -}} - {{- if .Scratch.Get "show_more" }} - <p class="more">{{- i18n "commons.more" -}}</p> + {{- if .Params.description_short }} + <p>{{ partial "PrepareHTML" .Params.description_short }}</p> {{ end -}} </div> - {{ if .Scratch.Get "show_image" }} - {{- partial "pages/page-media.html" . -}} - {{- end }} </article> diff --git a/layouts/partials/pages/pages.html b/layouts/partials/pages/pages.html index 48040bf6..f78350bb 100644 --- a/layouts/partials/pages/pages.html +++ b/layouts/partials/pages/pages.html @@ -1,9 +1,7 @@ <div class="pages"> {{ range .Paginator.Pages }} <div> - {{ .Scratch.Set "show_description" true }} {{ partial "pages/page.html" . }} - {{ .Scratch.Delete "show_description" }} </div> {{ end }} </div> diff --git a/layouts/partials/persons/hero-single.html b/layouts/partials/persons/hero-single.html index 847d4dc9..74dd7b9f 100644 --- a/layouts/partials/persons/hero-single.html +++ b/layouts/partials/persons/hero-single.html @@ -6,13 +6,11 @@ {{ if .Params.image }} <div class="avatar"> {{ partial "commons/image.html" - (dict - "image" .Params.image - "class" "img-fluid" - "mobile" "202x202" - "tablet" "192x192" - "desktop" "415x415" - )}} + (dict + "image" .Params.image + "class" "img-fluid" + "sizes" site.Params.image_sizes.sections.persons.hero_single + )}} </div> {{ end }} </div> diff --git a/layouts/partials/persons/hero.html b/layouts/partials/persons/hero.html index 8e7e675c..c346f266 100644 --- a/layouts/partials/persons/hero.html +++ b/layouts/partials/persons/hero.html @@ -4,4 +4,5 @@ "title" $title "image" .Params.image "context" . + "sizes" site.Params.image_sizes.sections.persons.hero ) -}} diff --git a/layouts/partials/persons/image.html b/layouts/partials/persons/image.html deleted file mode 100644 index c31b7b9b..00000000 --- a/layouts/partials/persons/image.html +++ /dev/null @@ -1,17 +0,0 @@ -{{ if . }} - <figure class="featured-image"> - {{ partial "commons/image.html" - (dict - "image" . - "mobile" "351x168" - "tablet" "456x219" - "desktop" "1232x450" - "itemprop" true - )}} - {{- if isset . "credit" -}} - {{ if partial "GetTextFromHTML" .credit }} - <figcaption>{{ partial "PrepareHTML" .credit }}</figcaption> - {{ end }} - {{- end -}} - </figure> -{{ end }} diff --git a/layouts/partials/persons/person.html b/layouts/partials/persons/person.html index 0047e2e5..6bdeb24d 100644 --- a/layouts/partials/persons/person.html +++ b/layouts/partials/persons/person.html @@ -12,11 +12,9 @@ {{- if .Params.image }} {{ partial "commons/image.html" (dict - "alt" .Title + "alt" .Title "image" .Params.image - "mobile" "80x80" - "tablet" "100x100" - "desktop" "255x255" + "sizes" site.Params.image_sizes.sections.persons.item )}} {{ end -}} </div> diff --git a/layouts/partials/posts/image.html b/layouts/partials/posts/image.html deleted file mode 100644 index eb398d08..00000000 --- a/layouts/partials/posts/image.html +++ /dev/null @@ -1,17 +0,0 @@ -{{ if . }} - <figure class="featured-image"> - {{ partial "commons/image.html" - (dict - "image" . - "mobile" "350x350" - "tablet" "450x450" - "desktop" "900x900" - "itemprop" true - )}} - {{- if isset . "credit" -}} - {{ if partial "GetTextFromHTML" .credit }} - <figcaption>{{ partial "PrepareHTML" .credit }}</figcaption> - {{ end }} - {{- end -}} - </figure> -{{ end }} diff --git a/layouts/partials/posts/post.html b/layouts/partials/posts/post.html index 1168ce5d..620cb59b 100644 --- a/layouts/partials/posts/post.html +++ b/layouts/partials/posts/post.html @@ -23,9 +23,7 @@ {{- partial "commons/image.html" (dict "image" .Params.image - "mobile" "350x350" - "tablet" "450x450" - "desktop" "900x900" + "sizes" site.Params.image_sizes.sections.posts.item ) -}} {{- else -}} {{- partial "commons/image-default.html" -}} diff --git a/layouts/partials/programs/image.html b/layouts/partials/programs/image.html index a6bc76f5..5774db7c 100644 --- a/layouts/partials/programs/image.html +++ b/layouts/partials/programs/image.html @@ -3,9 +3,7 @@ {{ partial "commons/image.html" (dict "image" . - "mobile" "351x168" - "tablet" "456x219" - "desktop" "856x410" + "sizes" site.Params.image_sizes.sections.programs.image "itemprop" true "crop" true )}} diff --git a/layouts/partials/programs/program.html b/layouts/partials/programs/program.html index 7efa8afb..45e78043 100644 --- a/layouts/partials/programs/program.html +++ b/layouts/partials/programs/program.html @@ -1,7 +1,3 @@ -{{- $with_image := false -}} -{{- if .Scratch.Get "with_image" -}} - {{- $with_image = true -}} -{{- end -}} {{- $title := partial "PrepareHTML" .Title -}} <article class="program"> <div> @@ -14,18 +10,4 @@ <p>{{- partial "PrepareHTML" .Params.presentation -}}</p> {{ end }} </div> - {{- if $with_image }} - {{- if .Params.image }} - <div class="media"> - {{ partial "commons/image.html" - (dict - "image" .Params.image - "mobile" "351x168" - "tablet" "456x219" - "desktop" "856x410" - "itemprop" true - )}} - </div> - {{ end -}} - {{ end -}} </article> diff --git a/layouts/partials/volumes/image.html b/layouts/partials/volumes/image.html deleted file mode 100644 index 38e5d66e..00000000 --- a/layouts/partials/volumes/image.html +++ /dev/null @@ -1,13 +0,0 @@ -{{- if .Params.image -}} - <div> - {{- partial "commons/image.html" - (dict - "image" .Params.image - "alt" .Title - "mobile" "327x388" - "tablet" "208x247" - "desktop" "300x356" - "class" "img-fluid" - ) -}} - </div> -{{- end -}} diff --git a/layouts/partials/volumes/volume.html b/layouts/partials/volumes/volume.html index 359caf27..09fc5ab2 100644 --- a/layouts/partials/volumes/volume.html +++ b/layouts/partials/volumes/volume.html @@ -9,9 +9,7 @@ (dict "image" .Params.image "alt" .Title - "mobile" "327x388" - "tablet" "208x247" - "desktop" "408x485" + "sizes" site.Params.image_sizes.sections.volumes.item ) -}} {{- else if site.Params.default_image.url -}} {{- partial "commons/image-default.html" (dict "class" "img-fluid") -}} diff --git a/layouts/volumes/term.html b/layouts/volumes/term.html index e81b3016..6f456eb0 100644 --- a/layouts/volumes/term.html +++ b/layouts/volumes/term.html @@ -13,7 +13,6 @@ <div class="container"> <div class="content"> - {{ partial "volumes/image.html" . }} {{ partial "volumes/description.html" . }} {{ partial "volumes/document-aside.html" . }} {{ partial "volumes/table-contents.html" . }} -- GitLab