Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VCCI-News
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Văn Hoàng
VCCI-News
Commits
132042dd
Commit
132042dd
authored
Aug 28, 2026
by
Văn Hoàng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "feat: tao dynamic OG image 1200x630 bang next/og - auto fit anh bai viet + title overlay"
This reverts commit
4b8920f5
.
parent
800bd21c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
100 deletions
+4
-100
page.tsx
src/app/(main)/[...slug]/page.tsx
+4
-7
route.tsx
src/app/api/og-post/route.tsx
+0
-93
No files found.
src/app/(main)/[...slug]/page.tsx
View file @
132042dd
...
@@ -3,6 +3,7 @@ import links from "@links/index";
...
@@ -3,6 +3,7 @@ import links from "@links/index";
import
{
import
{
fetchDynamicPostById
,
fetchDynamicPostById
,
fetchDynamicPostByExternalLink
,
fetchDynamicPostByExternalLink
,
getDynamicPostSeoImage
,
getDynamicPostExcerpt
,
getDynamicPostExcerpt
,
stripHtml
,
stripHtml
,
}
from
"./templates/data"
;
}
from
"./templates/data"
;
...
@@ -45,6 +46,7 @@ export async function generateMetadata({
...
@@ -45,6 +46,7 @@ export async function generateMetadata({
stripHtml(post.summary) ||
stripHtml(post.summary) ||
getDynamicPostExcerpt(post).slice(0, 160) ||
getDynamicPostExcerpt(post).slice(0, 160) ||
"Tin tức từ VCCI HCM";
"Tin tức từ VCCI HCM";
const imageUrl = getDynamicPostSeoImage(post);
const articleUrl = `
$
{
links
.
siteURL
.
replace
(
/
\/
+$/
,
""
)}
$
{
path
}
$
{
const articleUrl = `
$
{
links
.
siteURL
.
replace
(
/
\/
+$/
,
""
)}
$
{
path
}
$
{
postId
||
categoryIdParam
postId
||
categoryIdParam
?
`?
${
new
URLSearchParams
({
?
`?
${
new
URLSearchParams
({
...
@@ -54,11 +56,6 @@ export async function generateMetadata({
...
@@ -54,11 +56,6 @@ export async function generateMetadata({
:
""
:
""
}
`;
}
`;
const ogImageParams = new URLSearchParams();
if (postId) ogImageParams.set("id", postId);
if (!postId && slug?.length) ogImageParams.set("slug", slug.join("/"));
const ogImageUrl = `
/
api
/
og
-
post
?
$
{
ogImageParams
.
toString
()}
`;
return {
return {
title,
title,
description,
description,
...
@@ -70,7 +67,7 @@ export async function generateMetadata({
...
@@ -70,7 +67,7 @@ export async function generateMetadata({
siteName: "VCCI HCM",
siteName: "VCCI HCM",
images: [
images: [
{
{
url:
ogI
mageUrl,
url:
i
mageUrl,
width: 1200,
width: 1200,
height: 630,
height: 630,
alt: title,
alt: title,
...
@@ -83,7 +80,7 @@ export async function generateMetadata({
...
@@ -83,7 +80,7 @@ export async function generateMetadata({
card: "summary_large_image",
card: "summary_large_image",
title,
title,
description,
description,
images: [
ogI
mageUrl],
images: [
i
mageUrl],
},
},
};
};
}
}
...
...
src/app/api/og-post/route.tsx
deleted
100644 → 0
View file @
800bd21c
import
{
ImageResponse
}
from
"next/og"
;
import
{
fetchDynamicPostById
,
fetchDynamicPostByExternalLink
,
getDynamicPostSeoImage
,
getDynamicPostExcerpt
,
stripHtml
,
}
from
"@/app/(main)/[...slug]/templates/data"
;
export
const
runtime
=
"nodejs"
;
export
const
revalidate
=
3600
;
export
async
function
GET
(
request
:
Request
)
{
try
{
const
{
searchParams
}
=
new
URL
(
request
.
url
);
const
id
=
searchParams
.
get
(
"id"
)
??
""
;
const
slug
=
searchParams
.
get
(
"slug"
)
??
""
;
let
post
=
null
;
try
{
post
=
id
?
await
fetchDynamicPostById
(
id
)
:
slug
?
await
fetchDynamicPostByExternalLink
(
`/
${
slug
}
`
)
:
null
;
}
catch
{
post
=
null
;
}
const
title
=
post
?.
title
??
"VCCI HCM"
;
const
description
=
stripHtml
(
post
?.
summary
)
||
(
post
?
getDynamicPostExcerpt
(
post
).
slice
(
0
,
120
)
:
""
);
const
imageUrl
=
post
?
getDynamicPostSeoImage
(
post
)
:
""
;
const
hasImage
=
imageUrl
&&
imageUrl
!==
"/thumbnail.png"
;
return
new
ImageResponse
(
(
<
div
style=
{
{
display
:
"flex"
,
flexDirection
:
"column"
,
width
:
1200
,
height
:
630
,
backgroundColor
:
"#0a4d8c"
,
position
:
"relative"
,
fontFamily
:
"sans-serif"
,
}
}
>
{
hasImage
&&
(
<
img
src=
{
imageUrl
}
style=
{
{
position
:
"absolute"
,
top
:
0
,
left
:
0
,
width
:
1200
,
height
:
630
,
objectFit
:
"cover"
,
}
}
/>
)
}
</
div
>
),
{
width
:
1200
,
height
:
630
,
},
);
}
catch
{
return
new
ImageResponse
(
(
<
div
style=
{
{
display
:
"flex"
,
alignItems
:
"center"
,
justifyContent
:
"center"
,
width
:
1200
,
height
:
630
,
backgroundColor
:
"#0a4d8c"
,
color
:
"#ffffff"
,
fontSize
:
48
,
fontWeight
:
700
,
fontFamily
:
"sans-serif"
,
}
}
>
VCCI-HCM
</
div
>
),
{
width
:
1200
,
height
:
630
},
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment