mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-17 21:53:32 +09:00
update banner-img
This commit is contained in:
@@ -2,7 +2,7 @@ import { formatInTimeZone } from "date-fns-tz";
|
||||
|
||||
const dateFormat = (
|
||||
date: Date | string,
|
||||
format: string = "dd MMM, yyyy"
|
||||
format: string = "dd MMM, yyyy",
|
||||
): string => {
|
||||
return formatInTimeZone(date, "America/New_York", format);
|
||||
};
|
||||
|
||||
@@ -15,12 +15,12 @@ const similerItems = (currentItem: any, allItems: any, slug: string) => {
|
||||
|
||||
// filter by categories
|
||||
const filterByCategories = allItems.filter((item: any) =>
|
||||
categories.find((category) => item.data.categories.includes(category))
|
||||
categories.find((category) => item.data.categories.includes(category)),
|
||||
);
|
||||
|
||||
// filter by tags
|
||||
const filterByTags = allItems.filter((item: any) =>
|
||||
tags.find((tag) => item.data.tags.includes(tag))
|
||||
tags.find((tag) => item.data.tags.includes(tag)),
|
||||
);
|
||||
|
||||
// merged after filter
|
||||
|
||||
@@ -3,7 +3,7 @@ export const sortByDate = (array: any[]) => {
|
||||
const sortedArray = array.sort(
|
||||
(a: any, b: any) =>
|
||||
new Date(b.data.date && b.data.date).valueOf() -
|
||||
new Date(a.data.date && a.data.date).valueOf()
|
||||
new Date(a.data.date && a.data.date).valueOf(),
|
||||
);
|
||||
return sortedArray;
|
||||
};
|
||||
@@ -11,14 +11,14 @@ export const sortByDate = (array: any[]) => {
|
||||
// sort product by weight
|
||||
export const sortByWeight = (array: any[]) => {
|
||||
const withWeight = array.filter(
|
||||
(item: { data: { weight: any } }) => item.data.weight
|
||||
(item: { data: { weight: any } }) => item.data.weight,
|
||||
);
|
||||
const withoutWeight = array.filter(
|
||||
(item: { data: { weight: any } }) => !item.data.weight
|
||||
(item: { data: { weight: any } }) => !item.data.weight,
|
||||
);
|
||||
const sortedWeightedArray = withWeight.sort(
|
||||
(a: { data: { weight: number } }, b: { data: { weight: number } }) =>
|
||||
a.data.weight - b.data.weight
|
||||
a.data.weight - b.data.weight,
|
||||
);
|
||||
const sortedArray = [...new Set([...sortedWeightedArray, ...withoutWeight])];
|
||||
return sortedArray;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { slugify } from "@/lib/utils/textConverter";
|
||||
|
||||
const taxonomyFilter = (posts: any[], name: string, key: string) =>
|
||||
posts.filter((post) =>
|
||||
post.data[name].map((name: string) => slugify(name)).includes(key)
|
||||
post.data[name].map((name: string) => slugify(name)).includes(key),
|
||||
);
|
||||
|
||||
export default taxonomyFilter;
|
||||
|
||||
Reference in New Issue
Block a user