feat(blog): redesign post list cards
This commit is contained in:
@@ -35,6 +35,24 @@ export function formatJalali(iso?: string, withTime: boolean = true): string {
|
||||
}
|
||||
}
|
||||
|
||||
export function formatJalaliDate(iso?: string): string {
|
||||
if (!iso) return '—';
|
||||
try {
|
||||
const date = new Date(iso);
|
||||
const locale = Intl.DateTimeFormat.supportedLocalesOf(['fa-IR-u-ca-persian']).length > 0
|
||||
? 'fa-IR-u-ca-persian'
|
||||
: 'fa-IR';
|
||||
|
||||
return new Intl.DateTimeFormat(locale, {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
}).format(date);
|
||||
} catch {
|
||||
return '—';
|
||||
}
|
||||
}
|
||||
|
||||
const DEFAULT_THUMB = "/placeholder.svg";
|
||||
|
||||
const pickFirstUrl = (...values: Array<string | null | undefined>) =>
|
||||
@@ -66,6 +84,22 @@ export const getEventSeoImageUrl = (event: Types.EventListItemSchema) =>
|
||||
|
||||
export const getThumbUrl = getEventCardImageUrl;
|
||||
|
||||
export const getBlogCardImageUrl = (post: Types.PostListSchema) =>
|
||||
[
|
||||
post.absolute_featured_image_thumbnail_url,
|
||||
post.absolute_featured_image_preview_url,
|
||||
post.absolute_featured_image_url,
|
||||
post.featured_image,
|
||||
].find((value) => Boolean(value));
|
||||
|
||||
export const getBlogHeroImageUrl = (post: Types.PostListSchema) =>
|
||||
[
|
||||
post.absolute_featured_image_preview_url,
|
||||
post.absolute_featured_image_url,
|
||||
post.absolute_featured_image_thumbnail_url,
|
||||
post.featured_image,
|
||||
].find((value) => Boolean(value));
|
||||
|
||||
export const getGalleryImagePreviewUrl = (
|
||||
image:
|
||||
| Types.EventGalleryItem
|
||||
|
||||
Reference in New Issue
Block a user