updated to astro v3.6

This commit is contained in:
somrat sorkar
2023-12-03 15:28:12 +06:00
parent 34e3ac525f
commit afb57b5825
22 changed files with 151 additions and 121 deletions
-10
View File
@@ -1,10 +0,0 @@
---
import { getCollection } from "astro:content";
export const getSinglePage = async (collection: any) => {
const allPage = await getCollection(collection);
const removeIndex = allPage.filter((data: any) => data.id.match(/^(?!-)/));
const removeDrafts = removeIndex.filter((data: any) => !data.data.draft);
return removeDrafts;
};
---
+11 -2
View File
@@ -1,8 +1,16 @@
---
import { getSinglePage } from "./contentParser.astro";
import { getCollection } from "astro:content";
import { slugify } from "./utils/textConverter";
// get all taxonomies from frontmatter
// get all pages from collection
export const getSinglePage = async (collection: any) => {
const allPage = await getCollection(collection);
const removeIndex = allPage.filter((data: any) => data.id.match(/^(?!-)/));
const removeDrafts = removeIndex.filter((data: any) => !data.data.draft);
return removeDrafts;
};
// get taxonomy from frontmatter
export const getTaxonomy = async (collection: string, name: string) => {
const singlePages = await getSinglePage(collection);
const taxonomyPages = singlePages.map((page: any) => page.data[name]);
@@ -17,6 +25,7 @@ export const getTaxonomy = async (collection: string, name: string) => {
return taxonomy;
};
// get all taxonomies from frontmatter
export const getAllTaxonomy = async (collection: string, name: string) => {
const singlePages = await getSinglePage(collection);
const taxonomyPages = singlePages.map((page: any) => page.data[name]);
+6 -4
View File
@@ -1,5 +1,5 @@
// similer products
const similerItems = (currentItem: any, allItems: any, slug: string) => {
// similar products
const similarItems = (currentItem: any, allItems: any[]) => {
let categories: string[] = [];
let tags: string[] = [];
@@ -27,9 +27,11 @@ const similerItems = (currentItem: any, allItems: any, slug: string) => {
const mergedItems = [...new Set([...filterByCategories, ...filterByTags])];
// filter by slug
const filterBySlug = mergedItems.filter((product) => product.slug !== slug);
const filterBySlug = mergedItems.filter(
(product) => product.slug !== currentItem.slug,
);
return filterBySlug;
};
export default similerItems;
export default similarItems;