diff --git a/assets/scss/_custom.scss b/assets/scss/_custom.scss index 0bdc9fd2e7e45..f4464510b5d23 100644 --- a/assets/scss/_custom.scss +++ b/assets/scss/_custom.scss @@ -1964,6 +1964,9 @@ body.td-home section.case-studies { h2, h3 { text-align: center; } + &.case-studies--cncf { + text-align: center; + } .case-study-list { display: flex; flex-direction: row; diff --git a/content/en/case-studies/_index.html b/content/en/case-studies/_index.html index 4ab2b72e052c4..1209e7aa376b4 100644 --- a/content/en/case-studies/_index.html +++ b/content/en/case-studies/_index.html @@ -7,5 +7,6 @@ class: gridPage body_class: caseStudies cid: caseStudies +cncf_url: https://www.cncf.io/case-studies/?_sft_lf-project=kubernetes --- diff --git a/content/en/community/_index.html b/content/en/community/_index.html index fd5672daf375d..84e692fdc1edf 100644 --- a/content/en/community/_index.html +++ b/content/en/community/_index.html @@ -54,7 +54,7 @@ Releases
- Case Studies + {{< blocks/case-studies linkOnly="true" >}}
diff --git a/data/site_rendering/behaviors.yaml b/data/site_rendering/behaviors.yaml new file mode 100644 index 0000000000000..dbb504bfedfd8 --- /dev/null +++ b/data/site_rendering/behaviors.yaml @@ -0,0 +1,3 @@ +--- +website_rendering: + feature_flags_enabled: [] diff --git a/i18n/en/en.toml b/i18n/en/en.toml index eee1500671340..75b013b3e10c2 100644 --- a/i18n/en/en.toml +++ b/i18n/en/en.toml @@ -21,6 +21,12 @@ other = "Show More Posts..." [browser_clipboard_support_warning] other = "Sorry, your browser doesn't support copying this example to your clipboard." +[case_study_description] +other = "Read how organizations are using Kubernetes in production on the {{ .link }}." + +[case_study_title] +other = "Case Studies" + [case_study_prefix] other = "Case study:" diff --git a/layouts/index.redirects b/layouts/index.redirects index 7c44e335d0747..ed39bc20ab82f 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -12,6 +12,8 @@ /docs/reference/generated/kubernetes-api/latest/* /docs/reference/generated/kubernetes-api/{{ $latest }}/:splat 307 {{- end -}} +{{- partial "case-studies-redirects.html" . }} + # Include all existing static redirects {{- $staticRedirects := readFile "static/_redirects.base" -}} {{ $staticRedirects }} \ No newline at end of file diff --git a/layouts/partials/case-studies-redirects.html b/layouts/partials/case-studies-redirects.html new file mode 100644 index 0000000000000..40453743edbab --- /dev/null +++ b/layouts/partials/case-studies-redirects.html @@ -0,0 +1,20 @@ +{{- /* +Emit Netlify redirects for /case-studies pages when the +case_studies_are_cncf feature flag is enabled. Each locale whose +case-studies/_index.html sets `cncf_url` in its front matter gets +its /case-studies paths redirected to that URL. +*/ -}} +{{- $flags := site.Data.site_rendering.behaviors.website_rendering.feature_flags_enabled -}} +{{- if in $flags "case_studies_are_cncf" }} + +# Redirect case studies to CNCF (case_studies_are_cncf feature flag) + {{- range site.Sites }} + {{- $cs := .GetPage "case-studies" -}} + {{- with $cs }} + {{- with .Params.cncf_url }} +{{ $cs.RelPermalink }} {{ . }} 301! +{{ $cs.RelPermalink }}* {{ . }} 301! + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/layouts/shortcodes/blocks/case-studies.html b/layouts/shortcodes/blocks/case-studies.html index d490a2af51293..abafef0ec30fb 100644 --- a/layouts/shortcodes/blocks/case-studies.html +++ b/layouts/shortcodes/blocks/case-studies.html @@ -1,15 +1,31 @@ -{{- $caseStudiesSection := site.GetPage "case-studies" -}} -{{- if not $caseStudiesSection -}} -{{ errorf "[%s] No case-studies section found. Create content/%s/case-studies/_index.md" $.Page.Lang $.Page.Lang }} +{{- $flags := site.Data.site_rendering.behaviors.website_rendering.feature_flags_enabled -}} +{{- $linkOnly := eq (.Get "linkOnly" | default "false") "true" -}} +{{- $caseStudies := site.GetPage "case-studies" -}} +{{- if not $caseStudies -}} +{{- errorf "[%s] No case-studies section found. Create content/%s/case-studies/_index.md" $.Page.Lang $.Page.Lang -}} {{- else -}} -{{ $caseStudiesPages := where $caseStudiesSection.Pages "Params.featured" true | first 4 }} +{{- $cncfURL := $caseStudies.Params.cncf_url -}} +{{- $useCNCF := and (in $flags "case_studies_are_cncf") $cncfURL -}} +{{- if $linkOnly -}} + {{- if $useCNCF -}} +{{ $caseStudies.LinkTitle }} + {{- else -}} +{{ $caseStudies.LinkTitle }} + {{- end -}} +{{- else if $useCNCF -}} +
+

{{ $caseStudies.LinkTitle }}

+

{{ T "case_study_description" (dict "link" (printf "%s" $cncfURL $caseStudies.LinkTitle)) | safeHTML }}

+
+{{- else -}} +{{ $caseStudiesPages := where $caseStudies.Pages "Params.featured" true | first 4 }}
-

{{ $caseStudiesSection.LinkTitle }}

+

{{ $caseStudies.LinkTitle }}

{{- range $caseStudiesPages -}} {{ $dark := .Resources.GetMatch "**{dark_logo}*.svg" }} {{ $logo := .Resources.GetMatch "**{featured_logo}*.svg" }} - + {{ if not $logo }} {{ $logo = .Resources.GetMatch "**logo*.png" }} {{ end }} @@ -24,7 +40,8 @@

{{ $caseStudiesSection.Link

"{{ .Params.quote | truncate 100 }}"

{{ T "main_read_more" }}

- {{- end -}} + {{- end -}}
{{- end -}} +{{- end -}}