11import { CopyButton } from "@/components/ui/copy-button" ;
22import { getPost , getPosts } from "@/lib/ghost" ;
33import type { Metadata , ResolvingMetadata } from "next" ;
4- import { getTranslations } from "next-intl/server" ;
4+ import { getTranslations , setRequestLocale } from "next-intl/server" ;
55import Image from "next/image" ;
66import Link from "next/link" ;
77import { notFound } from "next/navigation" ;
@@ -27,7 +27,8 @@ export async function generateMetadata(
2727 { params } : Props ,
2828 parent : ResolvingMetadata ,
2929) : Promise < Metadata > {
30- const post = await getPost ( params . slug ) ;
30+ const { locale, slug } = await params ;
31+ const post = await getPost ( slug ) ;
3132
3233 if ( ! post ) {
3334 return {
@@ -36,10 +37,10 @@ export async function generateMetadata(
3637 }
3738
3839 const ogUrl = new URL (
39- `/${ params . locale } /api/og` ,
40+ `/${ locale } /api/og` ,
4041 process . env . NEXT_PUBLIC_APP_URL || "http://localhost:3000" ,
4142 ) ;
42- ogUrl . searchParams . set ( "slug" , params . slug ) ;
43+ ogUrl . searchParams . set ( "slug" , slug ) ;
4344
4445 return {
4546 title : post . title ,
@@ -69,10 +70,14 @@ export async function generateMetadata(
6970
7071export async function generateStaticParams ( ) {
7172 const posts = await getPosts ( ) ;
73+ const locales = [ "en" , "fr" , "zh-Hans" ] ;
7274
73- return posts . map ( ( post ) => ( {
74- slug : post . slug ,
75- } ) ) ;
75+ return posts . flatMap ( ( post ) =>
76+ locales . map ( ( locale ) => ( {
77+ locale,
78+ slug : post . slug ,
79+ } ) ) ,
80+ ) ;
7681}
7782
7883interface CodeProps
@@ -126,13 +131,14 @@ async function CodeBlock(props: LanguageProps) {
126131 < CopyButton text = { format } />
127132 < div
128133 dangerouslySetInnerHTML = { { __html : out } }
129- className = "text-sm p-4 rounded-lg bg-[#18191F]"
134+ className = "text-sm p-4 rounded-lg bg-[#18191F] overflow-auto "
130135 />
131136 </ div >
132137 ) ;
133138}
134139export default async function BlogPostPage ( { params } : Props ) {
135- const { locale, slug } = params ;
140+ const { locale, slug } = await params ;
141+ // setRequestLocale(locale);
136142 const t = await getTranslations ( { locale, namespace : "blog" } ) ;
137143 const post = await getPost ( slug ) ;
138144 const allPosts = await getPosts ( ) ;
@@ -164,7 +170,10 @@ export default async function BlogPostPage({ params }: Props) {
164170
165171 const components : Partial < Components > = {
166172 h1 : ( { node, ...props } ) => (
167- < h1 className = "text-3xl text-primary font-bold mt-8 mb-4" { ...props } />
173+ < h1
174+ className = "text-xl md:text-2xl xl:text-3xl text-primary font-bold mt-8 mb-4"
175+ { ...props }
176+ />
168177 ) ,
169178 h2 : ( { node, ...props } ) => (
170179 < h2 className = "text-2xl text-primary/90 font-bold mt-6 mb-3" { ...props } />
@@ -230,7 +239,7 @@ export default async function BlogPostPage({ params }: Props) {
230239 < ZoomableImage
231240 src = { src || "" }
232241 alt = { alt || "" }
233- className = "object-cover max-w-lg mx-auto rounded-lg border border-border"
242+ className = "object-cover max-w-lg mx-auto rounded-lg border max-lg:w-64 border-border overflow-hidden "
234243 />
235244 ) ,
236245 code : ( { inline, className, children, ...props } : CodeProps ) => {
@@ -245,7 +254,7 @@ export default async function BlogPostPage({ params }: Props) {
245254 } ;
246255
247256 return (
248- < article className = "container mx-auto px-4 py -12 max-w-5xl" >
257+ < article className = "container mx-auto px-4 pb -12 max-w-5xl" >
249258 < Link
250259 href = "/blog"
251260 className = "inline-flex items-center mb-8 text-primary hover:text-primary/80 transition-colors"
@@ -267,7 +276,9 @@ export default async function BlogPostPage({ params }: Props) {
267276
268277 < div className = " rounded-lg p-8 shadow-lg border border-border" >
269278 < header className = "mb-8" >
270- < h1 className = "text-4xl font-bold mb-4" > { post . title } </ h1 >
279+ < h1 className = "text-2xl md:text-3xl xl:text-4xl font-bold mb-4" >
280+ { post . title }
281+ </ h1 >
271282 < div className = "flex items-center mb-6" >
272283 { post . primary_author ?. profile_image && (
273284 < div className = "relative h-12 w-12 rounded-full overflow-hidden mr-4" >
0 commit comments