From 8592c9c57602112b2ab109d87b91458a63615987 Mon Sep 17 00:00:00 2001 From: caesarsage Date: Sat, 28 Mar 2026 00:11:11 +0100 Subject: [PATCH 1/2] Add feature flag to redirect case studies to CNCF --- content/en/community/_index.html | 10 +++++----- data/site_rendering/behaviors.yaml | 3 +++ i18n/en/en.toml | 6 ++++++ layouts/shortcodes/blocks/case-studies.html | 12 ++++++++++-- layouts/shortcodes/case-studies-link.html | 6 ++++++ 5 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 data/site_rendering/behaviors.yaml create mode 100644 layouts/shortcodes/case-studies-link.html diff --git a/content/en/community/_index.html b/content/en/community/_index.html index 7bd20b40e1d79..4239925202af3 100644 --- a/content/en/community/_index.html +++ b/content/en/community/_index.html @@ -54,7 +54,7 @@ Releases
- Case Studies + {{< case-studies-link >}}
@@ -202,12 +202,12 @@

Recent News

(async function() { const feedContainer = document.getElementById('bluesky-feed-container'); const bskyHandle = 'kubernetes.io'; - + try { // Fetching from the public Bluesky XRPC API const response = await fetch(`https://public.api.bsky.app/xrpc/app.bsky.feed.getAuthorFeed?actor=${bskyHandle}&limit=3`); if (!response.ok) throw new Error('Bluesky feed unavailable'); - + const data = await response.json(); feedContainer.innerHTML = ''; // Clear the loading message @@ -215,12 +215,12 @@

Recent News

const post = item.post; const postDate = new Date(post.indexedAt).toLocaleDateString(); const postUrl = `https://bsky.app/profile/${bskyHandle}/post/${post.uri.split('/').pop()}`; - + const postElement = document.createElement('div'); postElement.className = 'bsky-post'; postElement.style.padding = "15px 0"; postElement.style.borderBottom = "1px solid #eee"; - + postElement.innerHTML = `

${post.record.text}

${postDate} • View on Bluesky 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 04b8638984699..79255e8e3e475 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/shortcodes/blocks/case-studies.html b/layouts/shortcodes/blocks/case-studies.html index d490a2af51293..f283c3a7d21c3 100644 --- a/layouts/shortcodes/blocks/case-studies.html +++ b/layouts/shortcodes/blocks/case-studies.html @@ -1,3 +1,10 @@ +{{ $flags := site.Data.site_rendering.behaviors.website_rendering.feature_flags_enabled }} +{{ if in $flags "case_studies_are_cncf" }} +
+

{{ T "case_study_title" }}

+

{{ T "case_study_description" (dict "link" (printf "%s" "https://www.cncf.io/case-studies/?_sft_lf-project=kubernetes" (T "case_study_title"))) | safeHTML }}

+
+{{ else }} {{- $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 }} @@ -9,7 +16,7 @@

{{ $caseStudiesSection.Link {{- 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 +31,8 @@

{{ $caseStudiesSection.Link

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

{{ T "main_read_more" }} - {{- end -}} + {{- end -}} {{- end -}} +{{ end }} diff --git a/layouts/shortcodes/case-studies-link.html b/layouts/shortcodes/case-studies-link.html new file mode 100644 index 0000000000000..f63db318068cf --- /dev/null +++ b/layouts/shortcodes/case-studies-link.html @@ -0,0 +1,6 @@ +{{- $flags := site.Data.site_rendering.behaviors.website_rendering.feature_flags_enabled -}} +{{- if in $flags "case_studies_are_cncf" -}} +{{ T "case_study_title" }} +{{- else -}} +{{ T "case_study_title" }} +{{- end -}} From d5e952f8e3c8e8e40dcdd6b2a51aed25861a4bc9 Mon Sep 17 00:00:00 2001 From: caesarsage Date: Mon, 18 May 2026 02:47:27 +0100 Subject: [PATCH 2/2] consolidate case-studies shortcodes and add CNCF redirect --- assets/scss/_custom.scss | 3 ++ content/en/case-studies/_index.html | 1 + content/en/community/_index.html | 2 +- layouts/index.redirects | 2 ++ layouts/partials/case-studies-redirects.html | 20 ++++++++++++ layouts/shortcodes/blocks/case-studies.html | 33 +++++++++++++------- layouts/shortcodes/case-studies-link.html | 6 ---- 7 files changed, 48 insertions(+), 19 deletions(-) create mode 100644 layouts/partials/case-studies-redirects.html delete mode 100644 layouts/shortcodes/case-studies-link.html 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 4035c36562539..84e692fdc1edf 100644 --- a/content/en/community/_index.html +++ b/content/en/community/_index.html @@ -54,7 +54,7 @@ Releases
- {{< case-studies-link >}} + {{< blocks/case-studies linkOnly="true" >}}
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 f283c3a7d21c3..abafef0ec30fb 100644 --- a/layouts/shortcodes/blocks/case-studies.html +++ b/layouts/shortcodes/blocks/case-studies.html @@ -1,17 +1,26 @@ -{{ $flags := site.Data.site_rendering.behaviors.website_rendering.feature_flags_enabled }} -{{ if in $flags "case_studies_are_cncf" }} -
-

{{ T "case_study_title" }}

-

{{ T "case_study_description" (dict "link" (printf "%s" "https://www.cncf.io/case-studies/?_sft_lf-project=kubernetes" (T "case_study_title"))) | safeHTML }}

+{{- $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 -}} +{{- $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 }} -{{- $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 }} {{- else -}} -{{ $caseStudiesPages := where $caseStudiesSection.Pages "Params.featured" true | first 4 }} +{{ $caseStudiesPages := where $caseStudies.Pages "Params.featured" true | first 4 }}
-

{{ $caseStudiesSection.LinkTitle }}

+

{{ $caseStudies.LinkTitle }}

{{- range $caseStudiesPages -}} {{ $dark := .Resources.GetMatch "**{dark_logo}*.svg" }} @@ -35,4 +44,4 @@

{{ $caseStudiesSection.Link

{{- end -}} -{{ end }} +{{- end -}} diff --git a/layouts/shortcodes/case-studies-link.html b/layouts/shortcodes/case-studies-link.html deleted file mode 100644 index f63db318068cf..0000000000000 --- a/layouts/shortcodes/case-studies-link.html +++ /dev/null @@ -1,6 +0,0 @@ -{{- $flags := site.Data.site_rendering.behaviors.website_rendering.feature_flags_enabled -}} -{{- if in $flags "case_studies_are_cncf" -}} -{{ T "case_study_title" }} -{{- else -}} -{{ T "case_study_title" }} -{{- end -}}