Skip to content

Commit 6b6a535

Browse files
authored
Implement rss feed for amplifying-fsharp.github.io (#296)
1 parent a3f1254 commit 6b6a535

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

bun.lock

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"name": "amplifying-fsharp-website",
66
"dependencies": {
77
"@astrojs/react": "^4.2.7",
8+
"@astrojs/rss": "^4.0.13",
89
"@iconify-json/bi": "^1.2.4",
910
"@iconify-json/cil": "^1.2.2",
1011
"@iconify-json/fluent": "^1.2.21",
@@ -34,8 +35,8 @@
3435
"styled-components": "^6.1.18",
3536
},
3637
"devDependencies": {
37-
"@mermaid-js/mermaid-cli": "^11.4.0",
38-
"prettier": "^3.4.2",
38+
"@mermaid-js/mermaid-cli": "^11.4.2",
39+
"prettier": "^3.5.3",
3940
"prettier-plugin-astro": "^0.14.1",
4041
"vite-plugin-fable": "^0.0.32",
4142
},
@@ -65,6 +66,8 @@
6566

6667
"@astrojs/react": ["@astrojs/[email protected]", "", { "dependencies": { "@vitejs/plugin-react": "^4.4.1", "ultrahtml": "^1.6.0", "vite": "^6.3.4" }, "peerDependencies": { "@types/react": "^17.0.50 || ^18.0.21 || ^19.0.0", "@types/react-dom": "^17.0.17 || ^18.0.6 || ^19.0.0", "react": "^17.0.2 || ^18.0.0 || ^19.0.0", "react-dom": "^17.0.2 || ^18.0.0 || ^19.0.0" } }, "sha512-/wM90noT/6QyJEOGdDmDbq2D9qZooKTJNG1M8olmsW5ns6bJ7uxG5fzkYxcpA3WUTD6Dj6NtpEqchvb5h8Fa+g=="],
6768

69+
"@astrojs/rss": ["@astrojs/[email protected]", "", { "dependencies": { "fast-xml-parser": "^5.3.0", "picocolors": "^1.1.1" } }, "sha512-ugW4DmGn8kgfl8/qecU3EcKCAuEBrZqY7eYfa6at0sY7HGEwRdzsOafLE437RwDMP2ZuxfKnCNABs99YVhX0kg=="],
70+
6871
"@astrojs/telemetry": ["@astrojs/[email protected]", "", { "dependencies": { "ci-info": "^4.2.0", "debug": "^4.4.0", "dlv": "^1.1.3", "dset": "^3.1.4", "is-docker": "^3.0.0", "is-wsl": "^3.1.0", "which-pm-runs": "^1.1.0" } }, "sha512-SSVM820Jqc6wjsn7qYfV9qfeQvePtVc1nSofhyap7l0/iakUKywj3hfy3UJAOV4sGV4Q/u450RD4AaCaFvNPlg=="],
6972

7073
"@babel/code-frame": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.25.9", "js-tokens": "^4.0.0", "picocolors": "^1.0.0" } }, "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ=="],
@@ -891,6 +894,8 @@
891894

892895
"fast-safe-stringify": ["[email protected]", "", {}, "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA=="],
893896

897+
"fast-xml-parser": ["[email protected]", "", { "dependencies": { "strnum": "^2.1.0" }, "bin": { "fxparser": "src/cli/cli.js" } }, "sha512-jbNkWiv2Ec1A7wuuxk0br0d0aTMUtQ4IkL+l/i1r9PRf6pLXjDgsBsWwO+UyczmQlnehi4Tbc8/KIvxGQe+I/A=="],
898+
894899
"fastq": ["[email protected]", "", { "dependencies": { "reusify": "^1.0.4" } }, "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ=="],
895900

896901
"fd-slicer": ["[email protected]", "", { "dependencies": { "pend": "~1.2.0" } }, "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g=="],
@@ -1587,6 +1592,8 @@
15871592

15881593
"strip-json-comments": ["[email protected]", "", {}, "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig=="],
15891594

1595+
"strnum": ["[email protected]", "", {}, "sha512-7ZvoFTiCnGxBtDqJ//Cu6fWtZtc7Y3x+QOirG15wztbdngGSkht27o2pyGWrVy0b4WAy3jbKmnoK6g5VlVNUUw=="],
1596+
15901597
"styled-components": ["[email protected]", "", { "dependencies": { "@emotion/is-prop-valid": "1.2.2", "@emotion/unitless": "0.8.1", "@types/stylis": "4.2.5", "css-to-react-native": "3.2.0", "csstype": "3.1.3", "postcss": "8.4.49", "shallowequal": "1.1.0", "stylis": "4.3.2", "tslib": "2.6.2" }, "peerDependencies": { "react": ">= 16.8.0", "react-dom": ">= 16.8.0" } }, "sha512-Mvf3gJFzZCkhjY2Y/Fx9z1m3dxbza0uI9H1CbNZm/jSHCojzJhQ0R7bByrlFJINnMzz/gPulpoFFGymNwrsMcw=="],
15911598

15921599
"stylis": ["[email protected]", "", {}, "sha512-osIBl6BGUmSfDkyH2mB7EFvCJntXDrLhKjHTRj/rK6xLH0yuPrHULDRQzKokSOD4VoorhtKpfcfW1GAntu8now=="],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"dependencies": {
1515
"@astrojs/react": "^4.2.7",
16+
"@astrojs/rss": "^4.0.13",
1617
"@iconify-json/bi": "^1.2.4",
1718
"@iconify-json/cil": "^1.2.2",
1819
"@iconify-json/fluent": "^1.2.21",

src/layouts/Layout.astro

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ import Navigation from "../components/Navigation.astro";
3333
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
3434
<title>{title} | Amplifying F&#35;</title>
3535
<link rel="icon" href="/favicon.ico?v4" />
36+
<link
37+
rel="alternate"
38+
type="application/rss+xml"
39+
title="Amplifying F# Blog"
40+
href="/rss.xml"
41+
/>
3642
<link rel="preconnect" href="https://fonts.googleapis.com" />
3743
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
3844
<link

src/pages/rss.xml.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import rss from "@astrojs/rss";
2+
import { getCollection } from "astro:content";
3+
4+
export async function GET(context) {
5+
const blogs = await getCollection("blog");
6+
const sessions = await getCollection("sessions");
7+
8+
const blogItems = blogs.map((post) => ({
9+
title: post.data.title,
10+
pubDate: post.data.date,
11+
description: `A blog post by ${post.data.author}`,
12+
author: post.data.author,
13+
link: `/blog/${post.id}`,
14+
categories: ["Blog"],
15+
}));
16+
17+
const sessionItems = sessions.map((session) => ({
18+
title: session.data.title,
19+
pubDate: session.data.date,
20+
description: `${session.data.preview} - Champion: ${session.data.champion}`,
21+
author: session.data.champion,
22+
link: `/sessions/${session.id}`,
23+
categories: ["Session"],
24+
}));
25+
26+
const allItems = [...blogItems, ...sessionItems].sort(
27+
(a, b) => b.pubDate - a.pubDate,
28+
);
29+
30+
return rss({
31+
title: "Amplifying F#",
32+
description: "Blog posts and sessions from the Amplifying F# community",
33+
site: context.site,
34+
items: allItems,
35+
customData: `<language>en-us</language>`,
36+
});
37+
}

0 commit comments

Comments
 (0)