mirror of
https://github.com/Dokploy/website
synced 2025-06-26 18:16:01 +00:00
feat: add error handling and improve blog post page rendering
This commit is contained in:
parent
98ec4ab0c4
commit
3ae8888ef9
@ -80,6 +80,7 @@ export async function generateStaticParams() {
|
||||
}
|
||||
|
||||
export default async function BlogPostPage({ params }: Props) {
|
||||
try {
|
||||
const { locale, slug } = await params;
|
||||
// setRequestLocale(locale);
|
||||
const t = await getTranslations({ locale, namespace: "blog" });
|
||||
@ -105,11 +106,14 @@ export default async function BlogPostPage({ params }: Props) {
|
||||
|
||||
const markdown = turndownService.turndown(post.html);
|
||||
|
||||
const formattedDate = new Date(post.published_at).toLocaleDateString(locale, {
|
||||
const formattedDate = new Date(post.published_at).toLocaleDateString(
|
||||
locale,
|
||||
{
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
const components: Partial<Components> = {
|
||||
h1: H1,
|
||||
@ -343,7 +347,8 @@ export default async function BlogPostPage({ params }: Props) {
|
||||
{relatedPost.title}
|
||||
</h3>
|
||||
<p className="text-sm text-muted-foreground mb-4">
|
||||
{relatedPostDate} • {relatedPost.reading_time} min read
|
||||
{relatedPostDate} • {relatedPost.reading_time} min
|
||||
read
|
||||
</p>
|
||||
<p className="text-muted-foreground line-clamp-2">
|
||||
{relatedPost.excerpt}
|
||||
@ -358,4 +363,8 @@ export default async function BlogPostPage({ params }: Props) {
|
||||
)}
|
||||
</article>
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Error in BlogPostPage:", error);
|
||||
return <div>Error loading blog post</div>;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user