Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions assets/scss/_custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions content/en/case-studies/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
class: gridPage
body_class: caseStudies
cid: caseStudies
cncf_url: https://www.cncf.io/case-studies/?_sft_lf-project=kubernetes
---

2 changes: 1 addition & 1 deletion content/en/community/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<a href="/releases">Releases</a>
</div>
<div class="community-nav-item">
<a href="/case-studies">Case Studies</a>
{{< blocks/case-studies linkOnly="true" >}}
</div>
</div>

Expand Down
3 changes: 3 additions & 0 deletions data/site_rendering/behaviors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
website_rendering:
feature_flags_enabled: []

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I put case_studies_are_cncf here and go directly to /case-studies, what happens?

Now, what to do about that? We have a layout that renders Netlify redirects. How about a partial that conditionally redirects all the actual case studies to the right place?

It may need a list (English, Chinese) of which locales have a CNCF equivalent.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do have a new list of target localizations, maybe it can go in, eg, data/case_studies/cncf.yaml

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting, we have a redirect to cncf managed case studies based on localization? @lmktfy

If that's the case, I am not sure cncf have localization. My thoughts is everyone is redirected to the cncf page

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 changes: 6 additions & 0 deletions i18n/en/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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:"

Expand Down
2 changes: 2 additions & 0 deletions layouts/index.redirects
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
20 changes: 20 additions & 0 deletions layouts/partials/case-studies-redirects.html
Original file line number Diff line number Diff line change
@@ -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 }}
31 changes: 24 additions & 7 deletions layouts/shortcodes/blocks/case-studies.html
Original file line number Diff line number Diff line change
@@ -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 -}}
<a href="{{ $cncfURL }}" target="_blank" rel="noopener">{{ $caseStudies.LinkTitle }}</a>
{{- else -}}
<a href="{{ $caseStudies.RelPermalink }}">{{ $caseStudies.LinkTitle }}</a>
{{- end -}}
{{- else if $useCNCF -}}
<section class="case-studies case-studies--cncf">
<h3>{{ $caseStudies.LinkTitle }}</h3>
<p>{{ T "case_study_description" (dict "link" (printf "<a href=\"%s\" target=\"_blank\" rel=\"noopener\">%s</a>" $cncfURL $caseStudies.LinkTitle)) | safeHTML }}</p>
</section>
{{- else -}}
{{ $caseStudiesPages := where $caseStudies.Pages "Params.featured" true | first 4 }}
<section class="case-studies">
<h3><a href="{{ $caseStudiesSection.RelPermalink }}">{{ $caseStudiesSection.LinkTitle }}</a></h3>
<h3><a href="{{ $caseStudies.RelPermalink }}">{{ $caseStudies.LinkTitle }}</a></h3>
<div class="case-study-list">
{{- range $caseStudiesPages -}}
{{ $dark := .Resources.GetMatch "**{dark_logo}*.svg" }}
{{ $logo := .Resources.GetMatch "**{featured_logo}*.svg" }}

{{ if not $logo }}
{{ $logo = .Resources.GetMatch "**logo*.png" }}
{{ end }}
Expand All @@ -24,7 +40,8 @@ <h3><a href="{{ $caseStudiesSection.RelPermalink }}">{{ $caseStudiesSection.Link
<p>"{{ .Params.quote | truncate 100 }}"</p>
<a href="{{ .RelPermalink }}">{{ T "main_read_more" }}</a>
</div>
{{- end -}}
{{- end -}}
</div>
</section>
{{- end -}}
{{- end -}}