2026-02-05 17:22:56 +07:00
|
|
|
import type { Metadata } from "next";
|
|
|
|
|
|
|
|
|
|
export function metadataBySlug(result: any): Metadata {
|
2026-02-07 11:50:23 +07:00
|
|
|
|
2026-02-05 17:22:56 +07:00
|
|
|
switch (result.type) {
|
|
|
|
|
case "product_category":
|
|
|
|
|
return {
|
|
|
|
|
title: result.data.title,
|
|
|
|
|
description: stripHtml(result.data.summary),
|
|
|
|
|
openGraph: {
|
|
|
|
|
type: 'website',
|
|
|
|
|
images: [
|
|
|
|
|
result.data.big_image
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
case "product_detail":
|
|
|
|
|
return {
|
|
|
|
|
title: result.data.productName,
|
|
|
|
|
description: stripHtml(result.data.productSummary),
|
|
|
|
|
openGraph: {
|
|
|
|
|
type: 'website',
|
|
|
|
|
images: [
|
|
|
|
|
result.data.productImage.large.replace('/250_', '/')
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
case "article_home":
|
|
|
|
|
return {
|
|
|
|
|
title: "Tin tức",
|
|
|
|
|
description: "Tin tức mới nhất",
|
|
|
|
|
openGraph: {
|
|
|
|
|
type: 'article',
|
|
|
|
|
images: [
|
|
|
|
|
result.data.productImage.large.replace('/250_', '/')
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
case "article_category":
|
|
|
|
|
return {
|
|
|
|
|
title: result.data.title,
|
|
|
|
|
description: stripHtml(result.data.summary),
|
|
|
|
|
openGraph: {
|
|
|
|
|
type: 'article',
|
|
|
|
|
images: [
|
|
|
|
|
result.data.thumbnail
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
case "article_detail":
|
|
|
|
|
return {
|
|
|
|
|
title: result.data.title,
|
2026-02-10 17:11:24 +07:00
|
|
|
description: result.data.meta_description,
|
|
|
|
|
openGraph: {
|
|
|
|
|
type: 'article',
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
case "job_detail":
|
|
|
|
|
return {
|
|
|
|
|
title: result.data.title,
|
|
|
|
|
description: result.data.meta_description,
|
2026-02-05 17:22:56 +07:00
|
|
|
openGraph: {
|
|
|
|
|
type: 'article',
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
default:
|
2026-02-10 17:11:24 +07:00
|
|
|
|
2026-02-05 17:22:56 +07:00
|
|
|
return {
|
2026-02-10 17:11:24 +07:00
|
|
|
title: result.meta_title || "Local PC",
|
|
|
|
|
description: result.data.meta_description || "",
|
2026-02-05 17:22:56 +07:00
|
|
|
openGraph: {
|
|
|
|
|
type: 'website',
|
|
|
|
|
images: [
|
|
|
|
|
'/images/logo.png'
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function stripHtml(html: string) {
|
|
|
|
|
return html.replace(/<[^>]*>/g, '');
|
|
|
|
|
}
|