import type { Post, PostMetadata } from './posts'; const postMetadataFiles = import.meta.glob('/src/posts/*.svx', { eager: true, import: 'metadata' }); function getSlugFromPath(path: string): string { return path.split('/').pop()?.replace('.svx', '') ?? ''; } export function getPosts(): Post[] { const posts: Post[] = []; for (const path in postMetadataFiles) { const metadata = postMetadataFiles[path]; const slug = getSlugFromPath(path); posts.push({ ...metadata, slug }); } return posts.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()); }