Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/syndicate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Syndicate new posts

on:
push:
branches: [main]
paths:
- 'src/content/posts/**'

jobs:
syndicate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Find newly added posts
id: new-posts
run: |
NEW=$(git diff --name-only --diff-filter=A HEAD~1 HEAD -- 'src/content/posts/')
echo "new_posts<<EOF" >> $GITHUB_OUTPUT
echo "$NEW" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Wait for Netlify deploy
if: steps.new-posts.outputs.new_posts != ''
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
run: |
echo "Polling Netlify for deploy completion..."
for i in $(seq 1 30); do
STATE=$(curl -sf \
-H "Authorization: Bearer $NETLIFY_AUTH_TOKEN" \
"https://api.netlify.com/api/v1/sites/$NETLIFY_SITE_ID/deploys?per_page=1" \
| python3 -c "import sys,json; print(json.load(sys.stdin)[0]['state'])")
echo " Attempt $i: $STATE"
[ "$STATE" = "ready" ] && break
sleep 20
done
[ "$STATE" != "ready" ] && echo "::warning::Deploy did not reach ready state; webmentions may fail."

- name: Send webmentions to Bridgy
if: steps.new-posts.outputs.new_posts != ''
run: |
while IFS= read -r file; do
[ -z "$file" ] && continue
slug=$(basename "${file%.mdx}")
slug=$(basename "${slug%.md}")
source="https://danmatthew.co.uk/notes/${slug}/"
echo "Syndicating $source"

for target in \
"https://brid.gy/publish/mastodon" \
"https://brid.gy/publish/bluesky"; do
status=$(curl -s -o /dev/null -w "%{http_code}" \
-d "source=${source}&target=${target}" \
https://brid.gy/publish/webmention)
echo " $target → HTTP $status"
done
done <<< "${{ steps.new-posts.outputs.new_posts }}"
3 changes: 3 additions & 0 deletions src/layouts/BaseLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ const { title, description, modifier } = Astro.props;
<meta name="theme-color" content="hsl(0, 0%, 99%)" />
<link rel="alternate" type="application/rss+xml" title="Dan Matthew" href="/feed.xml" />
<link rel="alternate" type="application/feed+json" title="Dan Matthew" href="/feed.json" />
<link rel="webmention" href="https://webmention.io/danmatthew.co.uk/webmention" />
<link rel="me" href="https://front-end.social/@danielm" />
<link rel="me" href="https://bsky.app/profile/danmatthew.co.uk" />
</head>
<body>
<Nav />
Expand Down
15 changes: 12 additions & 3 deletions src/pages/notes/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,28 @@ const { Content } = await render(entry);
---

<BaseLayout title={`${entry.data.title}`}>
<article>
<article class="h-entry">
<Hero title={entry.data.title}>
<div slot="header-extras">
<div class="meta">
<time datetime={entry.data.publishedDate.toISOString()}>
<time class="dt-published" datetime={entry.data.publishedDate.toISOString()}>
{entry.data.publishedDate.toLocaleDateString("en-GB")}
</time>
</div>
</div>
</Hero>
<section class="flow">
<section class="flow e-content">
<Content />
</section>
<footer hidden>
<data class="p-name" value={entry.data.title}></data>
<a class="u-url" href={`https://danmatthew.co.uk/notes/${entry.id}/`}></a>
<div class="p-author h-card">
<a class="u-url p-name" href="https://danmatthew.co.uk">Dan Matthew</a>
</div>
<a class="u-syndication" href="https://brid.gy/publish/mastodon" rel="syndication"></a>
<a class="u-syndication" href="https://brid.gy/publish/bluesky" rel="syndication"></a>
</footer>
</article>
<nav aria-label="Notes pagination">
{
Expand Down
Loading