From b1fab2efbfaba5a7ba0bc120e3340dcc6b0a22ab Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Wed, 6 Sep 2023 21:02:24 -0700 Subject: [PATCH] chore: webmention fixes --- config/filters.js | 8 +++++++- .../partials/webmentions/comments.liquid | 3 ++- src/assets/img/media/missing-user.jpg | Bin 0 -> 4271 bytes 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 src/assets/img/media/missing-user.jpg diff --git a/config/filters.js b/config/filters.js index ed558cb1..c584164d 100644 --- a/config/filters.js +++ b/config/filters.js @@ -29,6 +29,10 @@ module.exports = { if (image && image !== '') return image return `${BASE_URL}/assets/img/social-card.jpg` }, + getUserImage: (image) => { + if (image && image !== '') return image + return `http://localhost:8080/assets/img/media/missing-user.jpg` + }, getPopularPosts: (posts, analytics) => { return posts .filter((post) => { @@ -46,6 +50,7 @@ module.exports = { 'like-of': [], 'repost-of': [], 'in-reply-to': [], + 'mention-of': [], } const hasRequiredFields = (entry) => { @@ -55,7 +60,7 @@ module.exports = { const filtered = webmentions - .filter((entry) => entry['wm-target'].replace(utmPattern, '') === `${BASE_URL}${url}`) + .filter((entry) => entry['wm-target'] === `${BASE_URL}${url}`) .filter((entry) => allowedTypes.includes(entry['wm-property'])) || [] filtered.forEach((m) => { @@ -74,6 +79,7 @@ module.exports = { } }) + // data['in-reply-to'] = [...data['in-reply-to'], ...data['mention-of']] data['in-reply-to'].sort((a, b) => a.published > b.published ? 1 : b.published > a.published ? -1 : 0 ) diff --git a/src/_includes/partials/webmentions/comments.liquid b/src/_includes/partials/webmentions/comments.liquid index 9768bee3..935fa09f 100644 --- a/src/_includes/partials/webmentions/comments.liquid +++ b/src/_includes/partials/webmentions/comments.liquid @@ -4,7 +4,8 @@ {% for mention in mentions['in-reply-to'] %}
- {% image mention.author.photo, mention.author.name, 'bg-gray-900 dark:bg-white h-14 w-14 rounded-full border-4 border-white dark:border-gray-900 transition-all ease-in-out duration-300 group-hover:border-pink-500 dark:group-hover:border-pink-500', '56px' %} + {% assign photo = mention.author.photo | getUserImage %} + {% image photo, mention.author.name, 'bg-gray-900 dark:bg-white h-14 w-14 rounded-full border-4 border-white dark:border-gray-900 transition-all ease-in-out duration-300 group-hover:border-pink-500 dark:group-hover:border-pink-500', '56px' %}

{{ mention.content.text }}

{{ mention.published | isoDateOnly }}

diff --git a/src/assets/img/media/missing-user.jpg b/src/assets/img/media/missing-user.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7090ec3d41d1a53d7054ec7815fad17dac504dc5 GIT binary patch literal 4271 zcmbtWcQ{;I*FQ7EXd!xua<%XpArE*4gLmb=E%n`JKJ?@7cez$+Ja(UP~RN4uC)a03tbX zHUm5Ypd_P!QczM-P}7k7BHe`xbQf9a8A#5`&%(h%y7+kndALXo2@?{6Ar;_Ka0P8u zRc#9si+}(k=>I#x**k!N5_AQ01p?v+zziS=1L&+B;5vs$eh&2?qkxc+Ln%SvvuS|x zcVbQPpXC4TR5fkC)Vg#U6+%itXW(lp-QRg~NPSn&LgjGX=LR8;q`=}^_=+mw>v)5s z&k3vQA^GXh7(ZP-?a1YmYUE1Wvpo(LWx1;{BPj7OvTfYb&4C;apHx4oJ5G*o%dZG-(vn$6f8 zRStYus;~tBmW`*?fQZr$O#slYl^T&8-EN!hi)*Mj9;E{S`v)ppZQ1TQJn#2R6(6+% zR6022-9?Z=fyczJ4pjgo>n3hp12753Y+PUm!1&pWvPB?iO+)TeFhI58;ZYR~#wKy? zR04o-W>0SmKxK~cY-t35WIM5-%m9G1dE;LH1OQyDct+&}TsTN3{rG=33Q|=$Np%B5 z{#RAWp&$qa+3%u)>Hq!|Y8Qx}2LQJ>y#XgiC4K-~D&d0H!Frq-AUzI4gr1}UpsW&f zIoszUfPCFLjQa+@0ILZ7`HMI>?vxS?^i`G0wE`DQ#E5C~0LmiJib;70bT}G-c_Yh* zkIn^dd(l~~($KCXZGmn+SUsY0ee%A!RcPl<73lKtOP^rcX~nsMzo3vXU;2&tZ)E3B zGIB5k3i@j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