Skip to content

Commit aa844c3

Browse files
committed
feat: Add RSS support with new rss.xml page and link in footer
1 parent b048b95 commit aa844c3

File tree

7 files changed

+207
-4
lines changed

7 files changed

+207
-4
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"dependencies": {
1212
"@astrojs/alpinejs": "^0.4.0",
13+
"@astrojs/rss": "^4.0.10",
1314
"@astrojs/sitemap": "^3.2.1",
1415
"@astrojs/tailwind": "^5.1.3",
1516
"@types/alpinejs": "^3.13.11",

pnpm-lock.yaml

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

public/rss/styles.xsl

Lines changed: 142 additions & 0 deletions
Large diffs are not rendered by default.

src/assets/events.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
[
22
{
3+
"id": "git-github-workshop",
34
"title": "Git & GitHub",
45
"description": "Hands-on Workshop para iniciantes.",
5-
"links": [
6-
"https://ecuadorintech.org"
7-
],
6+
"link": "https://ecuadorintech.org/events",
87
"date": "2024-12-4",
98
"place": "Online",
109
"modality": "Virtual",
1110
"hostedBy": "Ecuador In Tech",
1211
"image": "/github-workshop.jpg",
1312
"attendees": 31
1413
}
15-
]
14+
]
1615

src/components/Footer.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<li><a href="/" class="text-gray-300 hover:text-white">Inicio</a></li>
1515
<li><a href="/communities" class="text-gray-300 hover:text-white">Comunidades</a></li>
1616
<li><a href="/events" class="text-gray-300 hover:text-white">Eventos</a></li>
17+
<li><a href="/rss.xml" class="text-gray-300 hover:text-white"> Suscríbete a nuestro canal RSS</a></li>
1718
</ul>
1819
</div>
1920
<div>

src/layouts/Layout.astro

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ const { title } = Astro.props;
1717
<meta name="viewport" content="width=device-width" />
1818
<link rel="icon" type="image/svg+xml" href="/favicon.png" />
1919
<link rel="sitemap" href="/sitemap-index.xml" />
20+
<link
21+
rel="alternate"
22+
type="application/rss+xml"
23+
title="RSS Feed for Ecuador In Tech"
24+
href={new URL("rss.xml", Astro.site)}
25+
/>
2026
<meta name="generator" content={Astro.generator} />
2127
<title>{title}</title>
2228

src/pages/rss.xml.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import rss from '@astrojs/rss';
2+
import fs from 'fs';
3+
import path from 'path';
4+
5+
export async function GET(context) {
6+
const filePath = path.join(process.cwd(), 'src/assets/events.json');
7+
const fileContents = fs.readFileSync(filePath, 'utf-8');
8+
const events = JSON.parse(fileContents);
9+
10+
return rss({
11+
title: 'Eventos de Ecuador In Tech',
12+
description: 'Una lista de eventos organizados por Ecuador In Tech.',
13+
site: context.site,
14+
stylesheet: '/rss/styles.xsl',
15+
items: events.map((event) => ({
16+
title: event.title,
17+
description: event.description,
18+
link: event.link,
19+
date: event.date,
20+
place: event.place,
21+
modality: event.modality,
22+
hostedBy: event.hostedBy,
23+
customData: `
24+
<date>${event.date}</date>
25+
<place>${event.place}</place>
26+
<hostedBy>${event.hostedBy}</hostedBy>
27+
`
28+
})),
29+
});
30+
}

0 commit comments

Comments
 (0)