website/routes/membres/[id]/index.tsx

55 lines
1.2 KiB
TypeScript
Raw Normal View History

import { PageProps } from '$fresh/server.ts'
import { Markdown } from '../../../components/Markdown.tsx'
import { MemberCard, memberMock } from '../../../components/MemberCard.tsx'
const db = [
'julien.oculi',
]
async function getCarnet(user: string): Promise<string> {
try {
const response = await fetch(
`https://git.cohabit.fr/${user}/.carnet/raw/branch/main/index.md`,
)
return response.text()
} catch (error) {
return 'Carnet introuvable\n```js\nString(error)\n```'
}
}
export default async function Member(_: Request, { params }: PageProps) {
const id = Number(params.id)
const Member = memberMock.at(id)
if (!Member) {
return <h3>Membre inconnu, peut être serai vous le prochain</h3>
}
const carnet = await getCarnet(db.at(id)!)
return (
<div
style={{
display: 'grid',
gridTemplateColumns: 'auto 1fr',
gap: 'var(--_gap)',
justifyContent: 'center',
}}
>
<style>{'.markdown-body { max-width: 80dvw; }'}</style>
<div>
{MemberCard(Member)}
<br />
<a
href={`/membres/${id}/portfolio/index.html`}
class='cta'
target='_blank'
>
Portfolio
</a>
</div>
<Markdown>{carnet}</Markdown>
</div>
)
}