From cf783b3dd0c3950de502aff018a778f62dfe3333 Mon Sep 17 00:00:00 2001 From: YouHaveTrouble Date: Fri, 3 May 2024 22:54:28 +0200 Subject: [PATCH] blog doesn't have to have any posts --- src/pages/blog/[slug].astro | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/blog/[slug].astro b/src/pages/blog/[slug].astro index 1496c4e..db264b0 100644 --- a/src/pages/blog/[slug].astro +++ b/src/pages/blog/[slug].astro @@ -4,7 +4,12 @@ import Bio from '../../components/Bio.astro'; import getPostData from '../../utils/getPostData'; export async function getStaticPaths() { - const posts = await Astro.glob('../../data/blog-posts/*.md'); + let posts = []; + try { + posts = await Astro.glob('../../data/blog-posts/*.md'); + } catch (error) { + console.error("No blog posts found"); + } return posts.map(p => ({ params: { slug: p.file.split('/').pop().split('.').shift() }, props: { post: p },