+
+
500: Something went wrong
+
+ 服务器爆炸了!如果你能联系到博主的话提醒他一声吧!
+
+
+
+ ←
+ Go to home page
+
+
+
diff --git a/src/pages/blog/[...id].astro b/src/pages/blog/[...id].astro
index 449117c..1b14375 100644
--- a/src/pages/blog/[...id].astro
+++ b/src/pages/blog/[...id].astro
@@ -42,41 +42,55 @@ export async function getStaticPaths() {
const currentPostId = Astro.params.id
let Content: any = null
-let headings
-let remoteContent = null
+let headings: any[] = []
+let remoteContent: any = null
+let post: any = null
+let authors: any[] = []
+let isCurrentSubpost = false
+let navigation: any = null
+let parentPost: any = null
+let hasChildPosts = false
+let subpostCount = 0
+let tocSections: TOCSection[] = []
+let heroImage: any = null
+try {
+ const remote = await fetchRemotePostContent(currentPostId)
+ if (!remote) {
+ // return Astro.response(null, {status: 404})
+ return Astro.rewrite('/404')
+ }
-const remote = await fetchRemotePostContent(currentPostId)
-if(!remote) {
- // return Astro.response(null, {status: 404})
- return Astro.rewrite("/404")
+ remoteContent = renderRemoteBlockMap(remote.blockMap, remote.rootId)
+ headings = remoteContent?.headings ?? []
+ post = remote.post
+ authors = await parseAuthors(post?.authors ?? [])
+
+ isCurrentSubpost = isSubpost(currentPostId)
+ navigation = await getAdjacentPosts(currentPostId)
+ parentPost = isCurrentSubpost ? await getParentPost(currentPostId) : null
+
+ hasChildPosts = await hasSubposts(currentPostId)
+ subpostCount = !isCurrentSubpost
+ ? await getSubpostCount(currentPostId)
+ : 0
+
+ tocSections = remoteContent
+ ? remoteContent.headings.length > 0
+ ? [
+ {
+ type: 'parent',
+ title: 'Overview',
+ headings: remoteContent.headings,
+ },
+ ]
+ : []
+ : await getTOCSections(currentPostId)
+ heroImage = post?.data?.banner
+} catch (error) {
+ console.error('blog page render failed:', error)
+ return Astro.rewrite('/500')
}
-remoteContent = remote ? renderRemoteBlockMap(remote.blockMap, remote.post.id) : null
-headings = remoteContent?.headings ?? []
-const post = remote?.post
-const authors = await parseAuthors(post?.authors ?? [])
-
-const isCurrentSubpost = isSubpost(currentPostId)
-const navigation = await getAdjacentPosts(currentPostId)
-const parentPost = isCurrentSubpost ? await getParentPost(currentPostId) : null
-
-const hasChildPosts = await hasSubposts(currentPostId)
-const subpostCount = !isCurrentSubpost
- ? await getSubpostCount(currentPostId)
- : 0
-
-const tocSections: TOCSection[] = remoteContent
- ? remoteContent.headings.length > 0
- ? [
- {
- type: 'parent',
- title: 'Overview',
- headings: remoteContent.headings,
- },
- ]
- : []
- : await getTOCSections(currentPostId)
-const heroImage = post?.data?.banner
export const prerender = false;
---
diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro
index 80a4950..d6577cf 100644
--- a/src/pages/blog/index.astro
+++ b/src/pages/blog/index.astro
@@ -35,7 +35,6 @@ const page = await fetch(`https://notion-api.nvme0n1p.dev/v2/posts/?page=${nowPa
lastPage: totalPages,
};
});
-console.log(page);
// fetch page
if(page.lastPage < page.currentPage) {
console.log("redirect to 404")