2024-02-20 11:47:52 +01:00
|
|
|
import { PageProps } from '$fresh/server.ts'
|
2024-07-01 13:11:20 +02:00
|
|
|
import { Markdown } from ':components/Markdown.tsx'
|
2024-07-11 11:29:53 +02:00
|
|
|
import { MemberCard } from ':components/MemberCard.tsx'
|
|
|
|
import { db } from ':src/db/mod.ts'
|
|
|
|
import { fetchCarnet, userToMemberCardProps } from ':src/members/mod.ts'
|
2024-02-20 11:47:52 +01:00
|
|
|
|
2024-07-11 11:29:53 +02:00
|
|
|
export default async function Member(_: Request, { params, url }: PageProps) {
|
|
|
|
const uuid = params.id as ReturnType<Crypto['randomUUID']>
|
2024-07-16 15:29:30 +02:00
|
|
|
const user = await db.resource.user.get({ uuid }).catch(() => undefined)
|
2024-02-20 11:47:52 +01:00
|
|
|
|
2024-07-11 11:29:53 +02:00
|
|
|
if (!user) {
|
2024-07-03 11:52:36 +02:00
|
|
|
return <h3>Membre inconnu, peut être serez vous le prochain</h3>
|
2024-02-20 11:47:52 +01:00
|
|
|
}
|
|
|
|
|
2024-07-11 11:29:53 +02:00
|
|
|
const memberCardProps = await userToMemberCardProps(user)
|
|
|
|
const carnet = await fetchCarnet(user.login)
|
2024-02-20 11:47:52 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
display: 'grid',
|
|
|
|
gridTemplateColumns: 'auto 1fr',
|
|
|
|
gap: 'var(--_gap)',
|
|
|
|
justifyContent: 'center',
|
|
|
|
}}
|
|
|
|
>
|
2024-02-20 11:56:15 +01:00
|
|
|
<style>{'.markdown-body { max-width: 80dvw; }'}</style>
|
2024-02-20 11:47:52 +01:00
|
|
|
<div>
|
2024-07-11 11:29:53 +02:00
|
|
|
{MemberCard(memberCardProps)}
|
2024-02-20 11:56:15 +01:00
|
|
|
<br />
|
2024-02-20 11:47:52 +01:00
|
|
|
<a
|
2024-07-11 11:29:53 +02:00
|
|
|
href={`https://${
|
|
|
|
user.login.replace('.', '-')
|
|
|
|
}.portfolio.${url.hostname}`}
|
2024-02-20 11:47:52 +01:00
|
|
|
class='cta'
|
|
|
|
target='_blank'
|
|
|
|
>
|
|
|
|
Portfolio
|
|
|
|
</a>
|
|
|
|
</div>
|
2024-07-11 11:29:53 +02:00
|
|
|
<Markdown
|
|
|
|
options={{
|
|
|
|
baseUrl:
|
|
|
|
`https://git.cohabit.fr/${user.login}/.carnet/raw/branch/main/index.md`,
|
|
|
|
allowMath: true,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{carnet}
|
|
|
|
</Markdown>
|
2024-02-20 11:47:52 +01:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|