feat: restore pinboard

This commit is contained in:
Cory Dransfeldt 2023-11-09 19:57:27 -08:00
parent 2b675945ba
commit ce1dce2ebd
6 changed files with 23 additions and 101 deletions

View file

@ -1,5 +1,20 @@
const links = require('../_data/json/links.json')
const EleventyFetch = require('@11ty/eleventy-fetch')
module.exports = async function () {
return links.links.reverse()
const API_TOKEN_PINBOARD = process.env.API_TOKEN_PINBOARD
const url = `https://api.pinboard.in/v1/posts/recent?auth_token=${API_TOKEN_PINBOARD}&format=json&tag=share&count=5`
const res = EleventyFetch(url, {
duration: '1h',
type: 'json',
}).catch()
const links = await res
return links['posts'].map((link) => {
return {
title: link['description'],
url: link['href'],
tags: [...new Set(link['tags'].split(' '))],
date: link['time'],
description: link['extended'],
}
})
}