mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-16 13:13:26 +09:00
config ln array changed
This commit is contained in:
+12
-22
@@ -1,19 +1,4 @@
|
||||
---
|
||||
// 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;
|
||||
// };
|
||||
|
||||
import {
|
||||
getCollection,
|
||||
type CollectionEntry,
|
||||
@@ -31,15 +16,17 @@ export const getSinglePage = async <C extends CollectionKey>(
|
||||
const langCollection: keyof ContentEntryMap = lang as keyof ContentEntryMap;
|
||||
|
||||
// Explicitly define the type of pages to CollectionEntry<C>[]
|
||||
const pages: CollectionEntry<C>[] = await getCollection(langCollection || defaultLang, ({ id }) => {
|
||||
return id.startsWith(collectionName) && !id.endsWith("-index.md");
|
||||
}) as CollectionEntry<C>[];
|
||||
const pages: CollectionEntry<C>[] = (await getCollection(
|
||||
langCollection || defaultLang,
|
||||
({ id }: any) => {
|
||||
return id.startsWith(collectionName) && !id.endsWith("-index.md");
|
||||
}
|
||||
)) as CollectionEntry<C>[];
|
||||
|
||||
const removeDrafts = pages.filter((data) => !data.data.draft);
|
||||
return removeDrafts;
|
||||
};
|
||||
|
||||
|
||||
export const getListPage = async <C extends CollectionKey>(
|
||||
collectionName: C,
|
||||
lang: keyof ContentEntryMap
|
||||
@@ -47,9 +34,12 @@ export const getListPage = async <C extends CollectionKey>(
|
||||
const { defaultLang } = config.language;
|
||||
const langCollection: keyof ContentEntryMap = lang as keyof ContentEntryMap;
|
||||
// Fetch the collection based on the language
|
||||
const pages: CollectionEntry<C>[] = await getCollection(langCollection || defaultLang, ({ id }) => {
|
||||
return id.startsWith(collectionName);
|
||||
}) as CollectionEntry<C>[];
|
||||
const pages: CollectionEntry<C>[] = (await getCollection(
|
||||
langCollection || defaultLang,
|
||||
({ id }: any) => {
|
||||
return id.startsWith(collectionName);
|
||||
}
|
||||
)) as CollectionEntry<C>[];
|
||||
|
||||
return pages;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user