tags pages added

This commit is contained in:
Al Murad Uzzaman
2024-05-17 18:25:14 +06:00
parent c137b8afcd
commit 5c03211dfe
17 changed files with 229 additions and 144 deletions
+12 -6
View File
@@ -1,16 +1,20 @@
---
import config from "@/config/config.json";
import { slugify } from "@/lib/utils/textConverter";
import type { ContentEntryMap } from "astro:content";
import { getCollection } from "astro:content";
// get taxonomy from frontmatter
export const getTaxonomy = async (collection: any, name: string) => {
// const singlePages = await getSinglePage(collection);
const { default_language } = config.settings;
const actualCollection =
collection !== ("" || undefined) ? collection : default_language;
const singlePages = await getCollection(
collection as keyof ContentEntryMap,
actualCollection as keyof ContentEntryMap,
({ id }: any) => {
return id.startsWith("blog") && !id.endsWith("-index.md");
}
},
);
const taxonomyPages = singlePages.map((page: any) => page.data[name]);
let taxonomies: string[] = [];
@@ -26,12 +30,14 @@ export const getTaxonomy = async (collection: any, name: string) => {
// get all taxonomies from frontmatter
export const getAllTaxonomy = async (collection: any, name: string) => {
// const singlePages = await getSinglePage(collection);
const { default_language } = config.settings;
const actualCollection =
collection !== ("" || undefined) ? collection : default_language;
const singlePages = await getCollection(
collection as keyof ContentEntryMap,
actualCollection as keyof ContentEntryMap,
({ id }: any) => {
return id.startsWith("blog") && !id.endsWith("-index.md");
}
},
);
const taxonomyPages = singlePages.map((page: any) => page.data[name]);
let taxonomies: string[] = [];