GithubHelp home page GithubHelp logo

gatsby-source-pocket's Introduction

☠️ THIS PROJECT IS NO LONGER MAINTAINED ☠️

Please use gatsby-source-pocketapi instead 🚀


gatsby-source-pocket (deprecated)

Fetch data from Pocket API.

An example site for this plugin is available:

Breaking changes

  • v3.x - for Gatsby@4
  • v2.x - for Gatsby@3 and lower

How to Use

  1. npm install --save gatsby-source-pocket

  2. Go to https://getpocket.com/developer/ and create a new app to get your consumer key.

  3. Run node node_modules/node-getpocket/authorise --consumerkey 'YOUR-CONSUMER-KEY' and point your browser to http://127.0.0.1:8080to get your POCKET_ACCESS_TOKEN string.

    For more info on this process see https://github.com/vicchi/node-getpocket, which this plugin uses to talk to the Pocket API.

  4. In your gatsby-config.js

module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-pocket`,
      options: {
        consumerKey: INSERT_HERE_YOUR_POCKET_CONSUMER_KEY,
        accessToken: INSERT_HERE_YOUR_POCKET_ACCESS_TOKEN,
        weeksOfHistory: 52,
        apiMaxRecordsToReturn: 3000,
        getCurrentWeekOnly: `n`,
        stateFilterString: "archive",
        tagFilter: false,
        tagFilterString: "_untagged_",
        favouriteFilter: false,
        favouriteFilterValue: 0,
        searchFilter: false,
        searchFilterString: "These 21 things",
        domainFilter: false,
        domainFilterString: "buzzfeed.com"
      }
    }
  ]
};

Plugin Options

  • weeksOfHistory: Number of weeks worth of articles to fetch
  • apiMaxRecordsToReturn: Limit the number of records to return, to stop you hitting your api limit.
  • getCurrentWeekOnly:
    • n will fetch data based on the settings above.
    • y returns the current week and the last week (it'll make sense when you try it).
  • stateFilterString:
    • unread = only return unread items.
    • archive = only return archived items.
    • all = return both unread and archived items.
  • tagFilter:
    • true will use the tagFilterString value to get articles with that tag.
    • false will ignore the tagFilterString value
  • tagFilterString: If tagFilter is true then get articles tagged with this value. '\_untagged\_' will only return articles with no tags.
  • favouriteFilter (note UK English spelling!):
    • true will use the favouriteFilterValue to get articles that have/have not been favourited in Pocket
    • false will ignore the favouriteFilterValue
  • favouriteFilterValue:
    • 0 = only return un-favorited items
    • 1 = only return favorited items
  • searchFilter:
    • true will use the searchFilterString value to get articles with that value in the URL or title.
    • false will ignore the searchFilterString value
  • searchFilterString: If searchFilter is true then get articles with this value in the URL or title.
  • domainFilter:
    • true will use the domainFilterString value to get articles for that domain.
    • false will ignore the domainFilterString value
  • domainFilterString: If domainFilter is true then get articles from this domain.

How to query your Pocket articles data using GraphQL

Below is a sample query for fetching all Article nodes.

query PageQuery {
  allPocketArticle(sort: { fields: readWeek }) {
    edges {
      node {
        id
        url
        title
        favourite
        excerpt
        is_article
        is_index
        has_video
        has_image
        word_count
        tags
        time_read
        readDay
        readWeek
        articleDomain
        domainFavicon
        image {
          item_id
          src
          width
          height
        }
      }
    }
  }
}

gatsby-source-pocket's People

Contributors

conradj avatar laugri avatar nakleiderer avatar vacilando avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gatsby-source-pocket's Issues

Make it possible to fetch more /all Pocket items

Pocket API seems to have a limit of 10k items per request. In any case, fetching 10k requests takes considerable time, and it times out sometimes. It would be much better to fetch large archives (eg 35k in our case) using several requests with a smaller limit (of eg 5k).

Working on a PR for this, will you be able to look at it, @conradj?
Alternatively, would you consider providing write access to this repo so that we can collaborate?

See also Rate limit clarification #14.

Accessing posts by tag

Hi, is it possible to filter posts by tag?
My idea is to share only one tag from my pocket account, something like "pocket-linklog", and keep the remaining items on private.

Expose Pocket tags in GraphQL

According to the Pocket API docs, the tags associated with an article are returned. However, I cannot query field tags on type PocketArticle. Could we expose the tags returned by the Pocket API in GraphQL?

Rate limit clarification

According to https://getpocket.com/developer/docs/rate-limits

  • "Each user is limited to 320 calls per hour"
  • Each application is limited to 10,000 calls per hour

It's not clear how does this translate when using this plugin.
Gatsby builds a site at once, meaning a burst of calls to the Pocket API.

Does each record in Pocket need one call to retrieve? If so, can we get max 320 or 10k records only?
Or is the plugin getting them in batches, so it requires less calls?
What's the maximum size of Pocket API collection of links that can be retrieved using this module / Gatsby?

Filter by tagged items?

It's possible to use value "untagged" in tagFilter to get all items that are not tagged yet.

Is it possible to do the opposite - get all items that are tagged?
Perhaps by negating the condition, something like "NOT untagged"?

Support Gatsby 5

warn Plugin gatsby-source-pocket is not compatible with your gatsby version 5.2.0 - It requires gatsby@^4.0.0

Multiple sources

Hello, nice source plugin, but I have a particular use case that I'm not is possible or not, and I am newish to Gatsby, so bear with me.

I want to create pages based on different Pocket tag filters, but the Pocket API doesn't return the tag in the response. So I tried creating multiple instances of the plugin with different tag filters defined in Gatsby config, and that works, but now I'm not sure how to detect the difference between those sources anywhere else in Gatsby. If that makes any sense at all, I'd love to know if you think that's possible.

undefined tags throw an error

Hi guys !

First, thanks for having created the plugin! I'm using it to display my favorite articles on my personal website (which is not published yet).
I have run into the following error:

image

Indeed, this article has no tags. See the object returned by the Pocket API:

"1952903649": {
      "item_id": "1952903649",
      "resolved_id": "1952903649",
      "given_url": "https:\/\/hbr.org\/2017\/11\/many-strategies-fail-because-theyre-not-actually-strategies",
      "given_title": "Many Strategies Fail Because They’re Not Actually Strategies",
      "favorite": "1",
      "status": "1",
      "time_added": "1517864651",
      "time_updated": "1553810681",
      "time_read": "1518768063",
      "time_favorited": "1553640743",
      "sort_id": 47,
      "resolved_title": "Many Strategies Fail Because They’re Not Actually Strategies",
      "resolved_url": "https:\/\/hbr.org\/2017\/11\/many-strategies-fail-because-theyre-not-actually-strategies",
      "excerpt": "Many strategy execution processes fail because the firm does not have something worth executing. The strategy consultants come in, do their work, and document the new strategy in a PowerPoint presentation and a weighty report.",
      "is_article": "1",
      "is_index": "0",
      "has_video": "0",
      "has_image": "1",
      "word_count": "1377",
      "lang": "en",
      "time_to_read": 6,
      "top_image_url": "https:\/\/hbr.org\/resources\/images\/article_assets\/2017\/11\/nov17-08-135629213-Lobo-Press.jpg",
      "authors": {
        "97789314": {
          "item_id": "1952903649",
          "author_id": "97789314",
          "name": "Freek Vermeulen",
          "url": "https:\/\/hbr.org\/search?term=freek%20vermeulen"
        }
      },
      "image": {
        "item_id": "1952903649",
        "src": "https:\/\/hbr.org\/resources\/images\/article_assets\/2017\/11\/nov17-08-135629213-Lobo-Press.jpg",
        "width": "1200",
        "height": "675"
      },
      "images": {
        "1": {
          "item_id": "1952903649",
          "image_id": "1",
          "src": "https:\/\/hbr.org\/resources\/images\/article_assets\/2017\/11\/nov17-08-135629213-Lobo-Press.jpg",
          "width": "1200",
          "height": "675",
          "credit": "Lobo Press\/Getty Images",
          "caption": "Lobo Press\/Getty Images"
        }
      },
      "domain_metadata": {
        "name": "Harvard Business Review",
        "logo": "https:\/\/logo.clearbit.com\/hbr.org?size=800",
        "greyscale_logo": "https:\/\/logo.clearbit.com\/hbr.org?size=800&greyscale=true"
      },
      "listen_duration_estimate": 533
    },

It's a one-line fix at line 135 tags: Object.keys(datum.tags), but I can make a PR if you don't have time for it.

Many thanks

Warning on author node

Hi Conrad,

Thanks for merging the authors PR. After upgrading to 2.2.0, I get the following warning when running gatsby develop:

image

I tried to change the createNode code to fix it but I can't seem to make it have the proper id/item_id (which should be the author_id). I haven't found documentation on how to properly create nodes so I am stuck. Can you maybe point me in the right direction so I can fix it? Otherwise I'll make a PR removing the authors field.

Add `readDay` field

I use Pocket pretty extensively, and would like to group my read links by day, rather than by week. Doing so manually would be tedious, but if the Pocket source exposed readDay (similar to readWeek) I could group that really easily. Would you be willing to add this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.