Initial ASPHP website
This commit is contained in:
+56
@@ -0,0 +1,56 @@
|
||||
export const SITE_ORIGIN = "https://www.asphp.ir";
|
||||
export const SITE_NAME = "آریا شبکه پیشرو";
|
||||
export const DEFAULT_DESCRIPTION =
|
||||
"خرید سرور HP، رم سرور، هارد سرور، CPU و تجهیزات شبکه از آریا شبکه پیشرو همراه با مشاوره تخصصی، تضمین کیفیت و خدمات پس از فروش.";
|
||||
|
||||
export function pageMetadata({ title, description = DEFAULT_DESCRIPTION, path = "/", image }) {
|
||||
const canonical = absoluteUrl(path);
|
||||
const metaTitle = title.includes(SITE_NAME) ? title : `${title} | ${SITE_NAME}`;
|
||||
|
||||
return {
|
||||
title: metaTitle,
|
||||
description,
|
||||
alternates: {
|
||||
canonical
|
||||
},
|
||||
openGraph: {
|
||||
title: metaTitle,
|
||||
description,
|
||||
url: canonical,
|
||||
siteName: SITE_NAME,
|
||||
locale: "fa_IR",
|
||||
type: "website",
|
||||
...(image ? { images: [{ url: absoluteUrl(image), alt: title }] } : {})
|
||||
},
|
||||
twitter: {
|
||||
card: image ? "summary_large_image" : "summary",
|
||||
title: metaTitle,
|
||||
description,
|
||||
...(image ? { images: [absoluteUrl(image)] } : {})
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function productCanonicalPath(item) {
|
||||
const id = item.productId || item.id;
|
||||
return `/products/${encodeURIComponent(id)}/${slugifyFa(item.title)}`;
|
||||
}
|
||||
|
||||
export function blogCanonicalPath(blog) {
|
||||
return `/blog/${encodeURIComponent(blog.id)}/${slugifyFa(blog.title)}`;
|
||||
}
|
||||
|
||||
export function absoluteUrl(path = "/") {
|
||||
if (/^https?:\/\//.test(path)) return path;
|
||||
return `${SITE_ORIGIN}${path.startsWith("/") ? path : `/${path}`}`;
|
||||
}
|
||||
|
||||
export function slugifyFa(value = "") {
|
||||
return String(value)
|
||||
.trim()
|
||||
.normalize("NFKC")
|
||||
.replace(/[^\p{L}\p{N}\s-]+/gu, "")
|
||||
.replace(/\s+/g, "-")
|
||||
.replace(/-+/g, "-")
|
||||
.replace(/^-|-$/g, "");
|
||||
}
|
||||
Reference in New Issue
Block a user