This commit is contained in:
2026-02-05 17:22:56 +07:00
parent a499e06b31
commit 52748cb988
30 changed files with 1080 additions and 508 deletions

View File

@@ -0,0 +1,79 @@
import type { Metadata } from "next";
export function metadataBySlug(result: any): Metadata {
console.log('metadataBySlug: ', result)
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,
description: result.data.excerpt,
openGraph: {
type: 'article',
}
};
default:
return {
title: "Local PC",
openGraph: {
type: 'website',
images: [
'/images/logo.png'
],
}
};
}
}
function stripHtml(html: string) {
return html.replace(/<[^>]*>/g, '');
}