Skip to content

Commit

Permalink
fix(gatsby-source-medium): fix data fecthing & add limitation to read…
Browse files Browse the repository at this point in the history
…me (#17547)

* Temporary workaround for Medium CAPTCA issue

* chore(gatsby-source-medium): updated README to mention the limitation and remove limit option from query

* Fix README Prettier issues

* Update packages/gatsby-source-medium/README.md

Co-Authored-By: LB <laurie@gatsbyjs.com>

* chore: format

Co-authored-by: GatsbyJS Bot <mathews.kyle+gatsbybot@gmail.com>
Co-authored-by: Ollie Monk <omonk@users.noreply.github.com>
Co-authored-by: Ward Peeters <ward@coding-tech.com>
Co-authored-by: LB <laurie@gatsbyjs.com>
  • Loading branch information
5 people committed Mar 2, 2020
1 parent 8f75304 commit 3ba9f9c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
13 changes: 1 addition & 12 deletions packages/gatsby-source-medium/README.md
@@ -1,9 +1,7 @@
# gatsby-source-medium

Source plugin for pulling data into Gatsby from an unofficial Medium JSON
endpoint. Unfortunately the JSON endpoint does not provide the complete stories,
but only previews. If you need the complete stories, you might have a look at
something like
endpoint. Unfortunately the JSON endpoint does not provide the complete stories, but only previews. And due to a limitation placed by Medium, only the most recent 10 posts are returned. If you need the complete stories, you might have a look at something like
[gatsby-source-rss](https://github.com/jondubin/gatsby-source-rss).

## Install
Expand All @@ -19,7 +17,6 @@ plugins: [
resolve: `gatsby-source-medium`,
options: {
username: `username/publication`,
limit: 200,
},
},
]
Expand All @@ -31,14 +28,6 @@ plugins: [

Remember that if you are fetching a user, prepend your username with `@`.

#### Limit

**Note: this only affects requests for users and not publications.**

Limit is optional and will default to 100.

You must set a higher limit if you want more than 100 posts. If you want fewer, you can either use this setting, or add a limit parameter to your graphql query.

## How to query

Get all posts with the preview image ID and the author's name:
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-source-medium/src/gatsby-node.js
@@ -1,7 +1,7 @@
const axios = require(`axios`)

const fetch = (username, limit = 100) => {
const url = `https://medium.com/${username}/latest?format=json&limit=${limit}`
const url = `https://medium.com/${username}/?format=json&limit=${limit}`
return axios.get(url)
}

Expand Down

0 comments on commit 3ba9f9c

Please sign in to comment.