Skip to content

Commit cbecac2

Browse files
committed
rss feed back
1 parent f6ffb26 commit cbecac2

File tree

5 files changed

+83
-26
lines changed

5 files changed

+83
-26
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ yarn-error.log*
3838
*.tsbuildinfo
3939
next-env.d.ts
4040
out/
41+
public/feed.xml

package-lock.json

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,28 @@
88
"lint": "next lint"
99
},
1010
"dependencies": {
11-
"react": "^19.0.0",
12-
"react-dom": "^19.0.0",
13-
"next": "15.1.4",
11+
"@tailwindcss/typography": "^0.5.16",
1412
"autoprefixer": "^10.4.20",
13+
"feed": "^4.2.2",
1514
"focus-visible": "^5.2.1",
15+
"next": "15.1.4",
16+
"react": "^19.0.0",
1617
"react-aria": "^3.36.0",
18+
"react-dom": "^19.0.0",
1719
"react-stately": "^3.34.0",
18-
"tailwindcss": "^3.4.17",
19-
"@tailwindcss/typography": "^0.5.16"
20+
"tailwindcss": "^3.4.17"
2021
},
2122
"devDependencies": {
22-
"typescript": "^5",
23+
"@eslint/eslintrc": "^3",
2324
"@types/node": "^20",
2425
"@types/react": "^19",
2526
"@types/react-dom": "^19",
2627
"clsx": "^2.1.1",
28+
"eslint": "^9",
29+
"eslint-config-next": "15.1.4",
2730
"postcss": "^8",
2831
"postcss-focus-visible": "^10.0.1",
2932
"tailwindcss": "^3.4.1",
30-
"eslint": "^9",
31-
"eslint-config-next": "15.1.4",
32-
"@eslint/eslintrc": "^3"
33+
"typescript": "^5"
3334
}
3435
}

src/components/Layout.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,17 @@ function ApplePodcastIcon(props: React.SVGProps<SVGSVGElement>) {
108108
)
109109
}
110110

111-
// function RSSIcon(props: React.SVGProps<SVGSVGElement>) {
112-
// return (
113-
// <svg aria-hidden="true" viewBox="0 0 32 32" {...props}>
114-
// <path
115-
// fillRule="evenodd"
116-
// clipRule="evenodd"
117-
// d="M8.5 4h15A4.5 4.5 0 0 1 28 8.5v15a4.5 4.5 0 0 1-4.5 4.5h-15A4.5 4.5 0 0 1 4 23.5v-15A4.5 4.5 0 0 1 8.5 4ZM13 22a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm-6-6a9 9 0 0 1 9 9h3A12 12 0 0 0 7 13v3Zm5.74-4.858A15 15 0 0 0 7 10V7a18 18 0 0 1 18 18h-3a15 15 0 0 0-9.26-13.858Z"
118-
// />
119-
// </svg>
120-
// )
121-
// }
111+
function RSSIcon(props: React.SVGProps<SVGSVGElement>) {
112+
return (
113+
<svg aria-hidden="true" viewBox="0 0 32 32" {...props}>
114+
<path
115+
fillRule="evenodd"
116+
clipRule="evenodd"
117+
d="M8.5 4h15A4.5 4.5 0 0 1 28 8.5v15a4.5 4.5 0 0 1-4.5 4.5h-15A4.5 4.5 0 0 1 4 23.5v-15A4.5 4.5 0 0 1 8.5 4ZM13 22a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm-6-6a9 9 0 0 1 9 9h3A12 12 0 0 0 7 13v3Zm5.74-4.858A15 15 0 0 0 7 10V7a18 18 0 0 1 18 18h-3a15 15 0 0 0-9.26-13.858Z"
118+
/>
119+
</svg>
120+
)
121+
}
122122

123123
function AboutSection(props: React.HTMLAttributes<HTMLElement>) {
124124
return (
@@ -188,7 +188,7 @@ export function Layout({children}: { children: ReactElement }) {
188188
link: 'https://open.spotify.com/show/2rlbFoVg4eEVbrurrOkPHB'
189189
},
190190
{label: 'Apple Podcast', Icon: ApplePodcastIcon, link: 'https://podcasts.apple.com'},
191-
// {label: 'RSS Feed', Icon: RSSIcon, link: '/rss.xml'},
191+
{label: 'RSS Feed', Icon: RSSIcon, link: '/feed.xml'},
192192
].map(({label, Icon, link}) => (
193193
<li key={label} className="flex">
194194
<Link

src/pages/index.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import podcasts from '@/data/podcasts.json'
88
import authors from '@/data/authors.json'
99
import {PlayButton} from '@/components/player/PlayButton'
1010
import Image from 'next/image';
11+
import {Feed, FeedOptions} from "feed";
12+
import fs from "fs";
1113

1214
function EpisodeEntry({episode}: {
1315
episode: Episode
@@ -17,10 +19,7 @@ function EpisodeEntry({episode}: {
1719
const audioPlayerData: { title: string; audio: { src: string; type: string } } = useMemo(
1820
() => ({
1921
title: episode.title + " · " + episode.authors.map(({name}) => name).join(', '),
20-
audio: {
21-
src: `/audio/S${String(episode.season).padStart(2, '0')}-E${String(episode.episode).padStart(2, '0')}.mp3`,
22-
type: 'audio/mpeg'
23-
}
22+
audio: episode.audio
2423
}),
2524
[episode]
2625
)
@@ -161,6 +160,23 @@ export interface Episode {
161160

162161
export async function getStaticProps(): Promise<{ props: { episodes: Episode[] } }> {
163162
const episodes: PodcastEpisode[] = podcasts.toReversed();
163+
const feedOptions: FeedOptions = {
164+
id: "podcast.allegro.tech",
165+
title: "allegro.tech podcast",
166+
description: "W Allegro Tech uwielbiamy dzielić się wiedzą i robimy to na różne sposoby. Jednym z nich są nasze podcasty technologiczne, które są zbiorem angażujących historii, dobrych praktyk i inspirujących case-studies stosowanych w Allegro. Zapraszamy do słuchania!",
167+
copyright: 'Allegro'
168+
};
169+
const feed = new Feed(feedOptions);
170+
episodes.forEach((episode) => {
171+
feed.addItem({
172+
title: episode.title,
173+
id: episode.slug,
174+
link: `https://podcast.allegro.tech/#${episode.slug}`,
175+
description: episode.toc.join(""),
176+
date: new Date(episode.date),
177+
});
178+
});
179+
fs.writeFileSync('./public/feed.xml', feed.rss2());
164180
return {
165181
props: {
166182
episodes: episodes.map((episode) => ({
@@ -169,7 +185,7 @@ export async function getStaticProps(): Promise<{ props: { episodes: Episode[] }
169185
published: episode.date,
170186
description: episode.toc,
171187
audio: {
172-
src: 'https://their-side-feed.vercel.app/episode-002.mp3',
188+
src: `/audio/S${String(episode.season).padStart(2, '0')}-E${String(episode.episode).padStart(2, '0')}.mp3`,
173189
type: 'audio/mpeg'
174190
},
175191
host: episode.host,

0 commit comments

Comments
 (0)