Skip to content

Commit

Permalink
Add script to generate JSONFeed
Browse files Browse the repository at this point in the history
  • Loading branch information
joschi committed Dec 20, 2023
1 parent 3a3887c commit d429ea3
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/generate-jsonfeed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Generate BellSoft Blog Feed
on:
push:
branches:
- main
workflow_dispatch:
schedule:
- cron: "1 0 * * *"
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
generate-feed:
name: Generate JSON Feed
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Generate RSS
run: ./feed.bash
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3
6 changes: 6 additions & 0 deletions feed.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -e -u -o pipefail

curl -fsSO 'https://bell-sw.com/page-data/blog/page-data.json'
mkdir _site
jq -f filter.jq page-data.json > _site/feed.json
22 changes: 22 additions & 0 deletions filter.jq
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.result.pageContext | {
"version": "https://jsonfeed.org/version/1.1",
"title": .title,
"home_page_url": "https://bell-sw.com/",
"feed_url": "https://example.org/feed.json",
"favicon": "https://bell-sw.com/assets/images/favicon.png",
items: [
.nodes[] | {
"id": .postData.jsonId,
"title": .postData.data.title.iv,
"summary": .postData.data.seo.iv.description,
"image": ("https://bell-sw.com" + .postCover.images.fallback.src),
"date_published": .postData.data.publishedAt.iv,
"date_modified": .postData.data.updatedAt.iv,
"authors": [{
"name": .postAuthorsData[].authorData.name.iv,
"avatar": ("https://bell-sw.com" + .postAuthorsData[].authorGatsbyImageData.images.fallback.src)
}],
"tags": .postData.data.category.iv,
"url": ("https://bell-sw.com" + .postData.data.relativeUrl.iv)
}]
}

0 comments on commit d429ea3

Please sign in to comment.