Ghost

phantomknight287/Portfolio

public
Fork0
CodeIssues0Pull requests0
3branches
Portfolioapp[locale](root)writings[slug]page.tsx
translated :D39da910a year ago64 lines · 2.1 KB
1import {
2 allEnglishWritings,
3 allGermanWritings,
4} from "@/.content-collections/generated";
5import { Metadata }
6import { notFound }
7import { MDXContent }
8import defaultComponents from "fumadocs-ui/mdx
9import { Pre, CodeBlock
10
11export async function generateStaticParams
12 return [...allEnglishWritings
13 slug: writing._meta
14 locale: writing.locale
15 }));
16}
17export async function generateMetadata
18 params: Promise
19}): Promise<Metadata
20 const params =
21 const post =
22 (post) =>
23 );
24 if (!post)
25 return {
26 title: post.title
27 description: post.summary
28 openGraph: {
29 title: post.title
30 description: post.summary
31 },
32 };
33}
34
35export default async function
36 params: Promise
37}) {
38 const params =
39 const post =
40 (post) =>
41 );
42 if (!post)
43 return (
44 <article className="min-h-screen container items-center justify-center flex-col
45 <div className="flex flex-col max-w-[600px] mx-auto p-0
46 <div className="container prose prose-invert prose-lg my-5
47 <h1 className="text-xl font-bold
48 <p className="text-base text-gray-400 mb-10
49 <MDXContent
50 code={post.mdx
51 components={{
52 ...defaultComponents,
53 pre: ({ ref
54 <CodeBlock {...props
55 <Pre>{props.
56 </CodeBlock>
57 ),
58 }}
59 />
60 </div>
61 </div>
62 </article>
63 );
64}
from
"
next
"
;
from
"
next/navigation
"
;
from
"
@content-collections/mdx/react
"
;
"
;
}
from
"
fumadocs-ui/components/codeblock
"
;
()
{
,
...
allGermanWritings
]
.
map
(
(
writing
)
=>
(
{
.
path
,
,
(
props
:
{
<
{
slug
:
string
;
locale
:
string
}
>
;
>
{
await
props
.
params
;
[
...
allEnglishWritings
,
...
allGermanWritings
]
.
find
(
post
.
_meta
.
path
===
params
.
slug
&&
post
.
locale
===
params
.
locale
return
{}
;
,
,
,
,
Page
(
props
:
{
<
{
slug
:
string
;
locale
:
string
}
>
;
await
props
.
params
;
[
...
allEnglishWritings
,
...
allGermanWritings
]
.
find
(
post
.
_meta
.
path
===
params
.
slug
&&
post
.
locale
===
params
.
locale
return
notFound
()
;
"
>
"
>
"
>
"
>
{
post
.
title
}
</
h1
>
"
>
{
post
.
summary
}
</
p
>
}
:
_ref
,
...
props
}
)
=>
(
}
keepBackground
className
=
"
font-mono
"
>
children
}
</
Pre
>