Skip to content

Commit 464ae44

Browse files
authored
Merge pull request #4 from Persian-Caesar/1.1.2
1.1.2
2 parents f04147b + 40f5992 commit 464ae44

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ const {
135135
| Function | Description | Parameters | Returns | |
136136
| --------------------------------------------------- | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | -------- |
137137
| `topAuthors(limit?)` | Fetches authors sorted by total views | `limit` (number, default `10`): number of authors to return (1–50) | `Author[]` | |
138-
| `authorPosts(name, limit?, sort?)` | Retrieves published posts by a given author | `name` (string): display name and profile ID (e.g., "jane-doe-123")<br>`limit` (number, default `10`)<br>`sort` ("newest" | "most\_viewed", default "newest") | `Post[]` |
138+
| `authorPosts(tag, limit?, sort?)` | Retrieves published posts by a given author | `tag` (string): display name and profile ID (e.g., "jane-doe-123")<br>`limit` (number, default `10`)<br>`sort` ("newest" | "most\_viewed", default "newest") | `Post[]` |
139139
| `getTags(limit?)` | Returns tags with their associated post counts | `limit` (number, default `20`): number of tags (1–100) | `Tag[]` | |
140140
| `explore(search?, page?, limit?, sort?, tag?)` | Paginated list of articles with filtering and sorting | `search` (string)<br>`page` (number, default `1`)<br>`limit` (number, default `12`)<br>`sort` ("recommended" | | |
141141
| "newest" | | | | |

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@persian-caesar/hycom-api",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "A package for easy using hycom.ir api service.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -33,4 +33,4 @@
3333
"devDependencies": {
3434
"@types/node": "^22.15.21"
3535
}
36-
}
36+
}

src/HyCom.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ async function topAuthors(limit: number = 10) {
190190
const response = await fetch(hycom.url + hycom.topAuthor + `?limit=${limit}`);
191191
const data: TopAuthorResponse = await response.json();
192192

193-
return data.data;
193+
return data.data.map(a => {
194+
a.tag = a.display_name + "-" + a.profile_id
195+
return a;
196+
});
194197
} catch {
195198
return null;
196199
}
@@ -199,13 +202,13 @@ async function topAuthors(limit: number = 10) {
199202
/**
200203
* Returns published posts by a specific author.
201204
*
202-
* @param display_name Author display name and profile ID. (format: name-code)
205+
* @param tag Author display name and profile ID. (format: name-code)
203206
* @param limit Number of authors to return. (1-50)
204207
* @param sort Sort order. (newest, most_viewed)
205208
*/
206-
async function authorPosts(display_name: string, limit: number = 10, sort: SortParametr = "newest") {
209+
async function authorPosts(tag: string, limit: number = 10, sort: SortParametr = "newest") {
207210
try {
208-
const response = await fetch(hycom.url + hycom.authorPosts + `/${display_name}?limit=${limit}&sort=${sort}`);
211+
const response = await fetch(hycom.url + hycom.authorPosts + `/${tag}?limit=${limit}&sort=${sort}`);
209212
const data: AuthorPostsResponse = await response.json();
210213

211214
return data.data;

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export type SortParametr = "newest" | "most_viewed";
22
export type ExploreSortParametr = "recommended" | SortParametr;
33

44
export interface Author {
5+
tag: string;
56
display_name: string;
67
profile_id: string;
78
url: string;

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
1212

1313
/* Language and Environment */
14-
"target": "ES2024", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
14+
"target": "ES2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
1515
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
1616
// "jsx": "preserve", /* Specify what JSX code is generated. */
1717
// "libReplacement": true, /* Enable lib replacement. */

0 commit comments

Comments
 (0)