Files
imen_pishghaman/apps/web/app/composables/useSiteSeo.ts
T

47 lines
1.5 KiB
TypeScript
Raw Normal View History

import { siteConfig } from "#shared/config/site";
/** Used when the API is unreachable (the error page must still render) */
const FALLBACK = {
name: "ایمن پیشگامان",
title: "ایمن پیشگامان | تجهیزات ایمنی و حفاظت فردی صنعتی",
description: "ایمن پیشگامان — تأمین‌کننده تخصصی تجهیزات حفاظت فردی (PPE) و راهکارهای ایمنی صنعتی.",
};
/** Site-wide <head> defaults shared by the app shell and the error page. */
export function useSiteSeo() {
const site = useSiteStore();
const absUrl = useAbsUrl();
const s = site.data?.sections.settings;
const name = s?.name ?? FALLBACK.name;
const title = s?.title ?? FALLBACK.title;
const description = s?.description ?? FALLBACK.description;
const ogImage = s?.ogImage;
useHead({
titleTemplate: (t) => (t ? `${t} | ${name}` : title),
});
useSeoMeta({
description,
themeColor: siteConfig.themeColor,
formatDetection: "telephone=no",
ogType: "website",
ogSiteName: name,
ogLocale: siteConfig.locale,
ogTitle: title,
ogDescription: description,
twitterCard: "summary_large_image",
twitterTitle: title,
twitterDescription: description,
...(ogImage && {
ogImage: absUrl(ogImage.url),
ogImageWidth: ogImage.width ?? undefined,
ogImageHeight: ogImage.height ?? undefined,
ogImageAlt: ogImage.alt,
twitterImage: absUrl(ogImage.url),
twitterImageAlt: ogImage.alt,
}),
});
}