Ghost

phantomknight287/Portfolio

public
Fork0
CodeIssues0Pull requests0
3branches
Portfolioapp[locale](projects)projects[name]page.tsx
fix project URLsd7d305ea year ago123 lines · 3.8 KB
1import ImageWithLoader from "@/components/loadingimage";
2import BackButton from "@/components/shared/back
3import { Projects }
4import { cn }
5import { upperFirst }
6import { Metadata }
7import { getTranslations }
8import { FiExternalLink, FiGithub
9
10export async function generateStaticParams
11 const localeOptions =
12 return localeOptions.flatMap
13 Projects.map((p
14 name: encodeURIComponent(p
15 locale,
16 }))
17 );
18}
19interface Props {
20 params: Promise
21 name: string
22 }>;
23}
24
25export async function generateMetadata
26 const params =
27 const project =
28 (p) =>
29 )!;
30 const translation =
31 return {
32 title: project.name
33 description: translation(`${
34 openGraph: {
35 type: "website",
36 title: project.name
37 description: translation(`${
38 images: [
39 {
40 url: project.image
41 width: project.image
42 height: project.image
43 alt: project.image
44 },
45 ],
46 },
47 twitter: {
48 card: "summary_large_image",
49 site: "@gurpalsingh287",
50 },
51 };
52}
53
54async function ProjectPage(
55 const params =
56 const project =
57 (p) =>
58 )!;
59 const translation =
60 return (
61 <div className="min-h-screen p-5 container items-center justify-center flex-col lg:max-w-xl overflow-hidden
62 <BackButton />
63
64 <ImageWithLoader
65 className={cn(
66 "mx-auto rounded-md mt-5 object-cover h-[unset]",
67 project.image.width
68 )}
69 src={project.image
70 alt={project.image
71 loading="eager"
72 width={project.image
73 height={project.image
74 />
75
76 {project.image.source
77 <p className="text-center text-gray-400
78 Source: {project.image.source
79 </p>
80 ) : null}
81 <div className="flex flex-row items-center my-5
82 <h1 className="text-2xl font-bold text-left
83 <div className="flex flex-row items-center flex-nowrap ml-auto gap-2
84 {Object.keys(project
85 <a
86 href={project.urls
87 target="_blank"
88 rel="noreferrer"
89 key={key}
90 className="flex flex-row items-center justify-start gap-2.5
91 text-white transition duration-300 ease-in-out
92 bg-neutral-700 hover:bg-neutral-900 rounded-md px-3 py-2.5"
93 >
94 {key === "githubUrl
95 <FiGithub className="
96 ) : (
97 <FiExternalLink className="
98 )}
99 </a>
100 ))}
101 </div>
102 </div>
103
104 <div className="flex flex-col items-start justify-start gap-2.5
105 <p className="text-lg text-left text-gray-300
106 {translation(`${project
107 </p>
108 <div className="flex flex-row flex-wrap items-center justify-start gap-2.5
109 {project.tags?.map
110 <span
111 key={tag}
112 className=" text-sm bg-neutral-200 text-black font-medium rounded-xl px-2 py-1"
113 >
114 {upperFirst(tag)}
115 </span>
116 ))}
117 </div>
118 </div>
119 </div>
120 );
121}
122
123export default ProjectPage;
"
;
from
"
@/constants
"
;
from
"
@/lib/utils
"
;
from
"
@/utils/uppercase
"
;
from
"
next
"
;
from
"
next-intl/server
"
;
}
from
"
react-icons/fi
"
;
()
{
[
"
de
"
,
"
en
"
]
;
(
(
locale
)
=>
)
=>
(
{
.
slug
)
,
<
{
;
(
props
:
Props
)
:
Promise
<
Metadata
>
{
await
props
.
params
;
Projects
.
find
(
encodeURIComponent
(
p
.
slug
)
===
encodeURIComponent
(
params
.
name
)
await
getTranslations
(
"
Projects
"
)
;
,
project
.
slug
}
.description
`
)
,
,
project
.
slug
}
.description
`
)
,
?.
url
,
?.
width
,
?.
height
,
?.
alt
,
props
:
Props
)
{
await
props
.
params
;
Projects
.
find
(
encodeURIComponent
(
p
.
slug
)
===
encodeURIComponent
(
params
.
name
)
await
getTranslations
(
"
Projects
"
)
;
"
>
>
100
?
"
w-full
"
:
"
w-1/2
"
.
url
}
.
alt
}
.
width
}
.
height
}
?
(
"
>
}
"
>
"
>
{
project
.
name
}
</
h1
>
"
>
.
urls
)
.
map
(
(
key
:
keyof
typeof
project
.
urls
)
=>
(
[
key
]
}
"
?
(
text-white text-xl
"
/>
text-white text-xl
"
/>
"
>
"
>
.
slug
}
.description
`
)
}
"
>
(
(
tag
)
=>
(