diff --git a/.env b/.env index 8204e5c3..bc39b647 100644 --- a/.env +++ b/.env @@ -3,5 +3,7 @@ API_KEY_TRAKT= API_KEY_WEBMENTIONS_CORYD_DEV= API_BEARER_APPLE_MUSIC= API_TOKEN_APPLE_MUSIC= -SECRET_FEED_INSTAPAPER_FAVORITES= +APPLE_RENEW_TOKEN_URL= +CONSUMER_KEY_POCKET= +ACCESS_TOKEN_POCKET= SECRET_FEED_ALBUM_RELEASES= \ No newline at end of file diff --git a/src/_data/links.js b/src/_data/links.js index c29b62f5..10e26a59 100644 --- a/src/_data/links.js +++ b/src/_data/links.js @@ -1,24 +1,31 @@ -const { extract } = require('@extractus/feed-extractor') -const { AssetCache } = require('@11ty/eleventy-fetch') +const EleventyFetch = require('@11ty/eleventy-fetch') module.exports = async function () { - const URL = process.env.SECRET_FEED_INSTAPAPER_LIKES - // noinspection JSCheckFunctionSignatures - const asset = new AssetCache('links_data') - if (asset.isCacheValid('1h')) return await asset.getCachedValue() - const res = await extract(URL, { - getExtraEntryFields: (feedEntry) => { - return { - time: feedEntry['pubDate'] || '', - } + const KEY = process.env.CONSUMER_KEY_POCKET + const TOKEN = process.env.ACCESS_TOKEN_POCKET + const url = 'https://getpocket.com/v3/get' + const res = EleventyFetch(url, { + duration: '1h', + type: 'json', + fetchOptions: { + method: 'POST', + body: JSON.stringify({ + 'consumer_key': KEY, + 'access_token': TOKEN, + 'favorite': 1, + }), + headers: { + 'Content-Type': 'application/json', + }, }, + }).catch() + const data = await res + const articles = Object.values(data.list).map(article => { + return { + title: article['resolved_title'], + url: article['resolved_url'], + time: article['time_added'] + } }) - .catch((error) => { - console.log(error.message) - }) - .catch() - const data = res.entries - const links = data.splice(0, 5) - await asset.save(links, 'json') - return links + return articles.sort((a, b) => b.time - a.time).splice(0, 5) } diff --git a/src/_includes/icons/instapaper.liquid b/src/_includes/icons/instapaper.liquid deleted file mode 100644 index b54acc0f..00000000 --- a/src/_includes/icons/instapaper.liquid +++ /dev/null @@ -1,13 +0,0 @@ -{% if site.instapaper != "" %} - - - - Instapaper - -{% endif %} diff --git a/src/_includes/now.liquid b/src/_includes/now.liquid index 1af7e760..930a8677 100644 --- a/src/_includes/now.liquid +++ b/src/_includes/now.liquid @@ -138,7 +138,7 @@ layout: main