diff --git a/.env b/.env index a6cecfad..250e80e3 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ API_KEY_LASTFM= API_KEY_TRAKT= API_KEY_WEBMENTIONS_CORYD_DEV= -ACCESS_TOKEN_MATTER= +API_TOKEN_READWISE= SITE_ID_CLICKY= SITE_KEY_CLICKY= SECRET_FEED_ALBUM_RELEASES= diff --git a/config/filters.js b/config/filters.js index 7065a18d..21fca2c2 100644 --- a/config/filters.js +++ b/config/filters.js @@ -42,7 +42,12 @@ module.exports = { return visitors(b) - visitors(a) }) }, - tagLookup: (url, tagMap) => tagMap[url], + tagLookup: (url, tagMap) => { + if (!url) return + if (url.includes('goodreads.com')) return '#Books #Reading' + if (url.includes('letterboxd.com')) return '#Movies #Letterboxd' + return tagMap[url] || '' + }, webmentionsByUrl: (webmentions, url) => { const allowedTypes = ['mention-of', 'in-reply-to', 'like-of', 'repost-of'] diff --git a/src/_data/links.js b/src/_data/links.js index bcb47bfc..1fcb359d 100644 --- a/src/_data/links.js +++ b/src/_data/links.js @@ -1,27 +1,27 @@ const EleventyFetch = require('@11ty/eleventy-fetch') module.exports = async function () { - const MATTER_TOKEN = process.env.ACCESS_TOKEN_MATTER - const headers = { Cookie: MATTER_TOKEN } - const url = `https://web.getmatter.com/api/library_items/favorites_feed` + const READWISE_TOKEN = process.env.API_TOKEN_READWISE + const headers = { Authorization: `Token ${READWISE_TOKEN}` } + const url = 'https://readwise.io/api/v3/list?category=article' const res = EleventyFetch(url, { duration: '1h', type: 'json', fetchOptions: { headers }, }) - const feed = await res - return feed.feed.map((article) => { - const tags = article['content']['tags'].map((tag) => tag['name']) + const data = await res + const links = data['results'].filter((result) => Object.keys(result.tags).includes('share')) + return links.map((link) => { return { - url: article['content']['url'], - title: article['content']['title'], - date: article['content']['library']['modified_date'] - ? new Date(article['content']['library']['modified_date']) - : new Date(article['content']['publication_date']), - description: article['content']['excerpt'], - notes: article['content']['my_notes'] || '', - tags, - id: btoa(article['id']), + title: link['title'], + url: link['source_url'], + date: link['published_date'] + ? new Date(link['published_date']) + : new Date(link['created_at']), + summary: link['summary'], + notes: link['notes'], + tags: Object.keys(link.tags).filter((tag) => tag !== 'share' && tag !== 'shortlist'), + id: btoa(link['source_url']), } }) } diff --git a/src/uses.md b/src/uses.md index 919f3224..cc775998 100644 --- a/src/uses.md +++ b/src/uses.md @@ -85,7 +85,7 @@ Software and services that I use for work and my own enjoyment. - [Trakt](https://trakt.tv) - [Letterboxd](https://letterboxd.com) - [Goodreads](https://goodreads.com) -- [Matter](https://getmatter.com) +- [Reader](https://readwise.io/read) - [Slack](http://slack.com) - [Discord](http://discord.com)