import { define } from '../../utils.ts'
import { BlogPost } from ':components/BlogBlocks.tsx'
import { fetchNews } from ':src/blog/mod.ts'

export default define.page(async ({ params }) => {
	try {
		const article = await fetchNews('cohabit', params.name)
		return BlogPost(article)
	} catch {
		return (
			<>
				<h3>Une erreur est survenue</h3>
				<p>{`Impossible de récupérer l'article "${params.name}"`}.</p>
			</>
		)
	}
})
