fix: be less clever

This commit is contained in:
Cory Dransfeldt 2023-09-08 20:12:07 -07:00
parent d42ba7439c
commit 9d372b4490
No known key found for this signature in database
5 changed files with 22 additions and 70 deletions

View file

@ -86,20 +86,7 @@ module.exports = function (eleventyConfig) {
if (item.data.collections.posts) { if (item.data.collections.posts) {
item.data.collections.posts.forEach((post) => { item.data.collections.posts.forEach((post) => {
const url = post.url.includes('http') ? post.url : `https://coryd.dev${post.url}` const url = post.url.includes('http') ? post.url : `https://coryd.dev${post.url}`
const tagString = [ const tagString = [...new Set(post.data.tags.map((tag) => tagAliases[tag]))]
...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']
}`
})
),
]
.join(' ') .join(' ')
.trim() .trim()
if (tagString) tags[url] = tagString if (tagString) tags[url] = tagString
@ -107,22 +94,7 @@ module.exports = function (eleventyConfig) {
} }
if (item.data.links) { if (item.data.links) {
item.data.links.forEach((link) => { item.data.links.forEach((link) => {
const tagString = [ const tagString = [...new Set(link.tags.map((tag) => tagAliases[tag]))].join(' ').trim()
...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()
if (tagString) tags[link.url] = tagString if (tagString) tags[link.url] = tagString
}) })
} }

View file

@ -42,9 +42,7 @@ module.exports = {
return visitors(b) - visitors(a) return visitors(b) - visitors(a)
}) })
}, },
tagLookup: (url, tagMap) => { tagLookup: (url, tagMap) => tagMap[url],
return tagMap[url]
},
webmentionsByUrl: (webmentions, url) => { webmentionsByUrl: (webmentions, url) => {
const allowedTypes = ['mention-of', 'in-reply-to', 'like-of', 'repost-of'] const allowedTypes = ['mention-of', 'in-reply-to', 'like-of', 'repost-of']

View file

@ -1,36 +1,17 @@
{ {
"tags": [ "11ty": "#Eleventy",
{ "eleventy": "#Eleventy",
"tag": "Eleventy", "development": "#WebDev",
"aliases": ["11ty", "eleventy"] "javascript": "#JavaScript",
}, "react": "#JavaScript",
{ "tech": "#Tech",
"tag": "WebDev", "social media": "#Tech",
"aliases": [ "technology": "#Tech",
"development", "music": "#Music",
"webdev", "spotify": "#Music",
"web-development", "last.fm": "#Music",
"web-development", "lastfm": "#Music",
"jekyll", "email": "#Email",
"netlify", "fastmail": "#Email",
"vercel" "gmail": "#Email"
]
},
{
"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"]
}
]
} }

View file

@ -8,9 +8,9 @@
"items": [{% for entry in entries limit: 20 -%} "items": [{% for entry in entries limit: 20 -%}
{ {
"id": "{{ entry.url | btoa }}", "id": "{{ entry.url | btoa }}",
"title": "{{ entry.title | escape }}{% if tagMap %} {{ entry.url | tagLookup: tagMap }}{% endif %}", "title": "{{ entry.title | escape }}",
"url": "{{ entry.url }}", "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 }}" "date_published": "{{ entry.date | stringToDate | dateToRfc822 }}"
}{% if not forloop.last %},{% endif %} }{% if not forloop.last %},{% endif %}
{%- endfor %} {%- endfor %}

View file

@ -1,10 +1,11 @@
{% if links.size > 0 %} {% if links.size > 0 %}
{% assign data = links | reverse %}
<h2 class="icon--bold m-0 text-xl flex flex-row items-center font-black leading-tight tracking-normal dark:text-gray-200 md:text-2xl mt-8 mb-4 icon--28"> <h2 class="icon--bold m-0 text-xl flex flex-row items-center font-black leading-tight tracking-normal dark:text-gray-200 md:text-2xl mt-8 mb-4 icon--28">
{% tablericon "link" "Links" %} {% tablericon "link" "Links" %}
<div class="ml-1">Links</div> <div class="ml-1">Links</div>
</h2> </h2>
<ul class="list-inside list-disc pl-5 md:pl-10"> <ul class="list-inside list-disc pl-5 md:pl-10">
{% for link in links limit: 5 %} {% for link in data limit: 5 %}
<li class="mt-1.5 mb-2"> <li class="mt-1.5 mb-2">
<a href="{{link.url}}" title="{{link.title | escape}}"> <a href="{{link.url}}" title="{{link.title | escape}}">
{{ link.title }} {{ link.title }}