This repository has been archived on 2025-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
coryd.dev-eleventy/src/_data/links.js
2023-09-08 20:32:00 -07:00

27 lines
943 B
JavaScript

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 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'])
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']),
}
})
}