From fdcdb2e0cec4bc689060efb82ad5c566b94931f5 Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Sat, 10 Feb 2024 20:23:04 -0800 Subject: [PATCH] chore: drop webmentions --- .env | 1 - config/filters/index.js | 64 ----------- config/shortcodes/index.js | 11 +- package.json | 2 +- src/_data/webmentions.js | 20 ---- .../partials/webmentions/comments.liquid | 24 ---- .../partials/webmentions/container.liquid | 13 --- .../partials/webmentions/interaction.liquid | 21 ---- .../partials/webmentions/links.liquid | 12 -- src/_includes/post.liquid | 1 - src/assets/styles/widgets/webmentions.css | 105 ------------------ 11 files changed, 2 insertions(+), 272 deletions(-) delete mode 100644 src/_data/webmentions.js delete mode 100644 src/_includes/partials/webmentions/comments.liquid delete mode 100644 src/_includes/partials/webmentions/container.liquid delete mode 100644 src/_includes/partials/webmentions/interaction.liquid delete mode 100644 src/_includes/partials/webmentions/links.liquid delete mode 100644 src/assets/styles/widgets/webmentions.css diff --git a/.env b/.env index 5a1627bb..8a9e0f8d 100644 --- a/.env +++ b/.env @@ -2,7 +2,6 @@ API_KEY_LASTFM= API_KEY_PLAUSIBLE= API_KEY_TRAKT= API_KEY_MOVIEDB= -API_KEY_WEBMENTIONS_CORYD_DEV= API_TOKEN_READWISE= SECRET_FEED_ALBUM_RELEASES= COOKIE_STORYGRAPH= diff --git a/config/filters/index.js b/config/filters/index.js index c95bb1aa..c4559d5f 100644 --- a/config/filters/index.js +++ b/config/filters/index.js @@ -56,70 +56,6 @@ export default { return tagMap[url] || '' }, - // webmentions - webmentionsByUrl: (webmentions, url) => { - if (!webmentions) return null; - - const allowedTypes = ['mention-of', 'in-reply-to', 'like-of', 'repost-of'] - const data = { - 'like-of': [], - 'repost-of': [], - 'in-reply-to': [], - 'mention-of': [], - 'link-to': [], - } - - const hasRequiredReplyFields = (entry) => { - const { author, published, content } = entry - return author.name && author.photo && published && content - } - - const hasRequiredMentionFields = (entry) => { - const { name, url } = entry - return name && url - } - - const filtered = - webmentions - .filter((entry) => entry['wm-target'] === `${BASE_URL}${url}`) - .filter((entry) => allowedTypes.includes(entry['wm-property'])) || [] - - filtered.forEach((m) => { - if (data[m['wm-property']]) { - const isReply = m['wm-property'] === 'in-reply-to' - const isMention = m['wm-property'] === 'mention-of' - const isValidReply = (isReply || isMention) && hasRequiredReplyFields(m) - if (isReply || isMention) { - if (isValidReply) { - m.sanitized = sanitizeHTML(m.content.html) - data[m['wm-property']].unshift(m) - } - - if (isMention && hasRequiredMentionFields(m)) data['link-to'].push(m) - return - } - data[m['wm-property']].unshift(m) - } - }) - - 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 - ) - - // delete empty keys - Object.keys(data).forEach((key) => { - if (data[key].length === 0) delete data[key] - }); - - if (!Object.keys(data).length) return null; - - return data - }, - webmentionsSanitizeComments: (comment) => { - return comment.replace(/\?\?\?\?/g, ''); - }, - // dates readableDate: (date) => { return DateTime.fromISO(date).toFormat('LLLL d, yyyy') diff --git a/config/shortcodes/index.js b/config/shortcodes/index.js index f6df5b28..f3778ea3 100644 --- a/config/shortcodes/index.js +++ b/config/shortcodes/index.js @@ -18,15 +18,6 @@ export const img = async ( sizes = '90vw', formats = ['avif', 'webp', 'jpeg'] ) => { - const isLocal = src?.includes('src/assets'); - const imageExists = async () => { - try { - return await fetch(src, { method: 'HEAD' }).then((res) => res.ok); - } catch { - return false; - } - }; - const generateImage = async () => { const widths = [320, 570, 880, 1024, 1248]; const metadata = await Image(src, { @@ -70,7 +61,7 @@ export const img = async ( }; if (process.env.ELEVENTY_PRODUCTION) { - return isLocal ? await generateImage() : await imageExists().then(async (exists) => (exists ? await generateImage() : await generatePlaceholder())); + return await generateImage(); } else { return await generatePlaceholder(); } diff --git a/package.json b/package.json index ca0a4d41..d1a4b316 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "5.5.0", + "version": "5.6.0", "description": "The source for my personal site. Built using 11ty and hosted on Netlify.", "type": "module", "scripts": { diff --git a/src/_data/webmentions.js b/src/_data/webmentions.js deleted file mode 100644 index d759b820..00000000 --- a/src/_data/webmentions.js +++ /dev/null @@ -1,20 +0,0 @@ -import EleventyFetch from '@11ty/eleventy-fetch' - -export default async function () { - const KEY_CORYD = process.env.API_KEY_WEBMENTIONS_CORYD_DEV - const url = `https://webmention.io/api/mentions.jf2?token=${KEY_CORYD}&per-page=1000` - if (process.env.ELEVENTY_PRODUCTION) { - const res = EleventyFetch(url, { - duration: '1h', - type: 'json', - }).catch() - const webmentions = await res - return { - mentions: webmentions['children'], - } - } else { - return { - mentions: [] - } - } -} diff --git a/src/_includes/partials/webmentions/comments.liquid b/src/_includes/partials/webmentions/comments.liquid deleted file mode 100644 index 5c76ab51..00000000 --- a/src/_includes/partials/webmentions/comments.liquid +++ /dev/null @@ -1,24 +0,0 @@ -{% if mentions['in-reply-to'].size > 0 %} -

Comments

-
- {% for mention in mentions['in-reply-to'] %} - - {% endfor %} -
-{% endif %} \ No newline at end of file diff --git a/src/_includes/partials/webmentions/container.liquid b/src/_includes/partials/webmentions/container.liquid deleted file mode 100644 index bc01fac9..00000000 --- a/src/_includes/partials/webmentions/container.liquid +++ /dev/null @@ -1,13 +0,0 @@ -{% assign mentions = webmentions.mentions | webmentionsByUrl: page.url %} -{% if mentions %} - {% capture css %} - {% render "../../../assets/styles/widgets/webmentions.css" %} - {% endcapture %} - -
- {% render "partials/webmentions/interaction.liquid", mentions: mentions, type: 'repost-of' %} - {% render "partials/webmentions/interaction.liquid", mentions: mentions, type: 'like-of' %} - {% render "partials/webmentions/comments.liquid", mentions: mentions %} - {% render "partials/webmentions/links.liquid", mentions: mentions %} -
-{% endif %} \ No newline at end of file diff --git a/src/_includes/partials/webmentions/interaction.liquid b/src/_includes/partials/webmentions/interaction.liquid deleted file mode 100644 index fff52b47..00000000 --- a/src/_includes/partials/webmentions/interaction.liquid +++ /dev/null @@ -1,21 +0,0 @@ -{%- capture title %} - {% if type == 'repost-of' %} - Reposts - {% elsif type == 'like-of' %} - Likes - {% endif %} -{% endcapture -%} -{% if mentions[type].size > 0 %} -

{{ title }}

-
- {% for mention in mentions[type] %} - -
- {% capture authorAlt %}{{ mention.author.name | escape }}{% endcapture %} - {% capture fallbackIcon %}{% tablericon "user" authorAlt %}{% endcapture %} - {% image mention.author.photo, authorAlt, 'avatar__image', 'lazy', 'square', fallbackIcon %} -
-
- {% endfor %} -
-{% endif %} \ No newline at end of file diff --git a/src/_includes/partials/webmentions/links.liquid b/src/_includes/partials/webmentions/links.liquid deleted file mode 100644 index d7987eb8..00000000 --- a/src/_includes/partials/webmentions/links.liquid +++ /dev/null @@ -1,12 +0,0 @@ -{% if mentions['link-to'].size > 0 %} -

Links

- -{% endif %} \ No newline at end of file diff --git a/src/_includes/post.liquid b/src/_includes/post.liquid index a42089be..a0e34290 100644 --- a/src/_includes/post.liquid +++ b/src/_includes/post.liquid @@ -30,5 +30,4 @@ schema: blog {% render "partials/post-tags.liquid", tags: tags %} -{% render "partials/webmentions/container.liquid", webmentions: webmentions, page: page %} {% render "partials/popular-posts.liquid", posts: collections.posts, analytics: analytics %} \ No newline at end of file diff --git a/src/assets/styles/widgets/webmentions.css b/src/assets/styles/widgets/webmentions.css deleted file mode 100644 index 1c46f015..00000000 --- a/src/assets/styles/widgets/webmentions.css +++ /dev/null @@ -1,105 +0,0 @@ -.webmentions { - border-top: 1px solid var(--gray-light); - border-bottom: 1px solid var(--gray-light); - margin-top: 1.5rem; - margin-bottom: 2.5rem; - padding-top: 1rem; - padding-bottom: 2.5rem; -} - -.webmentions h2:not(:first-child) { - margin-top: 2rem; -} - -.webmentions .interaction { - cursor: pointer; - margin-top: 1rem; - margin-bottom: 1.5rem; -} - -.webmentions .interaction .comment__wrapper { - width: 100%; - padding-bottom: 1rem; -} - -.webmentions .interaction .comment__wrapper:last-child { - padding-bottom: 0; -} - -.webmentions .interaction .avatar__wrapper:hover, -.webmentions .interaction .avatar__wrapper:focus, -.webmentions .interaction .avatar__wrapper:active, -.webmentions .interaction .comment__wrapper:hover .avatar__wrapper, -.webmentions .interaction .comment__wrapper:focus .avatar__wrapper -.webmentions .interaction .comment__wrapper:active .avatar__wrapper { - border-color: var(--accent-color-hover); -} - -.webmentions .interaction .comment__wrapper--interior { - justify-content: space-between; -} - -.webmentions .interaction .comment__wrapper--interior .comment { - margin-left: .75rem; -} - -.webmentions .interaction .comment__wrapper--interior .comment a { - color: var(--text-color); - text-decoration: none; -} - -.webmentions .interaction .comment__wrapper--interior .comment p { - font-size: var(--font-size-sm); - line-height: var(--line-height-sm); - margin: 0; - word-break: break-word; -} - -.webmentions .interaction .comment__wrapper--interior .comment time { - font-size: var(--font-size-xs); - line-height: var(--line-height-xs); - margin-top: .25rem; -} - -.webmentions .interaction { - display: flex; - flex-direction: row; - flex-wrap: wrap; - margin: 0 0 0 .75rem; - padding: 0; -} - -.webmentions .interaction.comments { - flex-direction: column; - margin: 0; -} - -.webmentions .interaction > a { - margin-left: -.75rem; - height: 3.5rem; -} - -.webmentions .interaction .avatar__wrapper { - border: 4px solid var(--background-color); - background-color: var(--background-color-inverted); - width: 3.5rem; - height: 3.5rem; - margin-bottom: 0; - overflow: hidden; - border-radius: var(--rounded-full); - transition-property: border-color; - transition-timing-function: var(--transition-ease-in-out); - transition-duration: var(--transition-duration-default); -} - -.webmentions .interaction .avatar__wrapper img { - width: 100%; - height: 100%; - border-radius: var(--rounded-full); -} - -.webmentions .interaction .avatar__wrapper > picture { - display: flex; - flex-direction: column; - align-items: center; -} \ No newline at end of file