added contentParser with type support

This commit is contained in:
somrat sorkar
2023-12-09 11:14:43 +06:00
parent afb57b5825
commit 4c3b181a46
13 changed files with 74 additions and 86 deletions
+16
View File
@@ -0,0 +1,16 @@
---
import {
getCollection,
type CollectionEntry,
type CollectionKey,
} from "astro:content";
export const getSinglePage = async <C extends CollectionKey>(
collectionName: C,
): Promise<CollectionEntry<C>[]> => {
const allPages = await getCollection(collectionName);
const removeIndex = allPages.filter((data) => data.id.match(/^(?!-)/));
const removeDrafts = removeIndex.filter((data) => !data.data.draft);
return removeDrafts;
};
---