diff --git a/.env b/.env index 82c16002..242f9d8d 100644 --- a/.env +++ b/.env @@ -4,4 +4,5 @@ API_KEY_WEBMENTIONS_CORYD_DEV= SITE_ID_CLICKY= SITE_KEY_CLICKY= SECRET_FEED_ALBUM_RELEASES= -SECRET_FEED_GOODREADS= \ No newline at end of file +SECRET_FEED_GOODREADS= +SECRET_FEED_INSTAPAPER_LIKES= \ No newline at end of file diff --git a/src/_data/articles.js b/src/_data/articles.js new file mode 100644 index 00000000..9bda9a3c --- /dev/null +++ b/src/_data/articles.js @@ -0,0 +1,24 @@ +const Parser = require('rss-parser') +const { AssetCache } = require('@11ty/eleventy-fetch') + +module.exports = async function () { + const parser = new Parser() + const url = process.env.SECRET_FEED_INSTAPAPER_LIKES + const asset = new AssetCache('articles_data') + if (asset.isCacheValid('1h')) return await asset.getCachedValue() + const res = await parser.parseURL(url).catch((error) => { + console.log(error.message) + }) + const articles = res.items.map((item) => { + return { + title: item['title'], + date: item['pubDate'], + summary: item['description'], + url: item['link'], + id: item['guid'], + type: 'article', + } + }) + await asset.save(articles, 'json') + return articles +} diff --git a/src/_includes/now.liquid b/src/_includes/now.liquid index 2c1f8f7a..a0147b43 100644 --- a/src/_includes/now.liquid +++ b/src/_includes/now.liquid @@ -6,6 +6,7 @@ layout: main {% render "partials/now/media-grid.liquid", data:artists, icon: "microphone-2", title: "Artists", shape: "square", count: 8, loading: 'eager' %} {% render "partials/now/media-grid.liquid", data:albums, icon: "vinyl", title: "Albums", shape: "square", count: 8, loading: 'lazy' %} {% render "partials/now/albumReleases.liquid", albumReleases:albumReleases %} +{% render "partials/now/articles.liquid", articles:articles %} {% render "partials/now/media-grid.liquid", data:books, icon: "books", title: "Books", shape: "vertical", count: 6, loading: 'lazy' %} {% render "partials/now/media-grid.liquid", data:movies, icon: "movie", title: "Movies", shape: "vertical", count: 6, loading: 'lazy' %} {% render "partials/now/media-grid.liquid", data:tv, icon: "device-tv", title: "TV", shape: "vertical", count: 6, loading: 'lazy' %} diff --git a/src/_includes/partials/now/articles.liquid b/src/_includes/partials/now/articles.liquid new file mode 100644 index 00000000..2837d75b --- /dev/null +++ b/src/_includes/partials/now/articles.liquid @@ -0,0 +1,15 @@ +{% if articles.size > 0 %} +

+ {% tablericon "news" "Articles" %} + Articles +

+ +{% endif %} \ No newline at end of file diff --git a/src/feeds/articles.liquid b/src/feeds/articles.liquid new file mode 100644 index 00000000..960e0e90 --- /dev/null +++ b/src/feeds/articles.liquid @@ -0,0 +1,13 @@ +--- +layout: null +eleventyExcludeFromCollections: true +permalink: /feeds/articles +--- +{% render "partials/feeds/rss.liquid" + permalink:"/feeds/articles" + title:"Articles • Cory Dransfeldt" + description:"Articles I've liked recently." + data:articles + updated:articles[0].date + site:site +%} \ No newline at end of file