50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import type { PublicPage } from "@montech/shared";
|
|||
|
|
|
||
|
|
export interface BlogPostSummary {
|
||
|
|
id: string;
|
||
|
|
slug: string;
|
||
|
|
title: string;
|
||
|
|
excerpt: string;
|
||
|
|
coverUrl: string | null;
|
||
|
|
publishedAt: string | null;
|
||
|
|
updatedAt?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface BlogPost extends BlogPostSummary {
|
||
|
|
content: string;
|
||
|
|
seoTitle: string | null;
|
||
|
|
seoDesc: string | null;
|
||
|
|
ogImage: string | null;
|
||
|
|
canonical: string | null;
|
||
|
|
createdAt?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface GalleryItem {
|
||
|
|
id: string;
|
||
|
|
title: string;
|
||
|
|
imageUrl: string;
|
||
|
|
category: string | null;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function usePageMeta(key: string) {
|
||
|
|
return useAsyncData(`page-${key}`, () => apiFetch<PublicPage>(`/api/public/pages/${key}`).catch(() => null));
|
||
|
|
}
|
||
|
|
|
||
|
|
export function formatFaDate(value?: string | null) {
|
||
|
|
return value ? new Date(value).toLocaleDateString("fa-IR", { year: "numeric", month: "long", day: "numeric" }) : "";
|
||
|
|
}
|
||
|
|
|
||
|
|
export function useBreadcrumbJsonLd(items: Array<{ name: string; path: string }>) {
|
||
|
|
const siteUrl = useRuntimeConfig().public.siteUrl.replace(/\/$/, "");
|
||
|
|
useJsonLd({
|
||
|
|
"@context": "https://schema.org",
|
||
|
|
"@type": "BreadcrumbList",
|
||
|
|
itemListElement: items.map((item, i) => ({
|
||
|
|
"@type": "ListItem",
|
||
|
|
position: i + 1,
|
||
|
|
name: item.name,
|
||
|
|
item: `${siteUrl}${item.path}`,
|
||
|
|
})),
|
||
|
|
});
|
||
|
|
}
|