mirror of
https://github.com/theoludwig/theoludwig.git
synced 2025-05-29 22:37:44 +02:00
feat: init Curriculum Vitae
This commit is contained in:
64
apps/website/app/[locale]/(main)/blog/[slug]/page.tsx
Normal file
64
apps/website/app/[locale]/(main)/blog/[slug]/page.tsx
Normal file
@ -0,0 +1,64 @@
|
||||
import type { Metadata } from "next"
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
import { getBlogPostBySlug, getBlogPosts } from "@repo/blog"
|
||||
import { BlogPostUI } from "@repo/blog/BlogPostUI"
|
||||
import type { Locale } from "@repo/i18n/config"
|
||||
import { unstable_setRequestLocale } from "next-intl/server"
|
||||
|
||||
interface BlogPostPageProps {
|
||||
params: {
|
||||
slug: string
|
||||
locale: Locale
|
||||
}
|
||||
}
|
||||
|
||||
export const generateMetadata = async (
|
||||
props: BlogPostPageProps,
|
||||
): Promise<Metadata> => {
|
||||
const blogPost = await getBlogPostBySlug(props.params.slug)
|
||||
if (blogPost == null) {
|
||||
return notFound()
|
||||
}
|
||||
const title = `${blogPost.frontmatter.title} | Théo LUDWIG`
|
||||
const description = blogPost.frontmatter.description
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
openGraph: {
|
||||
title,
|
||||
description,
|
||||
},
|
||||
twitter: {
|
||||
title,
|
||||
description,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export const generateStaticParams = async (): Promise<
|
||||
Array<{ slug: string }>
|
||||
> => {
|
||||
const posts = await getBlogPosts()
|
||||
return posts.map((post) => {
|
||||
return {
|
||||
slug: post.slug,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const BlogPostPage: React.FC<BlogPostPageProps> = async (props) => {
|
||||
const { params } = props
|
||||
|
||||
// Enable static rendering
|
||||
unstable_setRequestLocale(params.locale)
|
||||
|
||||
const blogPost = await getBlogPostBySlug(params.slug)
|
||||
if (blogPost == null) {
|
||||
return notFound()
|
||||
}
|
||||
|
||||
return <BlogPostUI blogPost={blogPost} />
|
||||
}
|
||||
|
||||
export default BlogPostPage
|
55
apps/website/app/[locale]/(main)/blog/page.tsx
Normal file
55
apps/website/app/[locale]/(main)/blog/page.tsx
Normal file
@ -0,0 +1,55 @@
|
||||
import { getBlogPosts } from "@repo/blog"
|
||||
import { BlogPosts } from "@repo/blog/BlogPosts"
|
||||
import { LOCALE_DEFAULT, type LocaleProps } from "@repo/i18n/config"
|
||||
import { MainLayout } from "@repo/ui/Layout/MainLayout"
|
||||
import {
|
||||
Section,
|
||||
SectionDescription,
|
||||
SectionTitle,
|
||||
} from "@repo/ui/Layout/Section"
|
||||
import type { Metadata } from "next"
|
||||
import { unstable_setRequestLocale } from "next-intl/server"
|
||||
|
||||
const title = "Blog | Théo LUDWIG"
|
||||
const description =
|
||||
"The latest news about my journey of learning computer science."
|
||||
|
||||
export const generateMetadata = async (): Promise<Metadata> => {
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
openGraph: {
|
||||
title,
|
||||
description,
|
||||
locale: LOCALE_DEFAULT,
|
||||
},
|
||||
twitter: {
|
||||
title,
|
||||
description,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
interface BlogPageProps extends LocaleProps {}
|
||||
|
||||
const BlogPage: React.FC<BlogPageProps> = async (props) => {
|
||||
const { params } = props
|
||||
|
||||
// Enable static rendering
|
||||
unstable_setRequestLocale(params.locale)
|
||||
|
||||
const posts = await getBlogPosts()
|
||||
|
||||
return (
|
||||
<MainLayout>
|
||||
<Section verticalSpacing horizontalSpacing>
|
||||
<SectionTitle>Blog</SectionTitle>
|
||||
<SectionDescription>{description}</SectionDescription>
|
||||
|
||||
<BlogPosts posts={posts} />
|
||||
</Section>
|
||||
</MainLayout>
|
||||
)
|
||||
}
|
||||
|
||||
export default BlogPage
|
Reference in New Issue
Block a user