Skip to content

Commit

Permalink
rss feed back
Browse files Browse the repository at this point in the history
  • Loading branch information
bgalek committed Jan 27, 2025
1 parent f6ffb26 commit cbecac2
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts
out/
public/feed.xml
39 changes: 39 additions & 0 deletions package-lock.json

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

19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,28 @@
"lint": "next lint"
},
"dependencies": {
"react": "^19.0.0",
"react-dom": "^19.0.0",
"next": "15.1.4",
"@tailwindcss/typography": "^0.5.16",
"autoprefixer": "^10.4.20",
"feed": "^4.2.2",
"focus-visible": "^5.2.1",
"next": "15.1.4",
"react": "^19.0.0",
"react-aria": "^3.36.0",
"react-dom": "^19.0.0",
"react-stately": "^3.34.0",
"tailwindcss": "^3.4.17",
"@tailwindcss/typography": "^0.5.16"
"tailwindcss": "^3.4.17"
},
"devDependencies": {
"typescript": "^5",
"@eslint/eslintrc": "^3",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"clsx": "^2.1.1",
"eslint": "^9",
"eslint-config-next": "15.1.4",
"postcss": "^8",
"postcss-focus-visible": "^10.0.1",
"tailwindcss": "^3.4.1",
"eslint": "^9",
"eslint-config-next": "15.1.4",
"@eslint/eslintrc": "^3"
"typescript": "^5"
}
}
24 changes: 12 additions & 12 deletions src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,17 @@ function ApplePodcastIcon(props: React.SVGProps<SVGSVGElement>) {
)
}

// function RSSIcon(props: React.SVGProps<SVGSVGElement>) {
// return (
// <svg aria-hidden="true" viewBox="0 0 32 32" {...props}>
// <path
// fillRule="evenodd"
// clipRule="evenodd"
// 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"
// />
// </svg>
// )
// }
function RSSIcon(props: React.SVGProps<SVGSVGElement>) {
return (
<svg aria-hidden="true" viewBox="0 0 32 32" {...props}>
<path
fillRule="evenodd"
clipRule="evenodd"
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"
/>
</svg>
)
}

function AboutSection(props: React.HTMLAttributes<HTMLElement>) {
return (
Expand Down Expand Up @@ -188,7 +188,7 @@ export function Layout({children}: { children: ReactElement }) {
link: 'https://open.spotify.com/show/2rlbFoVg4eEVbrurrOkPHB'
},
{label: 'Apple Podcast', Icon: ApplePodcastIcon, link: 'https://podcasts.apple.com'},
// {label: 'RSS Feed', Icon: RSSIcon, link: '/rss.xml'},
{label: 'RSS Feed', Icon: RSSIcon, link: '/feed.xml'},
].map(({label, Icon, link}) => (
<li key={label} className="flex">
<Link
Expand Down
26 changes: 21 additions & 5 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import podcasts from '@/data/podcasts.json'
import authors from '@/data/authors.json'
import {PlayButton} from '@/components/player/PlayButton'
import Image from 'next/image';
import {Feed, FeedOptions} from "feed";
import fs from "fs";

function EpisodeEntry({episode}: {
episode: Episode
Expand All @@ -17,10 +19,7 @@ function EpisodeEntry({episode}: {
const audioPlayerData: { title: string; audio: { src: string; type: string } } = useMemo(
() => ({
title: episode.title + " · " + episode.authors.map(({name}) => name).join(', '),
audio: {
src: `/audio/S${String(episode.season).padStart(2, '0')}-E${String(episode.episode).padStart(2, '0')}.mp3`,
type: 'audio/mpeg'
}
audio: episode.audio
}),
[episode]
)
Expand Down Expand Up @@ -161,6 +160,23 @@ export interface Episode {

export async function getStaticProps(): Promise<{ props: { episodes: Episode[] } }> {
const episodes: PodcastEpisode[] = podcasts.toReversed();
const feedOptions: FeedOptions = {
id: "podcast.allegro.tech",
title: "allegro.tech podcast",
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!",
copyright: 'Allegro'
};
const feed = new Feed(feedOptions);
episodes.forEach((episode) => {
feed.addItem({
title: episode.title,
id: episode.slug,
link: `https://podcast.allegro.tech/#${episode.slug}`,
description: episode.toc.join(""),
date: new Date(episode.date),
});
});
fs.writeFileSync('./public/feed.xml', feed.rss2());
return {
props: {
episodes: episodes.map((episode) => ({
Expand All @@ -169,7 +185,7 @@ export async function getStaticProps(): Promise<{ props: { episodes: Episode[] }
published: episode.date,
description: episode.toc,
audio: {
src: 'https://their-side-feed.vercel.app/episode-002.mp3',
src: `/audio/S${String(episode.season).padStart(2, '0')}-E${String(episode.episode).padStart(2, '0')}.mp3`,
type: 'audio/mpeg'
},
host: episode.host,
Expand Down

0 comments on commit cbecac2

Please sign in to comment.