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

View file

@ -2,6 +2,7 @@ module.exports = async function () {
const { ActivityFeed } = await import('@11ty/eleventy-activity-feed')
const feed = new ActivityFeed()
feed.addSource('atom', '📝', 'https://coryd.dev/feed.xml')
// feed.addSource('atom', '🔗', 'https://coryd.dev/links.xml')
feed.addSource('rss', '🎥', 'https://letterboxd.com/cdme/rss')
feed.addSource('rss', '📖', 'https://oku.club/rss/collection/NvEmF')
const entries = feed.getEntries().catch()

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
}