feat: map authors to root urls + display them
This commit is contained in:
parent
725408c487
commit
c785c9a5df
5 changed files with 13 additions and 4 deletions
|
@ -3,6 +3,7 @@ import markdownIt from 'markdown-it'
|
||||||
import { URL } from 'url'
|
import { URL } from 'url'
|
||||||
import { createRequire } from 'module'
|
import { createRequire } from 'module'
|
||||||
import sanitizeHtml from 'sanitize-html';
|
import sanitizeHtml from 'sanitize-html';
|
||||||
|
import authors from '../json/author-map.js'
|
||||||
|
|
||||||
const require = createRequire(import.meta.url)
|
const require = createRequire(import.meta.url)
|
||||||
const metaData = require('../../src/_data/json/meta.json')
|
const metaData = require('../../src/_data/json/meta.json')
|
||||||
|
@ -61,7 +62,12 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
// authors
|
// authors
|
||||||
authorLookup: (url, authorMap) => authorMap[url] || '',
|
authorLookup: (url) => {
|
||||||
|
if (!url) return null
|
||||||
|
const urlObject = new URL(url)
|
||||||
|
const baseUrl = urlObject.origin
|
||||||
|
return authors?.[baseUrl] || null
|
||||||
|
},
|
||||||
|
|
||||||
// dates
|
// dates
|
||||||
readableDate: (date) => {
|
readableDate: (date) => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "12.1.9",
|
"version": "12.2.9",
|
||||||
"description": "The source for my personal site. Built using 11ty.",
|
"description": "The source for my personal site. Built using 11ty.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -15,8 +15,9 @@
|
||||||
<height>144</height>
|
<height>144</height>
|
||||||
</image>
|
</image>
|
||||||
{% for entry in entries limit: 20 -%}
|
{% for entry in entries limit: 20 -%}
|
||||||
|
{% assign author = entry.url | stripUtm | authorLookup %}
|
||||||
<item>
|
<item>
|
||||||
<title>{{ entry.title | escape }}</title>
|
<title>{{ entry.title | escape }}{% if author %} via {{ author }}{% endif %}</title>
|
||||||
<link>{{ entry.url | stripUtm | encodeAmp }}</link>
|
<link>{{ entry.url | stripUtm | encodeAmp }}</link>
|
||||||
<pubDate>{{ entry.date | stringToRFC822Date }}</pubDate>
|
<pubDate>{{ entry.date | stringToRFC822Date }}</pubDate>
|
||||||
<guid>{{ entry.url | stripUtm | encodeAmp }}</guid>
|
<guid>{{ entry.url | stripUtm | encodeAmp }}</guid>
|
||||||
|
|
|
@ -7,10 +7,12 @@ pagination:
|
||||||
---
|
---
|
||||||
<ul class="link-list reduced-spacing">
|
<ul class="link-list reduced-spacing">
|
||||||
{% for link in pagination.items %}
|
{% for link in pagination.items %}
|
||||||
|
{% assign author = link.data.link | stripUtm | authorLookup %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ link.data.link }}" title="{{ link.data.title | escape }}">
|
<a href="{{ link.data.link }}" title="{{ link.data.title | escape }}">
|
||||||
{{ link.data.title }}
|
<strong>{{ link.data.title }}</strong>
|
||||||
</a>
|
</a>
|
||||||
|
{% if author %} via {{ author }}{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Reference in a new issue