mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-19 06:33:33 +09:00
updated to astro v3.6
This commit is contained in:
@@ -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;
|
||||
};
|
||||
---
|
||||
@@ -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]);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user