Skip to content

Commit

Permalink
Merge pull request #3 from arifszn/change-repo-name
Browse files Browse the repository at this point in the history
Change repo name
  • Loading branch information
arifszn authored Mar 29, 2022
2 parents 419e298 + e6fecd6 commit d64d7cf
Show file tree
Hide file tree
Showing 6 changed files with 438 additions and 439 deletions.
69 changes: 32 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,57 @@

<h1 align="center">Article-api</h1>
<p align="center">Api client for dev.to and medium to fetch recent articles</p>
<h1 align="center">Blog-js</h1>
<p align="center">Api client to get recent blog posts from popular blogging platforms</p>

<p align="center">
<a href="https://www.npmjs.com/package/article-api"><img src="https://img.shields.io/npm/v/article-api"/></a>
<a href="https://github.com/arifszn/article-api/blob/main/LICENSE"><img src="https://img.shields.io/github/license/arifszn/article-api"/></a>
<a href="https://www.npmjs.com/package/@arifszn/blog-js"><img src="https://img.shields.io/npm/v/@arifszn/blog-js"/></a>
<a href="https://github.com/arifszn/blog-js/blob/main/LICENSE"><img src="https://img.shields.io/github/license/arifszn/blog-js"/></a>
</p>

<br/>
<br/>

<p>Get recent articles from dev.to and medium by just providing your username and showcase them on your portfolio or blog site.</p>

> PHP version: <a href="https://github.com/arifszn/article-api-php">Article-api</a>
<p>Get recent blog posts from popular blogging platforms by just providing your username and showcase them on your portfolio or blog site.</p>

> PHP version: <a href="https://github.com/arifszn/blog-js-php">Blog-js</a>
## Installation

Install via <a href="https://www.npmjs.com/package/article-api">NPM</a>
Install via <a href="https://www.npmjs.com/package/@arifszn/blog-js">NPM</a>

```
npm install article-api
npm install @arifszn/blog-js
```

Install via <a href="https://yarnpkg.com/package/article-api">Yarn</a>
Or install via <a href="https://yarnpkg.com/package/@arifszn/blog-js">Yarn</a>

```
yarn add article-api
yarn add @arifszn/blog-js
```


## Usage

- **getDevtoArticle()**: Get 10 recent articles from [dev.to](https://dev.to)

```js
const { getDevtoArticle } = require("article-api");
- **getDevtoPost()**: Get 10 recent posts from [dev.to](https://dev.to)

getDevtoArticle({
user: 'yourusername'
}).then(res => {
console.log(res);
})
```

- **getMediumArticle()**: Get 10 recent articles from [medium](https://medium.com)
```js
const { getDevtoPost } = require('@arifszn/blog-js');

```js
const { getMediumArticle } = require("article-api");
getDevtoPost({
user: 'yourusername',
}).then((res) => {
console.log(res);
});
```

getMediumArticle({
user: 'yourusername'
}).then(res => {
console.log(res);
})
```
- **getMediumPost()**: Get 10 recent posts from [medium](https://medium.com)

```js
const { getMediumPost } = require('@arifszn/blog-js');
getMediumPost({
user: 'yourusername',
}).then((res) => {
console.log(res);
});
```

## Sample Response

Expand All @@ -78,19 +76,16 @@ yarn add article-api
]
```


## Contribute

To contribute, clone this repo locally and commit your code on a new branch. Feel free to create an issue or make a pull request.


## Support

<a href="https://www.buymeacoffee.com/arifszn" target="_blank">
<img src="https://raw.githubusercontent.com/arifszn/arifszn/main/assets/bmc-button.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" >
</a>


## License

**Article-api** is licensed under the [MIT License](https://github.com/arifszn/article-api/blob/main/LICENSE).
**Blog-js** is licensed under the [MIT License](https://github.com/arifszn/blog-js/blob/main/LICENSE).
24 changes: 12 additions & 12 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// Type definitions for article-api
// Project https://github.com/arifszn/article-api
// Author: MD. Ariful Alam <[email protected]>
// Type definitions for blog-js
// Project https://github.com/arifszn/blog-js
// Author: Ariful Alam <[email protected]>

interface options {
/**
* Username
*/
user: string;
/**
* Username
*/
user: string;
}

/**
* Get most recent medium articles
* Get most recent medium posts
*/
declare function getMediumArticle(options: options): Promise<R>;
declare function getMediumPost(options: options): Promise<R>;

/**
* Get most recent dev.to articles
* Get most recent dev.to posts
*/
declare function getDevtoArticle(options: options): Promise<R>;
declare function getDevtoPost(options: options): Promise<R>;

export { getMediumArticle, getDevtoArticle };
export { getMediumPost, getDevtoPost };
18 changes: 9 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
const { request, formatMediumArticle, formatDevtoArticle } = require("./util");
const { request, formatMediumPost, formatDevtoPost } = require("./util");

module.exports = {
/**
* Get most recent medium articles
* Get most recent medium posts
*
* @param {Object} param
* @returns {Array} articles
* @returns {Array} posts
*/
getMediumArticle: async ({
getMediumPost: async ({
user
}) => {
try {
if (!user) return [];

let response = await request(`https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/@${user}`);

return response.data.items.map(item => formatMediumArticle(item));
return response.data.items.map(item => formatMediumPost(item));
} catch (error) {
return [];
}
},
/**
* Get most recent dev.to articles
* Get most recent dev.to posts
*
* @param {Object} param
* @returns {Array} articles
* @returns {Array} posts
*/
getDevtoArticle: async ({
getDevtoPost: async ({
user
}) => {
try {
if (!user) return [];

let response = await request(`https://dev.to/api/articles?per_page=10&username=${user}`);

return response.data.map(item => formatDevtoArticle(item));
return response.data.map(item => formatDevtoPost(item));
} catch (error) {
return [];
}
Expand Down
Loading

0 comments on commit d64d7cf

Please sign in to comment.