Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Load in an RSS Feed #25 #26

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ import netlify from "@astrojs/netlify/functions";
export default defineConfig({
output: "server",
adapter: netlify(),
site: "https://mixpod.app/",
});
39 changes: 38 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
"astro": "^3.4.3",
"prettier": "^3.0.3",
"prettier-plugin-astro": "^0.12.0"
},
"dependencies": {
"@astrojs/rss": "^4.0.1"
}
}
31 changes: 31 additions & 0 deletions src/pages/[playListID].xml.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import rss from "@astrojs/rss";

// fake a DB
const DB = {
playlist1: {
title: "A fabulous MixPod for my friend",
description: "A humble MixPod",
episodes: [],
},
};

export function GET(context) {
// get the ID for the playlist
const playListID = "playlist1";

const playList = DB[playListID];
// get the ID for the playlist from the URL [playListID].xml.js

return rss({
// `<title>` field in output xml
title: playList.title,
// `<description>` field in output xml
description: playList.description,
site: context.site,
// Array of `<item>`s in output xml
// See "Generating items" section for examples using content collections and glob imports
items: playList.episodes,
// (optional) inject custom xml
customData: `<language>en-us</language>`,
});
}
27 changes: 27 additions & 0 deletions src/pages/your-mix.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
const DB = { playlist1: { title: "A fabulous MixPod for my friend", items: [] }}

const playListID = "slow-steady";
// https://feeds.transistor.fm/slow-steady

import rss from "@astrojs/rss";

export function GET(context) {
return rss({
// `<title>` field in output xml
title: "A fabulous MixPod for my friend",
// `<description>` field in output xml
description: "A humble MixPod",
// Pull in your project "site" from the endpoint context
// https://docs.astro.build/en/reference/api-reference/#contextsite
site: context.site,
// Array of `<item>`s in output xml
// See "Generating items" section for examples using content collections and glob imports
items: [],
// (optional) inject custom xml
customData: `<language>en-us</language>`,
});
}

---