mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-13 11:46:17 +09:00
34 lines
1.1 KiB
Plaintext
34 lines
1.1 KiB
Plaintext
---
|
|
import { getSinglePage } from "@/lib/contentParser.astro";
|
|
import { slugify } from "@/lib/utils/textConverter";
|
|
|
|
// get taxonomy from frontmatter
|
|
export const getTaxonomy = async (collection: any, name: string) => {
|
|
const singlePages = await getSinglePage(collection);
|
|
const taxonomyPages = singlePages.map((page: any) => page.data[name]);
|
|
let taxonomies: string[] = [];
|
|
for (let i = 0; i < taxonomyPages.length; i++) {
|
|
const categoryArray = taxonomyPages[i];
|
|
for (let j = 0; j < categoryArray.length; j++) {
|
|
taxonomies.push(slugify(categoryArray[j]));
|
|
}
|
|
}
|
|
const taxonomy = [...new Set(taxonomies)];
|
|
return taxonomy;
|
|
};
|
|
|
|
// get all taxonomies from frontmatter
|
|
export const getAllTaxonomy = async (collection: any, name: string) => {
|
|
const singlePages = await getSinglePage(collection);
|
|
const taxonomyPages = singlePages.map((page: any) => page.data[name]);
|
|
let taxonomies: string[] = [];
|
|
for (let i = 0; i < taxonomyPages.length; i++) {
|
|
const categoryArray = taxonomyPages[i];
|
|
for (let j = 0; j < categoryArray.length; j++) {
|
|
taxonomies.push(slugify(categoryArray[j]));
|
|
}
|
|
}
|
|
return taxonomies;
|
|
};
|
|
---
|