diff --git a/.env b/.env index c1fa2a1a..f2067092 100644 --- a/.env +++ b/.env @@ -1,3 +1,4 @@ API_KEY_LASTFM= API_KEY_TRAKT= -API_KEY_WEBMENTIONS_CORYD_DEV= \ No newline at end of file +API_KEY_WEBMENTIONS_CORYD_DEV= +ACCESS_TOKEN_MATTER= \ No newline at end of file diff --git a/src/_data/articles.js b/src/_data/articles.js new file mode 100644 index 00000000..102fbd6b --- /dev/null +++ b/src/_data/articles.js @@ -0,0 +1,15 @@ +const EleventyFetch = require('@11ty/eleventy-fetch') + +module.exports = async function () { + const MATTER_TOKEN = process.env.ACCESS_TOKEN_MATTER + const headers = { Authorization: `Bearer ${MATTER_TOKEN}` } + const url = `https://web.getmatter.com/api/library_items/favorites_feed` + const res = EleventyFetch(url, { + duration: '1h', + type: 'json', + fetchOptions: { headers }, + }) + const feed = await res + const articles = feed.feed.splice(0, 5) + return articles +} diff --git a/src/_data/movies.js b/src/_data/movies.js index 03a81548..a620e532 100644 --- a/src/_data/movies.js +++ b/src/_data/movies.js @@ -9,7 +9,9 @@ module.exports = async function () { getExtraEntryFields: (feedEntry) => { const images = feedEntry['description']?.match(/<img [^>]*src="[^"]*"[^>]*>/gm) || [] return { - image: images.length ? images.map((image) => image.replace(/.*src="([^"]*)".*/, '$1'))[0] : '', + image: images.length + ? images.map((image) => image.replace(/.*src="([^"]*)".*/, '$1'))[0] + : '', } }, }).catch((error) => { diff --git a/src/_includes/now.liquid b/src/_includes/now.liquid index 9f60a7fe..97376418 100644 --- a/src/_includes/now.liquid +++ b/src/_includes/now.liquid @@ -101,7 +101,7 @@ layout: main {% endif %} {% if books %} <h2 class="m-0 text-xl font-black leading-tight tracking-normal dark:text-gray-200 md:text-2xl mt-6 mb-4"> - Reading + Reading: books </h2> <div> <ul class="list-inside list-disc pl-5 md:pl-10"> @@ -115,6 +115,22 @@ layout: main </ul> </div> {% endif %} + {% if articles %} + <h2 class="m-0 text-xl font-black leading-tight tracking-normal dark:text-gray-200 md:text-2xl mt-6 mb-4"> + Reading: favorite articles + </h2> + <div> + <ul class="list-inside list-disc pl-5 md:pl-10"> + {% for article in articles | reverse %} + <li class="mt-1.5 mb-2"> + <a href="{{article.content.url}}" title="{{article.content.title | escape}}"> + {{ article.content.title | escape }} by {{ article.content.author.name | escape }} + </a> + </li> + {% endfor %} + </ul> + </div> + {% endif %} {% if movies %} <h2 class="m-0 text-xl font-black leading-tight tracking-normal dark:text-gray-200 md:text-2xl mt-6 mb-4"> Watching: movies