From 4093ed32ee6390223a885a676d0a3086257b8789 Mon Sep 17 00:00:00 2001
From: XhmikosR
Date: Mon, 1 Apr 2024 21:52:45 +0300
Subject: [PATCH] docs: add a new partial for responsive images and use
`imageConfig` (#39779)
This way the dimensions are not hardcoded
---
site/layouts/_default/single.html | 26 +++----------------
site/layouts/partials/examples/bs-themes.html | 17 ++++++++++++
site/layouts/partials/home/icons.html | 8 +++---
site/layouts/partials/home/masthead.html | 12 ++++-----
site/layouts/partials/home/themes.html | 8 +++---
site/layouts/partials/responsive-img.html | 22 ++++++++++++++++
6 files changed, 55 insertions(+), 38 deletions(-)
create mode 100644 site/layouts/partials/examples/bs-themes.html
create mode 100644 site/layouts/partials/responsive-img.html
diff --git a/site/layouts/_default/single.html b/site/layouts/_default/single.html
index 3175c55c08..427ee76c8d 100644
--- a/site/layouts/_default/single.html
+++ b/site/layouts/_default/single.html
@@ -28,29 +28,9 @@
{{ .Content }}
- {{ if eq .Title "Examples" }}
-
-
-
-
- {{ partial "icons/droplet-fill.svg" (dict "width" "32" "height" "32") }}
-
-
Go further with Bootstrap Themes
-
- Need something more than these examples? Take Bootstrap to the next level with premium themes from the official Bootstrap Themes marketplace . They’re built as their own extended frameworks, rich with new components and plugins, documentation, and powerful build tools.
-
-
Browse themes
-
-
-
- {{ end }}
+ {{ if eq .Title "Examples" -}}
+ {{ partial "examples/bs-themes" . }}
+ {{- end }}
{{ end }}
diff --git a/site/layouts/partials/examples/bs-themes.html b/site/layouts/partials/examples/bs-themes.html
new file mode 100644
index 0000000000..b426d0723f
--- /dev/null
+++ b/site/layouts/partials/examples/bs-themes.html
@@ -0,0 +1,17 @@
+
+
+
+
+ {{ partial "icons/droplet-fill.svg" (dict "width" "32" "height" "32") }}
+
+
Go further with Bootstrap Themes
+
+ Need something more than these examples? Take Bootstrap to the next level with premium themes from the official Bootstrap Themes marketplace . They’re built as their own extended frameworks, rich with new components and plugins, documentation, and powerful build tools.
+
+
Browse themes
+
+ {{ partial "responsive-img" (dict "context" .
+ "imgPath" "/assets/img/bootstrap-themes-collage.png"
+ "alt" "Bootstrap Themes"
+ "classes" "d-block mt-3") }}
+
diff --git a/site/layouts/partials/home/icons.html b/site/layouts/partials/home/icons.html
index 5cc7f14173..7ec81764e0 100644
--- a/site/layouts/partials/home/icons.html
+++ b/site/layouts/partials/home/icons.html
@@ -15,9 +15,9 @@
-
+ {{ partial "responsive-img" (dict "context" .
+ "imgPath" "/assets/img/bootstrap-icons.png"
+ "alt" "Bootstrap Icons"
+ "classes" "d-block mt-3") }}
diff --git a/site/layouts/partials/home/masthead.html b/site/layouts/partials/home/masthead.html
index d4ec0c0264..4fb36f62f2 100644
--- a/site/layouts/partials/home/masthead.html
+++ b/site/layouts/partials/home/masthead.html
@@ -10,13 +10,11 @@
-
+ {{ partial "responsive-img" (dict "context" .
+ "imgPath" "/assets/brand/bootstrap-logo-shadow.png"
+ "alt" "Bootstrap"
+ "classes" "d-none d-sm-block mb-3"
+ "lazyload" false) }}
Build fast, responsive sites with Bootstrap
Powerful, extensible, and feature-packed frontend toolkit. Build and customize with Sass, utilize prebuilt grid system and components, and bring projects to life with powerful JavaScript plugins.
diff --git a/site/layouts/partials/home/themes.html b/site/layouts/partials/home/themes.html
index 3e286f2671..add1a3583e 100644
--- a/site/layouts/partials/home/themes.html
+++ b/site/layouts/partials/home/themes.html
@@ -15,9 +15,9 @@
-
+ {{ partial "responsive-img" (dict "context" .
+ "imgPath" "/assets/img/bootstrap-themes.png"
+ "alt" "Bootstrap Themes"
+ "classes" "d-block mt-3") }}
diff --git a/site/layouts/partials/responsive-img.html b/site/layouts/partials/responsive-img.html
new file mode 100644
index 0000000000..06aafb6aa7
--- /dev/null
+++ b/site/layouts/partials/responsive-img.html
@@ -0,0 +1,22 @@
+{{- /*
+ Accepts context, classes, imgPath, alt and lazyload
+*/ -}}
+
+{{- $lazy := .lazyload | default true -}}
+{{- $classes := slice "img-fluid" "mx-auto" | append (slice .classes) -}}
+
+{{- $basePath := path.Join "/docs" .context.Site.Params.docs_version (path.Dir .imgPath) -}}
+{{- $basename := path.BaseName .imgPath -}}
+{{- $ext := path.Ext .imgPath -}}
+{{- $imgPath := path.Join $basePath (printf "%s%s" $basename $ext) -}}
+{{- $imgPath2x := path.Join $basePath (printf "%s@2x%s" $basename $ext) -}}
+
+{{- with (imageConfig (path.Join "/site/static" $imgPath)) }}
+
+{{- end }}