1- import { repeatAction } from "./functions" ;
21import {
32 AuthorPostsResponse ,
43 ExploreResponse ,
@@ -8,8 +7,10 @@ import {
87 WebSiteInformationResponse ,
98 SortParametr ,
109 TagsResponse ,
11- TopAuthorResponse
10+ TopAuthorResponse ,
11+ PostTag
1212} from "./types" ;
13+ import { repeatAction } from "./functions" ;
1314
1415const hycom = {
1516 url : "https://hycom.ir" ,
@@ -39,7 +40,9 @@ async function topAuthors(limit: number = 10) {
3940 a . tag = a . display_name + "-" + a . profile_id
4041 return a ;
4142 } ) ;
42- } catch {
43+ }
44+
45+ catch {
4346 return null ;
4447 }
4548}
@@ -59,7 +62,9 @@ async function authorPosts(tag: string, limit: number = 10, sort: SortParametr =
5962 const data : AuthorPostsResponse = await response ! . json ( ) ;
6063
6164 return data . data ;
62- } catch {
65+ }
66+
67+ catch {
6368 return null ;
6469 }
6570}
@@ -77,7 +82,9 @@ async function getTags(limit: number = 20) {
7782 const data : TagsResponse = await response ! . json ( ) ;
7883
7984 return data . data ;
80- } catch {
85+ }
86+
87+ catch {
8188 return null ;
8289 }
8390}
@@ -99,11 +106,16 @@ async function explore(search: string = "", page: number = 1, limit: number = 12
99106 const data : ExploreResponse = await response ! . json ( ) ;
100107
101108 return data . data . map ( post => {
102- post . author_tag = post . author_name + "-" + post . author_name_id
109+ post . author_tag = post . author_name_id ;
110+ post . author_image = hycom . url + "/cdn" + post . author_image
111+ post . image = hycom . url + post . image
112+ post . tags = post . tags . map ( a => ( a as any as PostTag ) . name ) ;
103113
104114 return post ;
105115 } ) ;
106- } catch {
116+ }
117+
118+ catch {
107119 return null ;
108120 }
109121}
@@ -124,7 +136,9 @@ async function websiteInformation() {
124136 siteInfo . last_post = ( await lastPosts ( 1 ) ) ! [ 0 ] ;
125137
126138 return siteInfo ;
127- } catch {
139+ }
140+
141+ catch {
128142 return null ;
129143 }
130144}
0 commit comments