fix: old syndication flow
This commit is contained in:
parent
87fd1f589e
commit
c2289e488d
18 changed files with 12825 additions and 4 deletions
|
@ -12,7 +12,7 @@ import filters from './config/filters/index.js'
|
|||
import { slugifyString } from './config/utils/index.js'
|
||||
import { svgToJpeg } from './config/events/index.js'
|
||||
import { minifyJsComponents } from './config/events/index.js'
|
||||
import { searchIndex, tagList, postStats, tagsSortedByCount, links } from './config/collections/index.js'
|
||||
import { searchIndex, tagList, postStats, tagsSortedByCount, links, tagMap } from './config/collections/index.js'
|
||||
import { img } from './config/shortcodes/index.js'
|
||||
|
||||
// load .env
|
||||
|
@ -90,6 +90,7 @@ export default async function (eleventyConfig) {
|
|||
eleventyConfig.addCollection('postStats', postStats)
|
||||
eleventyConfig.addCollection('tagsSortedByCount', tagsSortedByCount)
|
||||
eleventyConfig.addCollection('links', links)
|
||||
eleventyConfig.addCollection('tagMap', tagMap)
|
||||
|
||||
const md = markdownIt({ html: true, linkify: true })
|
||||
md.use(markdownItAnchor, {
|
||||
|
|
22
.github/workflows/scheduled-post.yaml
vendored
Normal file
22
.github/workflows/scheduled-post.yaml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
name: Scheduled follow feed to Mastodon
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 */2 * * *'
|
||||
jobs:
|
||||
JSONFeed2Mastodon:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Feed to Mastodon
|
||||
uses: nhoizey/github-action-feed-to-mastodon@v2
|
||||
with:
|
||||
feedUrl: "https://coryd.dev/feeds/share-follow.json"
|
||||
mastodonInstance: "https://social.lol"
|
||||
mastodonToken: ${{ secrets.MASTODON_TOKEN }}
|
||||
globalDelayToots: 0
|
||||
- name: Pull any changes from Git
|
||||
run: git pull
|
||||
- name: Commit and push
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
|
@ -1,6 +1,6 @@
|
|||
# coryd.dev
|
||||
|
||||
[](https://app.netlify.com/sites/cdme/deploys) [](https://github.com/cdransf/coryd.dev/actions/workflows/scheduled-build.yaml) [](https://github.com/cdransf/coryd.dev/actions/workflows/scheduled-speedlify-build.yaml)
|
||||
[](https://app.netlify.com/sites/cdme/deploys) [](https://github.com/cdransf/coryd.dev/actions/workflows/scheduled-build.yaml) [](https://github.com/cdransf/coryd.dev/actions/workflows/scheduled-speedlify-build.yaml) [](https://github.com/cdransf/coryd.dev/actions/workflows/scheduled-post.yaml)
|
||||
|
||||
Hi! I'm Cory. 👋🏻
|
||||
|
||||
|
|
3
cache/json-feed-to-mastodon-timestamp.json
vendored
Normal file
3
cache/json-feed-to-mastodon-timestamp.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"timestamp": 1713319829577
|
||||
}
|
12612
cache/json-feed-to-mastodon.json
vendored
Normal file
12612
cache/json-feed-to-mastodon.json
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,6 @@
|
|||
import { DateTime } from 'luxon'
|
||||
import { makeYearStats, processPostFile } from './utils.js'
|
||||
import tagAliases from '../data/tag-aliases.js'
|
||||
|
||||
export const searchIndex = (collection) => {
|
||||
const searchIndex = []
|
||||
|
@ -44,6 +45,23 @@ export const tagList = (collection) => {
|
|||
return Array.from(tagsSet).sort()
|
||||
}
|
||||
|
||||
export const tagMap = (collection) => {
|
||||
const tags = {}
|
||||
const collectionData = collection.getAll()[0]
|
||||
const posts = collectionData.data.collections.posts
|
||||
const links = collectionData.data.links
|
||||
if (posts) {
|
||||
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) => tagAliases[tag.toLowerCase()]))]
|
||||
.join(' ')
|
||||
.trim()
|
||||
if (tagString) tags[url] = tagString.replace(/\s+/g,' ')
|
||||
})
|
||||
}
|
||||
return tags
|
||||
}
|
||||
|
||||
export const tagsSortedByCount = (collection) => {
|
||||
const tagStats = {};
|
||||
collection.getFilteredByGlob('src/posts/**/*.*').forEach((item) => {
|
||||
|
|
42
config/data/tag-aliases.js
Normal file
42
config/data/tag-aliases.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
export default {
|
||||
'11ty': '#Eleventy',
|
||||
accessibility: '#Accessibility',
|
||||
ai: '#AI',
|
||||
'black metal': '#BlackMetal',
|
||||
blogging: '#Blogging',
|
||||
books: '#Books',
|
||||
climate: '#Climate',
|
||||
css: '#CSS',
|
||||
'death metal': '#DeathMetal',
|
||||
development: '#WebDev',
|
||||
economics: '#Economics',
|
||||
eleventy: '#Eleventy',
|
||||
email: '#Email',
|
||||
emo: '#Emo',
|
||||
fastmail: '#Email',
|
||||
gmail: '#Email',
|
||||
grindcore: '#Grindcore',
|
||||
health: '#Health',
|
||||
'indie web': '#IndieWeb #SmallWeb',
|
||||
ios: '#iOS #Apple',
|
||||
javascript: '#JavaScript',
|
||||
'last.fm': '#Music',
|
||||
journalism: '#Journalism',
|
||||
labor: '#Work',
|
||||
lastfm: '#Music',
|
||||
macos: '#macOS #Apple',
|
||||
mastodon: '#Mastodon',
|
||||
music: '#Music',
|
||||
privacy: '#Privacy',
|
||||
productivity: '#Productivity',
|
||||
react: '#JavaScript',
|
||||
rss: '#RSS',
|
||||
shoegaze: '#Shoegaze',
|
||||
'social media': '#SocialMedia',
|
||||
spotify: '#Music',
|
||||
'surveillance capitalism': '#SurveillanceCapitalism',
|
||||
'tattoos': '#Tattoos',
|
||||
tech: '#Tech',
|
||||
technology: '#Tech',
|
||||
'web components': '#WebComponents'
|
||||
}
|
|
@ -60,6 +60,13 @@ export default {
|
|||
return visitors(b) - visitors(a)
|
||||
})
|
||||
},
|
||||
|
||||
tagLookup: (url, tagMap) => {
|
||||
if (!url) return
|
||||
if (url.includes('openlibrary.org')) return '#Books #NowReading'
|
||||
if (url.includes('trakt.tv')) return '#Movies #Watching #Trakt'
|
||||
return tagMap[url] || ''
|
||||
},
|
||||
|
||||
// authors
|
||||
authorLookup: (url) => {
|
||||
|
|
23
src/_data/follow.js
Normal file
23
src/_data/follow.js
Normal 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
8
src/_data/linkPosts.js
Normal 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
|
||||
}
|
24
src/_includes/partials/mastodon-post.liquid
Normal file
24
src/_includes/partials/mastodon-post.liquid
Normal 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 -%}
|
|
@ -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>
|
18
src/assets/styles/components/mastodon-post.css
Normal file
18
src/assets/styles/components/mastodon-post.css
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
12
src/feeds/follow.json.liquid
Normal file
12
src/feeds/follow.json.liquid
Normal 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
18
src/feeds/json.liquid
Normal 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 %}
|
||||
]
|
||||
}
|
13
src/feeds/share.follow.json.liquid
Normal file
13
src/feeds/share.follow.json.liquid
Normal 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
|
||||
%}
|
|
@ -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.
|
||||
|
|
Reference in a new issue