feature: add favorite articles to now page

This commit is contained in:
Cory Dransfeldt 2023-05-05 09:25:17 -07:00
parent 28f8330579
commit 059ec28b00
No known key found for this signature in database
4 changed files with 37 additions and 3 deletions

15
src/_data/articles.js Normal file
View file

@ -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
}