Skip to content

Commit f6b4e1c

Browse files
authored
Merge pull request #15 from Ecuador-In-Tech/13-rss-+-seo-+-sitemap-integration-implementation
rss + seo + sitemap integration implementation
2 parents a1b28d7 + aa844c3 commit f6b4e1c

File tree

9 files changed

+263
-6
lines changed

9 files changed

+263
-6
lines changed

astro.config.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import tailwind from '@astrojs/tailwind';
55

66
import alpinejs from '@astrojs/alpinejs';
77

8+
import sitemap from '@astrojs/sitemap';
9+
810
// https://astro.build/config
911
export default defineConfig({
1012
site: "https://ecuadorintech.org",
11-
integrations: [tailwind(), alpinejs()]
13+
integrations: [tailwind(), alpinejs(), sitemap()]
1214
});

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
},
1111
"dependencies": {
1212
"@astrojs/alpinejs": "^0.4.0",
13+
"@astrojs/rss": "^4.0.10",
14+
"@astrojs/sitemap": "^3.2.1",
1315
"@astrojs/tailwind": "^5.1.3",
1416
"@types/alpinejs": "^3.13.11",
1517
"alpinejs": "^3.14.6",

pnpm-lock.yaml

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

public/robots.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
User-agent: *
2+
Allow: /
3+
4+
Sitemap: https://ecuadorintech.org/sitemap-index.xml

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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@ const { title } = Astro.props;
1010
---
1111

1212
<!doctype html>
13-
<html lang="en">
13+
<html lang="es">
1414
<head>
1515
<meta charset="UTF-8" />
1616
<meta name="description" content="Ecuador In Tech" />
1717
<meta name="viewport" content="width=device-width" />
1818
<link rel="icon" type="image/svg+xml" href="/favicon.png" />
19+
<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+
/>
1926
<meta name="generator" content={Astro.generator} />
2027
<title>{title}</title>
2128

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)