---
import { type CollectionEntry, getCollection } from 'astro:content';
import BlogList from '../../../layouts/BlogList.astro';

export async function getStaticPaths() {
	const posts = await getCollection('blog');

  const tags = posts.flatMap(p => p.data.tags);

	return tags.map((tag) => ({
		params: { tag: tag },
    props: { tag: tag },
	}));
}
type Props = { tag: string }

const tag = Astro.props.tag;
---

<BlogList selectedTag={tag} />
