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:
@@ -80,6 +80,7 @@ export async function generateStaticParams() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function BlogPostPage({ params }: Props) {
|
export default async function BlogPostPage({ params }: Props) {
|
||||||
|
try {
|
||||||
const { locale, slug } = await params;
|
const { locale, slug } = await params;
|
||||||
// setRequestLocale(locale);
|
// setRequestLocale(locale);
|
||||||
const t = await getTranslations({ locale, namespace: "blog" });
|
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 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",
|
year: "numeric",
|
||||||
month: "long",
|
month: "long",
|
||||||
day: "numeric",
|
day: "numeric",
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const components: Partial<Components> = {
|
const components: Partial<Components> = {
|
||||||
h1: H1,
|
h1: H1,
|
||||||
@@ -343,7 +347,8 @@ export default async function BlogPostPage({ params }: Props) {
|
|||||||
{relatedPost.title}
|
{relatedPost.title}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-sm text-muted-foreground mb-4">
|
<p className="text-sm text-muted-foreground mb-4">
|
||||||
{relatedPostDate} • {relatedPost.reading_time} min read
|
{relatedPostDate} • {relatedPost.reading_time} min
|
||||||
|
read
|
||||||
</p>
|
</p>
|
||||||
<p className="text-muted-foreground line-clamp-2">
|
<p className="text-muted-foreground line-clamp-2">
|
||||||
{relatedPost.excerpt}
|
{relatedPost.excerpt}
|
||||||
@@ -358,4 +363,8 @@ export default async function BlogPostPage({ params }: Props) {
|
|||||||
)}
|
)}
|
||||||
</article>
|
</article>
|
||||||
);
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in BlogPostPage:", error);
|
||||||
|
return <div>Error loading blog post</div>;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user