11"use client" ;
22
3+ import { Tag } from "@/backend/models/domain-models" ;
34import * as articleActions from "@/backend/services/article.actions" ;
45import ArticleCard from "@/components/ArticleCard" ;
56import VisibilitySensor from "@/components/VisibilitySensor" ;
7+ import { useTranslation } from "@/i18n/use-translation" ;
68import { readingTime } from "@/lib/utils" ;
79import getFileUrl from "@/utils/getFileUrl" ;
810import { useInfiniteQuery } from "@tanstack/react-query" ;
9- import { useMemo } from "react" ;
11+ import React , { useMemo } from "react" ;
1012
1113interface TagArticleFeedProps {
12- tagId : string ;
14+ tag : Tag ;
1315}
1416
15- const TagArticleFeed : React . FC < TagArticleFeedProps > = ( { tagId } ) => {
17+ const TagArticleFeed : React . FC < TagArticleFeedProps > = ( { tag } ) => {
18+ const { _t } = useTranslation ( ) ;
1619 const tagFeedQuery = useInfiniteQuery ( {
17- queryKey : [ "tag-articles" , tagId ] ,
20+ queryKey : [ "tag-articles" , tag . id ] ,
1821 queryFn : ( { pageParam } ) =>
1922 articleActions . articlesByTag ( {
20- tag_id : tagId ,
23+ tag_id : tag . id ,
2124 limit : 5 ,
2225 page : pageParam ,
2326 } ) ,
@@ -37,18 +40,14 @@ const TagArticleFeed: React.FC<TagArticleFeedProps> = ({ tagId }) => {
3740 return tagFeedQuery . data ?. pages ?. [ 0 ] ?. meta ?. total ?? 0 ;
3841 } , [ tagFeedQuery . data ] ) ;
3942
40- const tagName = useMemo ( ( ) => {
41- return tagFeedQuery . data ?. pages ?. [ 0 ] ?. tagName ?? "Unknown Tag" ;
42- } , [ tagFeedQuery . data ] ) ;
43-
4443 // Show loading skeletons
4544 if ( tagFeedQuery . isPending ) {
4645 return (
4746 < div className = "flex flex-col gap-10 mt-2" >
48- < div className = "h-56 bg-muted animate-pulse mx-4" />
49- < div className = "h-56 bg-muted animate-pulse mx-4" />
50- < div className = "h-56 bg-muted animate-pulse mx-4" />
51- < div className = "h-56 bg-muted animate-pulse mx-4" />
47+ < div className = "h-56 bg-muted animate-pulse mx-4" suppressHydrationWarning = { true } />
48+ < div className = "h-56 bg-muted animate-pulse mx-4" suppressHydrationWarning = { true } />
49+ < div className = "h-56 bg-muted animate-pulse mx-4" suppressHydrationWarning = { true } />
50+ < div className = "h-56 bg-muted animate-pulse mx-4" suppressHydrationWarning = { true } />
5251 </ div >
5352 ) ;
5453 }
@@ -78,10 +77,10 @@ const TagArticleFeed: React.FC<TagArticleFeedProps> = ({ tagId }) => {
7877 return (
7978 < div className = "flex flex-col items-center justify-center py-12" >
8079 < h2 className = "text-xl font-semibold text-gray-900 dark:text-white mb-2" >
81- No articles found
80+ { _t ( " No articles found" ) }
8281 </ h2 >
8382 < p className = "text-gray-600 dark:text-gray-400" >
84- No articles have been tagged with “ { tagName } ” yet.
83+ { _t ( ` No articles have been tagged with "$" yet.` , [ tag . name ] ) }
8584 </ p >
8685 </ div >
8786 ) ;
@@ -91,10 +90,10 @@ const TagArticleFeed: React.FC<TagArticleFeedProps> = ({ tagId }) => {
9190 < >
9291 < div className = "mb-8" >
9392 < h1 className = "text-3xl font-bold text-gray-900 dark:text-white" >
94- Articles tagged with “ { tagName } ”
93+ { _t ( ` Articles tagged with "$"` , [ tag . name ] ) }
9594 </ h1 >
9695 < p className = "text-gray-600 dark:text-gray-400 mt-2" >
97- Found { totalArticles } articles
96+ { _t ( ` Found $ articles` , [ totalArticles ] ) }
9897 </ p >
9998 </ div >
10099
@@ -106,7 +105,9 @@ const TagArticleFeed: React.FC<TagArticleFeedProps> = ({ tagId }) => {
106105 handle = { article ?. handle ?? "" }
107106 title = { article ?. title ?? "" }
108107 excerpt = { article ?. excerpt ?? "" }
109- coverImage = { article ?. cover_image ? getFileUrl ( article . cover_image ) : "" }
108+ coverImage = {
109+ article ?. cover_image ? getFileUrl ( article . cover_image ) : ""
110+ }
110111 author = { {
111112 id : article ?. user ?. id ?? "" ,
112113 name : article ?. user ?. name ?? "" ,
@@ -133,4 +134,4 @@ const TagArticleFeed: React.FC<TagArticleFeedProps> = ({ tagId }) => {
133134 ) ;
134135} ;
135136
136- export default TagArticleFeed ;
137+ export default TagArticleFeed ;
0 commit comments