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) {
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
})
}

View file

@ -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']

View file

@ -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"
}

View file

@ -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 %}

View file

@ -1,10 +1,11 @@
{% 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">
{% tablericon "link" "Links" %}
<div class="ml-1">Links</div>
</h2>
<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">
<a href="{{link.url}}" title="{{link.title | escape}}">
{{ link.title }}