-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from opentelekomcloud-infra/static-i18n
Localization
- Loading branch information
Showing
21 changed files
with
592 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Startpage from "@/components/pages/Startpage" | ||
import Head from "next/head" | ||
|
||
|
||
export default async function App() { | ||
const metadata = await generateMetadata(); | ||
const startpageProps = { | ||
locale: "de-DE" // Like Strapi API response | ||
} | ||
return ( | ||
<div> | ||
<Head> | ||
<title>{metadata.title}</title> | ||
<meta name="description" content={metadata.description} /> | ||
</Head> | ||
<Startpage props={startpageProps}></Startpage> | ||
</div> | ||
) | ||
} | ||
|
||
export async function generateMetadata() { | ||
return { | ||
title: "Discover the powerful services of our partners", | ||
description: "Many start-ups and cloud service providers already work together with us an partners, using our technology and infrastructure for their cloud projects. This is a testament to their trust in the Open Telekom Cloud and our great partnership. You can start using these services today to improve your IT systems or your company's communications and benefit from the advantages of the GDPR-compliant European cloud." | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Startpage from "@/components/pages/Startpage" | ||
import Head from "next/head" | ||
|
||
|
||
export default async function App() { | ||
const metadata = await generateMetadata(); | ||
const startpageProps = { | ||
locale: "en" // Like Strapi API response | ||
} | ||
return ( | ||
<div> | ||
<Head> | ||
<title>{metadata.title}</title> | ||
<meta name="description" content={metadata.description} /> | ||
</Head> | ||
<Startpage props={startpageProps}></Startpage> | ||
</div> | ||
) | ||
} | ||
|
||
export async function generateMetadata() { | ||
return { | ||
title: "Discover the powerful services of our partners", | ||
description: "Many start-ups and cloud service providers already work together with us an partners, using our technology and infrastructure for their cloud projects. This is a testament to their trust in the Open Telekom Cloud and our great partnership. You can start using these services today to improve your IT systems or your company's communications and benefit from the advantages of the GDPR-compliant European cloud." | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import Overview from '@/components/Overview'; | ||
import Feature from '@/components/Feature'; | ||
import Teaser from '@/components/Teaser'; | ||
import { getAllPartners } from '@/lib/partners'; | ||
import PartnerContactForm from "@/components/PartnerContactForm" | ||
import Quotation from "@/components/Quotation" | ||
import PartnerBreadcrumbs from '@/components/PartnerBreadcrumbs'; | ||
import Head from 'next/head'; | ||
|
||
let cachedPartnersData = null; | ||
|
||
async function getCachedPartnersData() { | ||
// get partner data from API and cache the value for the time creating the partner pages | ||
if (cachedPartnersData === null) { | ||
cachedPartnersData = await getAllPartners(); | ||
} | ||
return cachedPartnersData; | ||
} | ||
|
||
export default async function Page({ params }) { | ||
// function to create partner pages | ||
|
||
const locale = "en" | ||
const linkLocale = "en" | ||
|
||
// const { partner } = params; | ||
const partners = await getCachedPartnersData() | ||
|
||
// From all partners the one with the correct partner data is being collected. | ||
let partnerData = partners.find(element => element.attributes.partner_id === params.partner); | ||
|
||
const metadata = await generateMetadata({params}); | ||
|
||
// Quote | ||
let quote = {} | ||
if (partnerData.attributes.quotes.data) { | ||
// prevent more than one quote | ||
quote = partnerData.attributes.quotes.data[0] | ||
} | ||
|
||
return ( | ||
<div> | ||
<Head> | ||
<title>{metadata.title}</title> | ||
<meta name="description" content={metadata.description} /> | ||
</Head> | ||
<PartnerBreadcrumbs props={partnerData} linkLocale={linkLocale} locale={locale}></PartnerBreadcrumbs> | ||
<Overview props={partnerData} locale={locale}></Overview> | ||
<Teaser props={partnerData} locale={locale}></Teaser> | ||
{partnerData["attributes"]["features"]["data"].map(feature => { | ||
return ( | ||
<Feature key={feature["id"]} props={feature} locale={locale}></Feature> | ||
) | ||
})} | ||
{/* Test if quote is existing */} | ||
{quote && ( | ||
<Quotation props={quote} locale={locale}></Quotation> | ||
)} | ||
<PartnerContactForm locale={locale}></PartnerContactForm> | ||
|
||
</div> | ||
) | ||
} | ||
|
||
export async function generateStaticParams() { | ||
const partners = await getCachedPartnersData() | ||
return partners.map((partner) => ({ | ||
partner: partner.attributes.partner_id | ||
})); | ||
} | ||
|
||
export async function generateMetadata({ params }) { | ||
const partners = await getCachedPartnersData() | ||
let partnerData = partners.find(element => element.attributes.partner_id === params.partner); | ||
return { | ||
title: partnerData.attributes.overview_headline, | ||
description: partnerData.attributes.overview_description | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { redirect } from 'next/navigation' | ||
|
||
export default function Redirect({ }) { | ||
// Click on 'Partner' link in breadcrumbs should redirect to home page | ||
redirect('/en') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,18 @@ | ||
import Index_header from "@/components/Index_Header" | ||
import PartnerListing from "@/components/PartnerListing" | ||
import HeroImage from "@/components/HeroImage" | ||
import PartnerContactForm from "@/components/ContactForm" | ||
import Breadcrumbs from "@/components/Breadcrumbs" | ||
import TwoColumnsWithPicture from "@/components/TwoColumnsWithPicture" | ||
import { getAllPartners, getAllTags, getAllWebAssets } from '@/lib/partners'; | ||
import Head from "next/head" | ||
|
||
|
||
export default async function App() { | ||
// representation of first page | ||
const cachedPartnersData = await getAllPartners(); | ||
const cachedTagsData = await getAllTags(); | ||
const metadata = await generateMetadata(); | ||
const webAssets = await getAllWebAssets(); | ||
|
||
const mainHero = webAssets.find(asset => asset.attributes.name === 'main-hero-image') | ||
const mainHeroHash = mainHero["attributes"]["media"]["data"]["attributes"]["hash"] | ||
const mainHeroExt = mainHero["attributes"]["media"]["data"]["attributes"]["ext"] | ||
|
||
const otcIcon = webAssets.find(asset => asset.attributes.name === 'otc-icon') | ||
const otcIconHash = otcIcon["attributes"]["media"]["data"]["attributes"]["hash"] | ||
const otcIconExt = otcIcon["attributes"]["media"]["data"]["attributes"]["ext"] | ||
|
||
let heroMedia = { | ||
backgroundImageUrl: `/api/${mainHeroHash}${mainHeroExt}`, | ||
iconSrc: `/api/${otcIconHash}${otcIconExt}`, | ||
iconAlt: otcIcon["attributes"]["name"] | ||
} | ||
|
||
const introMedia = webAssets.find(asset => asset.attributes.name === 'circle-partner-tp') | ||
const introMediaHash = introMedia["attributes"]["media"]["data"]["attributes"]["hash"] | ||
const introMediaExt = introMedia["attributes"]["media"]["data"]["attributes"]["ext"] | ||
|
||
let intro = { | ||
image: `${introMediaHash}${introMediaExt}`, | ||
img_height: "517px", | ||
headline: "Discover the powerful services of our partners", | ||
text: ["Many start-ups and cloud service providers already work together with us an partners, using our technology and infrastructure for their cloud projects. This is a testament to their trust in the Open Telekom Cloud and our great partnership.", "You can start using these services today to improve your IT systems or your company's communications and benefit from the advantages of the GDPR-compliant European cloud."] | ||
} | ||
|
||
return ( | ||
<div> | ||
<Head> | ||
<title>{metadata.title}</title> | ||
<meta name="description" content={metadata.description} /> | ||
</Head> | ||
<HeroImage props={heroMedia}></HeroImage> | ||
<Breadcrumbs></Breadcrumbs> | ||
<TwoColumnsWithPicture props={intro}></TwoColumnsWithPicture> | ||
<PartnerListing cachedPartners={cachedPartnersData} cachedTags={cachedTagsData}></PartnerListing> | ||
<PartnerContactForm></PartnerContactForm> | ||
</div> | ||
) | ||
} | ||
|
||
export async function generateMetadata() { | ||
return { | ||
title: "Discover the powerful services of our partners", | ||
description: "Many start-ups and cloud service providers already work together with us an partners, using our technology and infrastructure for their cloud projects. This is a testament to their trust in the Open Telekom Cloud and our great partnership. You can start using these services today to improve your IT systems or your company's communications and benefit from the advantages of the GDPR-compliant European cloud." | ||
}; | ||
} | ||
'use client'; | ||
|
||
import { redirect } from 'next/navigation' | ||
import { useEffect } from 'react'; | ||
|
||
export default function Redirect({ }) { | ||
|
||
// Redirection based on language | ||
useEffect(() => { | ||
const userLanguage = navigator.language; | ||
if (userLanguage.startsWith('de')) { | ||
redirect('/de') | ||
} else { | ||
redirect('/en') | ||
} | ||
}, []) | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.