-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b1cf0f
commit 4656dd7
Showing
57 changed files
with
4,919 additions
and
2,934 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
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 was deleted.
Oops, something went wrong.
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,71 @@ | ||
import { draftMode } from 'next/headers'; | ||
import { notFound } from 'next/navigation'; | ||
|
||
import { ArticleContent, ArticleHero, ArticleTileGrid } from '@src/components/features/article'; | ||
import { Container } from '@src/components/shared/container'; | ||
import initTranslations from '@src/i18n'; | ||
import { client, previewClient } from '@src/lib/client'; | ||
|
||
export async function generateStaticParams({ | ||
params: { locale }, | ||
}: { | ||
params: { locale: string }; | ||
}): Promise<BlogPageProps['params'][]> { | ||
const gqlClient = client; | ||
const { pageBlogPostCollection } = await gqlClient.pageBlogPostCollection({ locale, limit: 100 }); | ||
|
||
if (!pageBlogPostCollection?.items) { | ||
throw new Error('No blog posts found'); | ||
} | ||
|
||
return pageBlogPostCollection.items | ||
.filter((blogPost): blogPost is NonNullable<typeof blogPost> => Boolean(blogPost?.slug)) | ||
.map(blogPost => { | ||
return { | ||
locale, | ||
slug: blogPost.slug!, | ||
}; | ||
}); | ||
} | ||
|
||
interface BlogPageProps { | ||
params: { | ||
locale: string; | ||
slug: string; | ||
}; | ||
} | ||
|
||
export default async function Page({ params: { locale, slug } }: BlogPageProps) { | ||
const { isEnabled: preview } = draftMode(); | ||
const gqlClient = preview ? previewClient : client; | ||
const { t } = await initTranslations({ locale }); | ||
const { pageBlogPostCollection } = await gqlClient.pageBlogPost({ locale, slug, preview }); | ||
const { pageLandingCollection } = await gqlClient.pageLanding({ locale, preview }); | ||
const landingPage = pageLandingCollection?.items[0]; | ||
const blogPost = pageBlogPostCollection?.items[0]; | ||
const relatedPosts = blogPost?.relatedBlogPostsCollection?.items; | ||
const isFeatured = Boolean( | ||
blogPost?.slug && landingPage?.featuredBlogPost?.slug === blogPost.slug, | ||
); | ||
|
||
if (!blogPost) { | ||
notFound(); | ||
} | ||
|
||
return ( | ||
<> | ||
<Container> | ||
<ArticleHero article={blogPost} isFeatured={isFeatured} isReversedLayout={true} /> | ||
</Container> | ||
<Container className="mt-8 max-w-4xl"> | ||
<ArticleContent article={blogPost} /> | ||
</Container> | ||
{relatedPosts && ( | ||
<Container className="mt-8 max-w-5xl"> | ||
<h2 className="mb-4 md:mb-6">{t('article.relatedArticles')}</h2> | ||
<ArticleTileGrid className="md:grid-cols-2" articles={relatedPosts} /> | ||
</Container> | ||
)} | ||
</> | ||
); | ||
} |
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,70 @@ | ||
import { dir } from 'i18next'; | ||
import type { Metadata, Viewport } from 'next'; | ||
import { Urbanist } from 'next/font/google'; | ||
import { draftMode } from 'next/headers'; | ||
|
||
import { ContentfulPreviewProvider } from '@src/components/features/contentful'; | ||
import TranslationsProvider from '@src/components/shared/i18n/TranslationProvider'; | ||
import { Footer } from '@src/components/templates/footer'; | ||
import { Header } from '@src/components/templates/header'; | ||
import initTranslations from '@src/i18n'; | ||
import { locales } from '@src/i18n/config'; | ||
|
||
export async function generateMetadata() { | ||
const metatadata: Metadata = { | ||
metadataBase: new URL(process.env.NEXT_PUBLIC_BASE_URL!), | ||
other: { | ||
'msapplication-TileColor': '#ffffff', | ||
'msapplication-config': '/favicons/browserconfig.xml', | ||
}, | ||
} as Metadata; | ||
|
||
return metatadata; | ||
} | ||
|
||
export const viewport: Viewport = { | ||
themeColor: '#ffffff', | ||
}; | ||
|
||
export async function generateStaticParams(): Promise<LayoutProps['params'][]> { | ||
return locales.map(locale => ({ locale })); | ||
} | ||
|
||
const urbanist = Urbanist({ subsets: ['latin'], variable: '--font-urbanist' }); | ||
|
||
interface LayoutProps { | ||
children: React.ReactNode; | ||
params: { locale: string }; | ||
} | ||
|
||
export default async function PageLayout({ children, params }: LayoutProps) { | ||
const { isEnabled: preview } = draftMode(); | ||
const { locale } = params; | ||
const { resources } = await initTranslations({ locale }); | ||
|
||
return ( | ||
<html lang={locale} dir={dir(locale)}> | ||
<head> | ||
<link rel="mask-icon" href="/favicons/safari-pinned-tab.svg" color="#5bbad5" /> | ||
</head> | ||
|
||
<body> | ||
<TranslationsProvider locale={locale} resources={resources}> | ||
<ContentfulPreviewProvider | ||
locale={locale} | ||
enableInspectorMode={preview} | ||
enableLiveUpdates={preview} | ||
targetOrigin={'https://app.contentful.com'} | ||
> | ||
<main className={`${urbanist.variable} font-sans`}> | ||
<Header /> | ||
{children} | ||
<Footer /> | ||
</main> | ||
<div id="portal" className={`${urbanist.variable} font-sans`} /> | ||
</ContentfulPreviewProvider> | ||
</TranslationsProvider> | ||
</body> | ||
</html> | ||
); | ||
} |
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,20 @@ | ||
import Link from 'next/link'; | ||
|
||
import { Container } from '@src/components/shared/container'; | ||
import initTranslations from '@src/i18n'; | ||
import { defaultLocale } from '@src/i18n/config'; | ||
|
||
export default async function NotFound() { | ||
const { t } = await initTranslations({ locale: defaultLocale }); | ||
|
||
return ( | ||
<Container> | ||
<h1 className="h2">{t('notFound.title')}</h1> | ||
<p className="mt-4"> | ||
{t('notFound.description')} | ||
|
||
<Link className="text-blue500" href="/" /> | ||
</p> | ||
</Container> | ||
); | ||
} |
Oops, something went wrong.