mirror of
https://github.com/10h30/astroplate.git
synced 2026-06-05 15:08:00 +09:00
33 lines
1.1 KiB
Plaintext
33 lines
1.1 KiB
Plaintext
---
|
|
import { getSinglePage } from "./contentParser.astro";
|
|
import { slugify } from "./utils/textConverter";
|
|
|
|
// get all taxonomies from frontmatter
|
|
export const getTaxonomy = async (collection: string, name: string) => {
|
|
const singlePages = await getSinglePage(collection);
|
|
const taxonomyPages = singlePages.map((page) => page.data[name]);
|
|
let taxonomies = [];
|
|
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;
|
|
};
|
|
|
|
export const getAllTaxonomy = async (collection: string, name: string) => {
|
|
const singlePages = await getSinglePage(collection);
|
|
const taxonomyPages = singlePages.map((page) => page.data[name]);
|
|
let taxonomies = [];
|
|
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;
|
|
};
|
|
---
|