From 23427e253b67809c110ba79d54d534bdbe31f63b Mon Sep 17 00:00:00 2001
From: Cory Dransfeldt <hi@coryd.dev>
Date: Sun, 5 Nov 2023 17:42:55 -0800
Subject: [PATCH] chore: pinboard for links

---
 .eleventy.js              |  5 ++---
 .env                      |  1 +
 src/_data/json/links.json |  1 -
 src/_data/links.js        | 19 +++++++++++++++++--
 src/_data/nav.js          |  1 +
 src/uses.md               |  1 +
 6 files changed, 22 insertions(+), 6 deletions(-)
 delete mode 100644 src/_data/json/links.json

diff --git a/.eleventy.js b/.eleventy.js
index 07888987..8b66b736 100644
--- a/.eleventy.js
+++ b/.eleventy.js
@@ -160,9 +160,8 @@ module.exports = function (eleventyConfig) {
       }
       if (item.data.links) {
         item.data.links.forEach((link) => {
-          const tagString = [
-            ...new Set(link.tags.split(',').map((tag) => tagAliases[tag.toLowerCase()])),
-          ]
+          const tagString = link['tags']
+            .map((tag) => tagAliases[tag.toLowerCase()])
             .join(' ')
             .trim()
           if (tagString) tags[link.url] = tagString
diff --git a/.env b/.env
index e50b0ed4..3541d8d0 100644
--- a/.env
+++ b/.env
@@ -1,6 +1,7 @@
 API_KEY_TRAKT=
 API_KEY_MOVIEDB=
 API_KEY_WEBMENTIONS_CORYD_DEV=
+API_TOKEN_PINBOARD=
 API_APPLE_MUSIC_DEVELOPER_TOKEN=
 API_APPLE_MUSIC_USER_TOKEN=
 APPLE_RENEW_TOKEN_URL=
diff --git a/src/_data/json/links.json b/src/_data/json/links.json
deleted file mode 100644
index fc177b44..00000000
--- a/src/_data/json/links.json
+++ /dev/null
@@ -1 +0,0 @@
-{"links":[{"tags":"development","title":"What Happened to Separation of Concerns in Frontend Development","id":"https:\/\/meiert.com\/en\/blog\/what-happened-to-separation-of-concerns\/","url":"https:\/\/meiert.com\/en\/blog\/what-happened-to-separation-of-concerns\/","date":"Tue, 31 Oct 2023 10:25:06 -0700"},{"tags":"development","title":"It&#39;s 2023, here is why your web design sucks.","id":"https:\/\/heather-buchel.com\/blog\/2023\/10\/why-your-web-design-sucks\/","url":"https:\/\/heather-buchel.com\/blog\/2023\/10\/why-your-web-design-sucks\/","date":"Tue, 31 Oct 2023 10:27:36 -0700"},{"tags":"music","title":"You should look at this chart about music genres","id":"https:\/\/pudding.cool\/2023\/10\/genre\/","url":"https:\/\/pudding.cool\/2023\/10\/genre\/","date":"Tue, 31 Oct 2023 11:02:55 -0700"},{"tags":"development","title":"The Fight For The Main Thread","id":"https:\/\/www.smashingmagazine.com\/2023\/10\/speedcurve-fight-main-thread\/","url":"https:\/\/www.smashingmagazine.com\/2023\/10\/speedcurve-fight-main-thread\/","date":"Tue, 31 Oct 2023 11:04:41 -0700"},{"tags":"development","title":"Why I Won&#x27;t Use Next.js","id":"https:\/\/www.epicweb.dev\/why-i-wont-use-nextjs","url":"https:\/\/www.epicweb.dev\/why-i-wont-use-nextjs","date":"Tue, 31 Oct 2023 11:18:47 -0700"},{"tags":"development","title":"The ideal viewport doesn’t exist","id":"https:\/\/viewports.fyi\/","url":"https:\/\/viewports.fyi\/","date":"Tue, 31 Oct 2023 12:40:05 -0700"},{"tags":"development","title":"Software disenchantment","id":"https:\/\/tonsky.me\/blog\/disenchantment\/","url":"https:\/\/tonsky.me\/blog\/disenchantment\/","date":"Tue, 31 Oct 2023 18:53:38 -0700"},{"tags":"development","title":"Second-guessing the modern web","id":"https:\/\/macwright.com\/2020\/05\/10\/spa-fatigue.html","url":"https:\/\/macwright.com\/2020\/05\/10\/spa-fatigue.html","date":"Thu, 02 Nov 2023 08:55:58 -0700"},{"tags":"development","title":"Presentational shadow DOM","id":"https:\/\/www.mayank.co\/blog\/presentational-shadow-dom\/","url":"https:\/\/www.mayank.co\/blog\/presentational-shadow-dom\/","date":"Fri, 03 Nov 2023 12:40:07 -0700"}]}
\ No newline at end of file
diff --git a/src/_data/links.js b/src/_data/links.js
index 3a83eaf5..4027e6aa 100644
--- a/src/_data/links.js
+++ b/src/_data/links.js
@@ -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'],
+    }
+  })
 }
diff --git a/src/_data/nav.js b/src/_data/nav.js
index d94c382c..b6000532 100644
--- a/src/_data/nav.js
+++ b/src/_data/nav.js
@@ -21,6 +21,7 @@ module.exports = async function () {
       },
       { name: 'Trakt', url: 'https://trakt.tv/users/cdransf', icon: 'device-tv' },
       { name: 'StoryGraph', url: 'https://app.thestorygraph.com/profile/coryd', icon: 'books' },
+      { name: 'Pinboard', url: 'http://pinboard.in/u:cdme', icon: 'pin' },
       { name: 'Buy Me a Coffee', url: 'https://www.buymeacoffee.com/cory', icon: 'cup' },
     ],
     resume: [
diff --git a/src/uses.md b/src/uses.md
index d63ef8c9..a001e743 100644
--- a/src/uses.md
+++ b/src/uses.md
@@ -79,6 +79,7 @@ Software and services that I use for work and my own enjoyment.
 - <a onclick="clicky.goal('Referral: Bunny.net')" href="https://bunny.net?ref=revw3mehej">Bunny.net</a>: a powerful and affordable CDN. I use it to serve assets on my personal site (most notable my now page — raw assets are fetched by Eleventy and then optimized to webp).
 - <a onclick="clicky.goal('Referral: Clicky')" href="https://clicky.com/101424044">Clicky</a>: powerful and easy to understand analytics (if, perhaps, not the prettiest to look at).
 - <a onclick="clicky.goal('Referral: Feedpress')" href="https://feedpress.com/?affid=34370">Feedpress</a>: they've been around for a while now and don't change much (nor do they need to), but look no further for reliable, helpful feed analytics.
+- [Pinboard](https://pinboard.in): an old, reliable and slow to change web service that does exactly what it sets out to — provide reliable bookmarking.
 - [SavvyCal](https://savvycal.com): the most pleasant scheduling solution I've found to date. It offers a number of scheduling niceties and allows visitors to overlay their own calendars for a seamless booking experience.
 - [IVPN](https://www.ivpn.net): my VPN of choice for browsing outside of my home network. Privacy-focused and trustworthy.
 - [Kagi](https://kagi.com): search that's actually helpful and ad-free. It's lenses feature and the ability to up/downvote and block results from different sites are indispensable.