From 9d372b44907c116dc2dbf13c0d9c8a8cc2bb3635 Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Fri, 8 Sep 2023 20:12:07 -0700 Subject: [PATCH] fix: be less clever --- .eleventy.js | 32 +--------------- config/filters.js | 4 +- src/_data/json/tag-aliases.json | 49 ++++++++---------------- src/_includes/partials/feeds/json.liquid | 4 +- src/_includes/partials/now/links.liquid | 3 +- 5 files changed, 22 insertions(+), 70 deletions(-) diff --git a/.eleventy.js b/.eleventy.js index 0348edeb..07cafefd 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -86,20 +86,7 @@ module.exports = function (eleventyConfig) { if (item.data.collections.posts) { item.data.collections.posts.forEach((post) => { const url = post.url.includes('http') ? post.url : `https://coryd.dev${post.url}` - const tagString = [ - ...new Set( - post.data.tags.map((tag) => { - if ( - typeof tagAliases.tags.find((t) => t.aliases.includes(tag.toLowerCase()))?.[ - 'tag' - ] !== 'undefined' - ) - return `#${ - tagAliases.tags.find((t) => t.aliases.includes(tag.toLowerCase()))?.['tag'] - }` - }) - ), - ] + const tagString = [...new Set(post.data.tags.map((tag) => tagAliases[tag]))] .join(' ') .trim() if (tagString) tags[url] = tagString @@ -107,22 +94,7 @@ module.exports = function (eleventyConfig) { } if (item.data.links) { item.data.links.forEach((link) => { - const tagString = [ - ...new Set( - link.tags.map((tag) => { - if ( - typeof tagAliases.tags.find((t) => t.aliases.includes(tag.toLowerCase()))?.[ - 'tag' - ] !== 'undefined' - ) - return `#${ - tagAliases.tags.find((t) => t.aliases.includes(tag.toLowerCase()))?.['tag'] - }` - }) - ), - ] - .join(' ') - .trim() + const tagString = [...new Set(link.tags.map((tag) => tagAliases[tag]))].join(' ').trim() if (tagString) tags[link.url] = tagString }) } diff --git a/config/filters.js b/config/filters.js index 64dff340..7065a18d 100644 --- a/config/filters.js +++ b/config/filters.js @@ -42,9 +42,7 @@ module.exports = { return visitors(b) - visitors(a) }) }, - tagLookup: (url, tagMap) => { - return tagMap[url] - }, + tagLookup: (url, tagMap) => tagMap[url], webmentionsByUrl: (webmentions, url) => { const allowedTypes = ['mention-of', 'in-reply-to', 'like-of', 'repost-of'] diff --git a/src/_data/json/tag-aliases.json b/src/_data/json/tag-aliases.json index 64ab960c..67e04082 100644 --- a/src/_data/json/tag-aliases.json +++ b/src/_data/json/tag-aliases.json @@ -1,36 +1,17 @@ { - "tags": [ - { - "tag": "Eleventy", - "aliases": ["11ty", "eleventy"] - }, - { - "tag": "WebDev", - "aliases": [ - "development", - "webdev", - "web-development", - "web-development", - "jekyll", - "netlify", - "vercel" - ] - }, - { - "tag": "JavaScript", - "aliases": ["javascript", "js", "react", "nextjs", "gatsby", "vue", "svelte", "angular"] - }, - { - "tag": "Tech", - "aliases": ["technology", "tech"] - }, - { - "tag": "Music", - "aliases": ["music", "spotify", "last.fm", "lastfm"] - }, - { - "tag": "Email", - "aliases": ["email", "fastmail", "gmail"] - } - ] + "11ty": "#Eleventy", + "eleventy": "#Eleventy", + "development": "#WebDev", + "javascript": "#JavaScript", + "react": "#JavaScript", + "tech": "#Tech", + "social media": "#Tech", + "technology": "#Tech", + "music": "#Music", + "spotify": "#Music", + "last.fm": "#Music", + "lastfm": "#Music", + "email": "#Email", + "fastmail": "#Email", + "gmail": "#Email" } diff --git a/src/_includes/partials/feeds/json.liquid b/src/_includes/partials/feeds/json.liquid index b75d951b..983deb2c 100644 --- a/src/_includes/partials/feeds/json.liquid +++ b/src/_includes/partials/feeds/json.liquid @@ -8,9 +8,9 @@ "items": [{% for entry in entries limit: 20 -%} { "id": "{{ entry.url | btoa }}", - "title": "{{ entry.title | escape }}{% if tagMap %} {{ entry.url | tagLookup: tagMap }}{% endif %}", + "title": "{{ entry.title | escape }}", "url": "{{ entry.url }}", - "content_text": "{{ entry.title | escape }}{% if tagMap %} {{ entry.url | tagLookup: tagMap }}{% endif %}", + "content_text": "{{ entry.title | escape }}{% if tagMap %} {{ entry.url | tagLookup: tagMap }}{% endif %} {{ entry.url }}", "date_published": "{{ entry.date | stringToDate | dateToRfc822 }}" }{% if not forloop.last %},{% endif %} {%- endfor %} diff --git a/src/_includes/partials/now/links.liquid b/src/_includes/partials/now/links.liquid index e8551e38..8cdc25be 100644 --- a/src/_includes/partials/now/links.liquid +++ b/src/_includes/partials/now/links.liquid @@ -1,10 +1,11 @@ {% if links.size > 0 %} + {% assign data = links | reverse %}

{% tablericon "link" "Links" %}
Links