mirror of
https://github.com/kremalicious/blog.git
synced 2024-06-28 16:48:00 +02:00
13 lines
379 B
TypeScript
13 lines
379 B
TypeScript
import { type CollectionEntry } from 'astro:content'
|
|
import { getAllPosts } from './index'
|
|
import { slugifyAll } from '../slugify'
|
|
|
|
export async function getPostsByTag(
|
|
tag: string
|
|
): Promise<CollectionEntry<'articles' | 'links' | 'photos'>[]> {
|
|
const allPosts = await getAllPosts()
|
|
return allPosts.filter((post) =>
|
|
slugifyAll(post.data.tags || []).includes(tag)
|
|
)
|
|
}
|