Skip empty slug blog pages
This commit is contained in:
@@ -4,10 +4,12 @@ import { getBlogPostBySlug, getBlogPosts } from '../../utils/directus';
|
|||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const posts = await getBlogPosts();
|
const posts = await getBlogPosts();
|
||||||
return posts.map((post) => ({
|
return posts
|
||||||
params: { slug: Array.isArray(post.slug) ? post.slug[0] : post.slug },
|
.filter((post) => typeof post.slug === 'string' && post.slug.trim() !== '')
|
||||||
props: { post },
|
.map((post) => ({
|
||||||
}));
|
params: { slug: post.slug },
|
||||||
|
props: { post },
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
const { post } = Astro.props;
|
const { post } = Astro.props;
|
||||||
|
Reference in New Issue
Block a user