forked from UKSOURCE/hailearning.edu.vn
Merge pull request 'fix: update blog post URL handling to use API base URL instead of site URL' (#22) from fea/thanh-02022026-news into main
Reviewed-on: UKSOURCE/hailearning.edu.vn#22
This commit is contained in:
@@ -12,12 +12,9 @@ export default function NewsDetailsContent({ post }: NewsDetailsContentProps) {
|
|||||||
// Lấy comments từ post (đã được bao gồm trong API response)
|
// Lấy comments từ post (đã được bao gồm trong API response)
|
||||||
const postComments = post.comments || [];
|
const postComments = post.comments || [];
|
||||||
|
|
||||||
// Lấy base URL cho EditorJS images
|
// Lấy base URL cho EditorJS images và URL tuyệt đối của bài viết
|
||||||
const baseUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001";
|
const baseUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001";
|
||||||
|
const postUrl = `${baseUrl}/blog/${post.slug}`;
|
||||||
// URL tuyệt đối của bài viết để share lên mạng xã hội
|
|
||||||
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || "http://localhost:3000";
|
|
||||||
const postUrl = `${siteUrl}/blog/${post.slug}`;
|
|
||||||
const encodedPostUrl = encodeURIComponent(postUrl);
|
const encodedPostUrl = encodeURIComponent(postUrl);
|
||||||
const encodedTitle = encodeURIComponent(post.title);
|
const encodedTitle = encodeURIComponent(post.title);
|
||||||
|
|
||||||
|
|||||||
@@ -48,11 +48,11 @@ export async function generateMetadata({
|
|||||||
const blogResponse = await fetchBlogDetail(slug);
|
const blogResponse = await fetchBlogDetail(slug);
|
||||||
const post = blogResponse.data;
|
const post = blogResponse.data;
|
||||||
|
|
||||||
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || "http://localhost:3000";
|
const apiUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001";
|
||||||
const url = `${siteUrl}/blog/${post.slug}`;
|
const url = `${apiUrl}/blog/${post.slug}`;
|
||||||
const imageUrl = post.featuredImage
|
const imageUrl = post.featuredImage
|
||||||
? getCmsImageUrl(post.featuredImage)
|
? getCmsImageUrl(post.featuredImage)
|
||||||
: `${siteUrl}/assets/img/inner-page/news-details/details-1.jpg`;
|
: `${apiUrl}/assets/img/inner-page/news-details/details-1.jpg`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: post.title,
|
title: post.title,
|
||||||
|
|||||||
Reference in New Issue
Block a user