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
ed0c2c5b
Commit
ed0c2c5b
authored
Aug 28, 2026
by
Văn Hoàng
Browse files
Options
Browse Files
Download
Plain Diff
[tag]0.1-vcci
parents
c6e718f7
800bd21c
Pipeline
#52917
passed with stages
in 2 minutes and 44 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
4 deletions
+100
-4
page.tsx
src/app/(main)/[...slug]/page.tsx
+7
-4
route.tsx
src/app/api/og-post/route.tsx
+93
-0
No files found.
src/app/(main)/[...slug]/page.tsx
View file @
ed0c2c5b
...
...
@@ -3,7 +3,6 @@ import links from "@links/index";
import
{
fetchDynamicPostById
,
fetchDynamicPostByExternalLink
,
getDynamicPostSeoImage
,
getDynamicPostExcerpt
,
stripHtml
,
}
from
"./templates/data"
;
...
...
@@ -46,7 +45,6 @@ export async function generateMetadata({
stripHtml(post.summary) ||
getDynamicPostExcerpt(post).slice(0, 160) ||
"Tin tức từ VCCI HCM";
const imageUrl = getDynamicPostSeoImage(post);
const articleUrl = `
$
{
links
.
siteURL
.
replace
(
/
\/
+$/
,
""
)}
$
{
path
}
$
{
postId
||
categoryIdParam
?
`?
${
new
URLSearchParams
({
...
...
@@ -56,6 +54,11 @@ 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 {
title,
description,
...
...
@@ -67,7 +70,7 @@ export async function generateMetadata({
siteName: "VCCI HCM",
images: [
{
url:
i
mageUrl,
url:
ogI
mageUrl,
width: 1200,
height: 630,
alt: title,
...
...
@@ -80,7 +83,7 @@ export async function generateMetadata({
card: "summary_large_image",
title,
description,
images: [
i
mageUrl],
images: [
ogI
mageUrl],
},
};
}
...
...
src/app/api/og-post/route.tsx
0 → 100644
View file @
ed0c2c5b
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