feat: restore link sharing

This commit is contained in:
Cory Dransfeldt 2023-06-04 13:44:47 -07:00
parent d15d4e00ab
commit 112c0d4306
No known key found for this signature in database
11 changed files with 217 additions and 15 deletions

24
src/_data/links.js Normal file
View file

@ -0,0 +1,24 @@
const { extract } = require('@extractus/feed-extractor')
const { AssetCache } = 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'] || '',
}
},
})
.catch((error) => {
console.log(error.message)
})
.catch()
const data = res.entries
const links = data.splice(0, 5)
await asset.save(links, 'json')
return links
}