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
6a37537a
Commit
6a37537a
authored
May 25, 2026
by
Lê Bảo Hồng Đức
☄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
0c9063d2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
16 deletions
+46
-16
ArticlePage.tsx
src/app/(main)/[...slug]/templates/ArticlePage.tsx
+4
-10
data.ts
src/app/(main)/[...slug]/templates/data.ts
+40
-0
page.tsx
src/app/(main)/search/page.tsx
+2
-6
No files found.
src/app/(main)/[...slug]/templates/ArticlePage.tsx
View file @
6a37537a
...
...
@@ -16,8 +16,8 @@ import {
buildVisibleNewsFilters
,
fetchDynamicPostList
,
findDisplayCategoryForPost
,
getDynamicPostExcerpt
,
resolveDynamicPostImage
,
stripHtml
,
}
from
"./data"
;
import
type
{
DynamicCategoryRouteItem
}
from
"./types"
;
...
...
@@ -128,13 +128,7 @@ export default function ArticlePage({ category, allCategories }: ArticlePageProp
<
div
className=
"space-y-9"
>
{
paginatedPosts
.
length
?
(
paginatedPosts
.
map
((
item
,
index
)
=>
{
const
fallbackDescription
=
item
.
content_structure
?.
post_content
?.
map
((
section
)
=>
section
.
content
)
.
join
(
" "
);
const
description
=
stripHtml
(
item
.
summary
)
||
stripHtml
(
item
.
content
)
||
stripHtml
(
fallbackDescription
);
const
description
=
getDynamicPostExcerpt
(
item
);
const
primaryCategory
=
findDisplayCategoryForPost
(
item
,
category
,
...
...
@@ -152,7 +146,7 @@ export default function ArticlePage({ category, allCategories }: ArticlePageProp
>
<
Link
href=
{
buildDynamicPostHref
(
item
.
external_link
,
item
.
id
,
category
.
id
)
}
className=
"group grid gap-5 sm:grid-cols-[250px_minmax(0,1fr)]"
className=
"group grid
items-center
gap-5 sm:grid-cols-[250px_minmax(0,1fr)]"
>
<
div
className=
"relative overflow-hidden rounded-md bg-[#edf1f5] aspect-[25/15] sm:aspect-[5/3]"
>
<
ImageNext
...
...
@@ -164,7 +158,7 @@ export default function ArticlePage({ category, allCategories }: ArticlePageProp
/>
</
div
>
<
div
className=
"min-w-0
pt-1
"
>
<
div
className=
"min-w-0"
>
<
div
className=
"flex flex-wrap items-center gap-3 text-xs"
>
<
span
className=
{
`rounded-full px-2.5 py-1 font-semibold ${getTagClassName(tagIndex)}`
}
...
...
src/app/(main)/[...slug]/templates/data.ts
View file @
6a37537a
...
...
@@ -483,13 +483,53 @@ export function resolveDynamicPostImage(thumbnail?: DynamicPostThumbnail) {
export
function
stripHtml
(
value
?:
string
|
null
)
{
if
(
!
value
)
return
""
;
return
value
.
replace
(
/
\[
caption
[^\]]
*]/gi
,
" "
)
.
replace
(
/
\[\/
caption]/gi
,
" "
)
.
replace
(
/
\[[^
[
\]]
+]/g
,
" "
)
.
replace
(
/<img
[^
>
]
*>/gi
,
" "
)
.
replace
(
/<
[^
>
]
+>/g
,
" "
)
.
replace
(
/
\s
+/g
,
" "
)
.
trim
();
}
export
function
getDynamicPostExcerpt
(
post
:
DynamicPostItem
|
null
)
{
if
(
!
post
)
return
""
;
const
structuredContentText
=
(
post
.
content_structure
?.
post_content
??
[])
.
map
((
section
)
=>
stripHtml
(
section
.
content
))
.
filter
(
Boolean
)
.
join
(
" "
);
const
candidates
=
[
stripHtml
(
post
.
summary
),
stripHtml
(
post
.
content
),
structuredContentText
,
].
filter
(
Boolean
);
const
parts
:
string
[]
=
[];
for
(
const
candidate
of
candidates
)
{
const
normalizedCandidate
=
candidate
.
trim
();
if
(
!
normalizedCandidate
)
continue
;
const
isDuplicated
=
parts
.
some
((
part
)
=>
{
return
(
part
===
normalizedCandidate
||
part
.
includes
(
normalizedCandidate
)
||
normalizedCandidate
.
includes
(
part
)
);
});
if
(
!
isDuplicated
)
{
parts
.
push
(
normalizedCandidate
);
}
}
return
parts
.
join
(
" "
).
replace
(
/
\s
+/g
,
" "
).
trim
();
}
export
function
getDynamicPostBodyHtml
(
post
:
DynamicPostItem
|
null
)
{
if
(
!
post
)
return
""
;
...
...
src/app/(main)/search/page.tsx
View file @
6a37537a
...
...
@@ -13,8 +13,8 @@ import {
buildDynamicPostHref
,
buildVisibleNewsFilters
,
fetchDynamicPostList
,
getDynamicPostExcerpt
,
resolveDynamicPostImage
,
stripHtml
,
}
from
"@/app/(main)/[...slug]/templates/data"
;
import
type
{
DynamicPostItem
}
from
"@/app/(main)/[...slug]/templates/types"
;
...
...
@@ -43,11 +43,7 @@ const getTagClassName = (index: number) => {
};
function
SearchResultItem
({
item
,
index
}:
{
item
:
DynamicPostItem
;
index
:
number
})
{
const
fallbackDescription
=
item
.
content_structure
?.
post_content
?.
map
((
section
)
=>
section
.
content
)
.
join
(
" "
);
const
description
=
stripHtml
(
item
.
summary
)
||
stripHtml
(
item
.
content
)
||
stripHtml
(
fallbackDescription
);
const
description
=
getDynamicPostExcerpt
(
item
);
const
date
=
formatPostDate
(
item
.
release_at
||
item
.
published_at
||
item
.
created_at
);
const
categoryName
=
item
.
categories
[
0
]?.
name
||
"Tin tức"
;
...
...
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