fix: old syndication flow

This commit is contained in:
Cory Dransfeldt 2024-04-20 10:46:18 -07:00
parent 87fd1f589e
commit c2289e488d
18 changed files with 12825 additions and 4 deletions

23
src/_data/follow.js Normal file
View file

@ -0,0 +1,23 @@
export default async function () {
const { ActivityFeed } = await import('@11ty/eleventy-activity-feed')
const feed = new ActivityFeed()
feed.addSource('rss', '📝', 'https://coryd.dev/feeds/posts')
feed.addSource('rss', '🎥', 'https://coryd.dev/feeds/movies')
feed.addSource('rss', '📖', 'https://coryd.dev/feeds/books')
feed.addSource('rss', '🔗', 'https://coryd.dev/feeds/links')
feed.addSource('rss', '🎧', 'https://coryd.dev/feeds/weekly-artist-chart')
const entries = feed.getEntries().catch()
const res = await entries
const activity = { posts: [] }
res.forEach((entry) => {
activity.posts.push({
id: entry.url,
title: entry.title,
url: entry.url,
description: entry.content,
content_html: entry.content,
date_published: entry.published,
})
})
return activity
}

8
src/_data/linkPosts.js Normal file
View file

@ -0,0 +1,8 @@
import { createRequire } from 'module'
const require = createRequire(import.meta.url)
const mastodonCache = require('../../cache/jsonfeed-to-mastodon.json')
export default async function () {
return mastodonCache
}

View file

@ -0,0 +1,24 @@
{%- assign shareLink = postUrl | findPost: linkPosts -%}
{%- if shareLink %}
<script type="module" src="/assets/scripts/components/mastodon-post.js"></script>
<template id="mastodon-post-template">
<div class="mastodon-post-wrapper">
<blockquote data-key="content"></blockquote>
<dl>
<dt>{% tablericon "refresh" "Reposts" %}</dt>
<dd data-key="reblogs_count"></dd>
<dt>{% tablericon "message-circle" "Replies" %}</dt>
<dd data-key="replies_count"></dd>
<dt>{% tablericon "star" "Favorites" %}</dt>
<dd data-key="favourites_count"></dd>
</dl>
</div>
</template>
<span class="client-side">
<mastodon-post>
<a href="{{ shareLink }}">
Discuss on Mastodon
</a>
</mastodon-post>
</span>
{% endif -%}

View file

@ -1,4 +1,4 @@
<script type="module" src="/assets/scripts/components/webcare-webshare.js"></script>
<webcare-webshare share-text="{{ title }} {{ url }}" share-url="{{ url }}" copy-text="{{ title }} {{ url }} {{ url }}">
<webcare-webshare share-text="{{ title }} {{ url | tagLookup: tagMap }}" share-url="{{ url }}" copy-text="{{ title }} {{ url | tagLookup: tagMap }} {{ url }}">
<button class="share icon-small icon-center-vertical" disabled>{% tablericon "share" "Share" %}</button>
</webcare-webshare>

View file

@ -0,0 +1,18 @@
.mastodon-post-wrapper {
border-bottom: 1px solid var(--gray-light);
margin-bottom: var(--sizing-base);
padding-bottom: var(--sizing-base);
& dl {
display: flex;
flex-direction: row;
}
& dd {
margin-left: var(--sizing-xs);
&:not(:last-child) {
margin-right: var(--sizing-lg);
}
}
}

View file

@ -30,6 +30,7 @@
@import url('./components/buttons.css') layer(components);
@import url('./components/forms.css') layer(components);
@import url('./components/link-peek.css') layer(components);
@import url('./components/mastodon-post.css') layer(components);
@import url('./components/media-grid.css') layer(components);
@import url('./components/paginator.css') layer(components);
@import url('./components/post-graph.css') layer(components);

View file

@ -0,0 +1,12 @@
---
layout: null
eleventyExcludeFromCollections: true
permalink: /feeds/follow.json
---
{% render "partials/feeds/json.liquid"
permalink:'/feeds/follow'
title:'Follow • Cory Dransfeldt'
data:follow.posts
updated:follow.posts[0].date_published
site:site
%}

18
src/feeds/json.liquid Normal file
View file

@ -0,0 +1,18 @@
{%- assign entries = data | normalizeEntries -%}
{
"version": "https://jsonfeed.org/version/1",
"title": "{{ title }}",
"icon": "https://coryd.dev/assets/img/avatar.png",
"home_page_url": "{{ meta.url }}",
"feed_url": "{{ permalink | absoluteUrl: meta.url }}",
"items": [{% for entry in entries limit: 20 -%}
{
"id": "{{ entry.url | btoa }}",
"title": "{{ entry.title | replaceQuotes }}",
"url": "{{ entry.url }}",
"content_text": "{{ entry.title | replaceQuotes }}{% if tagMap %} {{ entry.url | tagLookup: tagMap }}{% endif %} {{ entry.url }}",
"date_published": "{{ entry.date | stringToRFC822Date }}"
}{% if not forloop.last %},{% endif %}
{%- endfor %}
]
}

View file

@ -0,0 +1,13 @@
---
layout: null
eleventyExcludeFromCollections: true
permalink: /feeds/share-follow.json
---
{% render "partials/feeds/json.liquid"
permalink:'/feeds/share-follow.json'
title:'Follow • Cory Dransfeldt'
data:follow.posts
updated:follow.posts[0].date_published
site:site
tagMap:collections.tagMap
%}

View file

@ -67,7 +67,6 @@ Software and services that I use for work and my own enjoyment.
- [Netlify](https://netlify.com): I use their hosting, forms and webhooks. It's a reliable and feature-rich platform.
- <a onclick="clicky?.log('/uses', 'Clicky referral', 'click')" href="https://clicky.com/101449513">Clicky</a>: not the *prettiest* analytics, but very feature rich.
- <a onclick="clicky?.log('/uses','Feedpress referral', 'click')" href="https://feedpress.com/?affid=34370">Feedpress</a>: they've been around for a while now and don't change much (nor do they need to), but look no further for reliable, helpful feed analytics.
- [EchoFeed](https://echofeed.app): [Robb Knight](https://rknight.me)'s beautifully designed and easy to use content syndication service — it makes the [POSSE](https://indieweb.org/POSSE) concept effortless to put into practice.
- [Feedbin](https://feedbin.com): performant, open and super reliable RSS.
- [Instapaper](https://instapaper.com): slow to change and often better for it — a reliable and steady read it later service.
- [forwardemail.net](https://forwardemail.net): a simple and reliable service for forwarding and routing emails from a few of the domains I own.