feat: 404 page
This commit is contained in:
@@ -18,11 +18,16 @@ interface Post {
|
||||
content: string;
|
||||
}
|
||||
|
||||
const {data} = await http.get<ApiResponse<Post>>(`post/${slug}`);
|
||||
let data: Post;
|
||||
|
||||
try {
|
||||
const res = await http.get<ApiResponse<Post>>(`post/${slug}`);
|
||||
data = res.data
|
||||
} catch (error) {
|
||||
return Astro.redirect("/404")
|
||||
}
|
||||
const content = await highlightHtmlWithJsdom(data.content)
|
||||
|
||||
data.published_at = formatDatetime(data.published_at, 'YYYY 年 M 月 D 日')
|
||||
const published_at = formatDatetime(data.published_at, 'YYYY 年 M 月 D 日')
|
||||
---
|
||||
|
||||
<Layout title={data.title} description={data.summary}>
|
||||
@@ -43,7 +48,7 @@ data.published_at = formatDatetime(data.published_at, 'YYYY 年 M 月 D 日')
|
||||
<path d="M12 18h.01"/>
|
||||
<path d="M16 18h.01"/>
|
||||
</svg>
|
||||
{data.published_at}
|
||||
{published_at}
|
||||
</div>
|
||||
|
||||
<div class="post markdown-body" set:html={content}></div>
|
||||
|
||||
Reference in New Issue
Block a user