Publishing my Pocket reading list on this website
Reading time: 3 min read
In case you don’t know, Pocket is a service that lets you save links to read/watch later. It’s really well-integrated into Firefox.
readingList.js that 1) pulls in all my items saved in Pocket, 2) reverses the order so they’re roughly in descending publication date order, and 3) excludes any items I’ve tagged in Pocket as ‘private’.
I host this website on Netlify. Netlify runs a build of your site when you make a change to the git repository it’s linked to. Usually these changes would be things like adding a new blogpost or changing some CSS. But when I add an article to Pocket, no changes are made to the files in the git repository. The readingList.js file stays the same.
So, for automated updating of the Reading List page, I need to trigger a build whenever something changes in my Pocket account.
I’m doing this using IFTT ‘Applets’. I’ve set up triggers to run whenever 1) a new item is added to my Pocket account, 2) if an item is archived, or 3) if an item is tagged as ‘private’.
And because IFTT can’t detect if a tag is removed from a Pocket item, I’ve also added a trigger that runs once a day at midnight. This one makes sure any items are displayed which I’d previously tagged as ‘private’ but then had that tag removed.
When these ‘applets’ above run, they send a webhook to Netlify to start a new build - using a ‘Build hook’ from the ‘Build & Deploy’ settings in Netlify. In IFTT, you set a POST request to a URL generated by Netlify that looks like this:
Notice you can include a
trigger_title parameter which can be unique to each IFTT applet. This shows up in the Netlify build logs so you can check back on what happened.
When these applets start a new build, the site pulls in the updated Pocket data and then rebuilds the HTML using the new Pocket data. I don’t have to do anything other than manage my Pocket account for the changes to be replicated on my site.
That’s it. I’ve possibly missed something. Let me know if you have any questions :-)
Thanks also for Felix Neumann’s tool that lets you easily generate a Pocket Access Token.