Ghost

phantomknight287/Portfolio

public
Fork0
CodeIssues0Pull requests0
3branches
Portfolioapp[locale](root)writings[slug]page.tsx
add experience section and git blog3dd1b56a month ago66 lines · 2.2 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
10import dayjs from "dayjs
11
12export async function generateStaticParams
13 return [...allEnglishWritings
14 slug: writing._meta
15 locale: writing.locale
16 }));
17}
18export async function generateMetadata
19 params: Promise
20}): Promise<Metadata
21 const params =
22 const post =
23 (post) =>
24 );
25 if (!post)
26 return {
27 title: post.title
28 description: post.summary
29 openGraph: {
30 title: post.title
31 description: post.summary
32 },
33 };
34}
35
36export default async function
37 params: Promise
38}) {
39 const params =
40 const post =
41 (post) =>
42 );
43 if (!post)
44 return (
45 <article className="min-h-screen container items-center justify-center flex-col
46 <div className="flex flex-col max-w-[600px] mx-auto p-0
47 <div className="container !mx-0 prose prose-invert prose-lg my-5
48 <h1 className="text-xl font-bold mb-1
49 <p className="text-sm text-gray-500 m-0
50 <p className="text-base text-gray-400 mb-10
51 <MDXContent
52 code={post.mdx
53 components={{
54 ...defaultComponents,
55 pre: ({ ref
56 <CodeBlock {...props
57 <Pre>{props.
58 </CodeBlock>
59 ),
60 }}
61 />
62 </div>
63 </div>
64 </article>
65 );
66}
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
>
"
>
{
dayjs
(
post
.
date
)
.
format
(
"
DD/MM/YYYY
"
)
}
</
p
>
"
>
{
post
.
summary
}
</
p
>
}
:
_ref
,
...
props
}
)
=>
(
}
keepBackground
className
=
"
font-mono
"
>
children
}
</
Pre
>