changed the content folder structure && fixed breadcrumps

This commit is contained in:
Al Murad Uzzaman
2024-05-23 15:39:53 +06:00
parent 521fd4804d
commit d5e012e6f8
54 changed files with 295 additions and 60 deletions
+66 -2
View File
@@ -9,7 +9,7 @@ import {
import config from "@/config/config.json";
import languages from "@/config/language.json";
export const getSinglePage = async <C extends CollectionKey>(
export const getSP = async <C extends CollectionKey>(
collectionName: C,
lang: keyof ContentEntryMap | undefined
): Promise<CollectionEntry<C>[]> => {
@@ -40,7 +40,7 @@ export const getSinglePage = async <C extends CollectionKey>(
return removeDrafts;
};
export const getListPage = async <C extends CollectionKey>(
export const getLP = async <C extends CollectionKey>(
collectionName: C,
lang: keyof ContentEntryMap | undefined
): Promise<CollectionEntry<C>[]> => {
@@ -67,4 +67,68 @@ export const getListPage = async <C extends CollectionKey>(
return pages;
};
export const getSinglePage = async <C extends CollectionKey>(
collectionName: C,
lang: keyof ContentEntryMap | undefined,
subCollectionName?: string
): Promise<CollectionEntry<C>[]> => {
const { default_language } = config.settings;
const selectedLanguageCode = lang || default_language;
const language = languages.find(
(l: any) => l.languageCode === selectedLanguageCode
);
if (!language) {
throw new Error("Language not found");
}
const { contentDir } = language;
const path = subCollectionName
? `${contentDir}/${subCollectionName}`
: contentDir;
const pages: CollectionEntry<C>[] = (await getCollection(
collectionName as any,
({ id }: any) => {
return id.startsWith(path) && !id.endsWith("-index.md");
}
)) as CollectionEntry<C>[];
// @ts-ignore
const removeDrafts = pages.filter((data) => !data.data.draft);
return removeDrafts;
};
export const getListPage = async <C extends CollectionKey>(
collectionName: C,
lang: keyof ContentEntryMap | undefined
): Promise<CollectionEntry<C>[]> => {
const { default_language } = config.settings;
const selectedLanguageCode = lang || default_language;
const language = languages.find(
(l: any) => l.languageCode == selectedLanguageCode
);
if (!language) {
throw new Error("Language not found");
}
const { contentDir } = language;
const pages: CollectionEntry<C>[] = (await getCollection(
collectionName as any,
({ id }: any) => {
return id.startsWith(contentDir);
}
)) as CollectionEntry<C>[];
return pages;
};
---
+8 -8
View File
@@ -16,7 +16,7 @@ export const getTaxonomy = async (collection: string, name: string) => {
actualCollection = language.contentDir;
} else {
const defaultLanguageMatch = languages.find(
(l) => l.languageCode === default_language,
(l) => l.languageCode === default_language
);
if (defaultLanguageMatch) {
actualCollection = defaultLanguageMatch.contentDir;
@@ -24,10 +24,10 @@ export const getTaxonomy = async (collection: string, name: string) => {
}
const singlePages = await getCollection(
actualCollection as keyof ContentEntryMap,
"blog" as keyof ContentEntryMap,
({ id }: any) => {
return id.startsWith("blog") && !id.endsWith("-index.md");
},
return id.startsWith(actualCollection) && !id.endsWith("-index.md");
}
);
const taxonomyPages = singlePages.map((page: any) => page.data[name]);
let taxonomies: string[] = [];
@@ -52,7 +52,7 @@ export const getAllTaxonomy = async (collection: string, name: string) => {
actualCollection = language.contentDir;
} else {
const defaultLanguageMatch = languages.find(
(l) => l.languageCode === default_language,
(l) => l.languageCode === default_language
);
if (defaultLanguageMatch) {
actualCollection = defaultLanguageMatch.contentDir;
@@ -60,10 +60,10 @@ export const getAllTaxonomy = async (collection: string, name: string) => {
}
const singlePages = await getCollection(
actualCollection as keyof ContentEntryMap,
"blog" as keyof ContentEntryMap,
({ id }: any) => {
return id.startsWith("blog") && !id.endsWith("-index.md");
},
return id.startsWith(actualCollection) && !id.endsWith("-index.md");
}
);
const taxonomyPages = singlePages.map((page: any) => page.data[name]);
let taxonomies: string[] = [];