diff --git a/_posts/2023-11-10-testing-like.md b/_posts/2023-11-10-testing-like.md index 6884369..f5041bd 100644 --- a/_posts/2023-11-10-testing-like.md +++ b/_posts/2023-11-10-testing-like.md @@ -2,5 +2,6 @@ layout: like categories: like title: "" +published: false --- ❤️ https://www.aferrero.boo/why-did-i-do-this/ diff --git a/_posts/2023-11-10-testing-repost.md b/_posts/2023-11-10-testing-repost.md index 964758e..9ff6e6a 100644 --- a/_posts/2023-11-10-testing-repost.md +++ b/_posts/2023-11-10-testing-repost.md @@ -2,5 +2,6 @@ layout: repost categories: repost title: "" +published: false --- 🔁 https://www.aferrero.boo/why-did-i-do-this/ diff --git a/webmentions.js b/webmentions.js deleted file mode 100644 index 2e3d60c..0000000 --- a/webmentions.js +++ /dev/null @@ -1,64 +0,0 @@ -const https = require("https"); -const fs = require("fs") -// Transform webmention slashes with -- -fetchWebmentions().then(webmentions => { - webmentions.forEach(webmention => { - const slug = webmention["wm-target"] - .replace("https://www.aferrero.boo/", "") - .replace(/\/$/, "") - .replace("/", "--"); - - const filename = `${__dirname}/_data/webmentions/${slug}.json`; - - // if file doesn't exist; create it - if (!fs.existsSync(filename)) { - fs.writeFileSync(filename, JSON.stringify([webmention], null, 2)); - return; - } - - // If the file already exists we need to append new webmentions and make sure we didn't add duplicates - const entries = JSON.parse(fs.readFileSync(filename)).filter(wm => wm["wm-id"] !== webmention["wm-id"]).concat([webmention]); - - // Sort to make sure the file is always the same - entries.sort((a, b) => a["wm-id"] - b["wm-id"]); - - // And write the modified file - fs.writeFileSync(filename, JSON.stringify(entries, null, 2)); - }); -}); - -function fetchWebmentions() { - // Catch webmention.io token from GH secret - const token = process.env.WEBMENTIONS_TOKEN; - - // Gather webmentions from the past 3 days - const since = new Date(); - since.setDate(since.getDate() - 60) - - const url = `https://webmention.io/api/mentions.jf2?domain=www.aferrero.boo&token=${token}&since=${since.toISOString()}&per-page=999` - - return new Promise((resolve, reject) => { - https.get(url, res => { - let body = ""; - res.on("data", chunk => { - body += chunk; - }); - - res.on("end", () => { - try { - resolve(JSON.parse(body)); - } catch (error) { - reject(error); - } - }); - }).on("error", error => { - reject(error); - }); - }).then(response => { - if (!("children" in response)) { - throw new Error("Invalid webmention.io response."); - } - - return response.children; - }); -}