Skip to content

Commit 29100c4

Browse files
committed
chore: fix rss feed
1 parent 38d8334 commit 29100c4

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

.changeset/hungry-bees-sniff.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"r.obin.ch": patch
3+
---
4+
5+
Fix rss feed

src/pages/rss[...locale].xml.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import rss from "@astrojs/rss";
22
import type { APIRoute, GetStaticPaths, InferGetStaticParamsType, InferGetStaticPropsType } from "astro";
33
import { C, localeSlugs } from "../site.config";
44
import { parseLocale } from "../utils/i18n";
5-
import { getCollection } from "astro:content";
65
import { i18nPropsAndParams } from "astro-loader-i18n";
76
import { defaultPropsAndParamsOptions } from "../utils/paths";
7+
import { defaultBlogCollection } from "../collections/blog";
8+
import slug from "limax";
89

910
export const getStaticPaths = (async () => {
1011
const versions = [undefined, ...localeSlugs];
@@ -16,19 +17,23 @@ type Params = InferGetStaticParamsType<typeof getStaticPaths>;
1617

1718
export const GET: APIRoute<Props, Params> = async (context) => {
1819
const locale = parseLocale(context.props.locale);
19-
const blogs = await getCollection("blog", (entry) => entry.data.locale === locale);
20+
const blogs = defaultBlogCollection;
2021

2122
const routePattern = "[...locale]/[blog]/[...slug]";
2223
const propsAndParams = i18nPropsAndParams(blogs, {
2324
...defaultPropsAndParamsOptions,
2425
routePattern,
26+
generateSegments: (entry) => ({
27+
slug: `${entry.data.contentPath}/${slug(entry.data.title)}`,
28+
}),
2529
});
2630

2731
return rss({
2832
title: C.MESSAGES[locale]["title"],
2933
description: C.MESSAGES[locale]["description"],
3034
site: context.site || "http://localhost:4321",
3135
items: propsAndParams.map(({ props: blog }) => ({
36+
author: C.MESSAGES[locale]["author"],
3237
title: blog.data.title,
3338
pubDate: blog.data.publishedAt,
3439
link: blog.translatedPath,

src/site.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const C = {
2323
de: {
2424
language: "Deutsch",
2525
title: "Robin Bühlers Webseite",
26+
author: "Robin Bühler",
2627
description:
2728
"Auf dieser Webseite sammle ich interessante Dinge aus meinen Abenteuer in der Welt von Bits und Bytes und teile auch das Eine oder Andere aus der analogen Realität.",
2829
feedTitle: "Robins Blog",
@@ -57,6 +58,7 @@ export const C = {
5758
en: {
5859
language: "English",
5960
title: "Robin Bühlers Website",
61+
author: "Robin Bühler",
6062
description:
6163
"On this website I collect interesting things from my adventures in the world of bits and bytes and also share some things from the analog reality.",
6264
feedTitle: "Robins Blog",

0 commit comments

Comments
 (0)