blog doesn't have to have any posts

This commit is contained in:
2024-05-03 22:54:28 +02:00
parent 4405754d1d
commit cf783b3dd0
+6 -1
View File
@@ -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 },