Skip to content

feature: Add RSS feed support for news#198

Closed
Scoutboy06 wants to merge 3 commits into
cthit:mainfrom
Scoutboy06:main
Closed

feature: Add RSS feed support for news#198
Scoutboy06 wants to merge 3 commits into
cthit:mainfrom
Scoutboy06:main

Conversation

@Scoutboy06
Copy link
Copy Markdown
Contributor

The purpose of this PR is to add a "Subscribe via RSS" button for the news list. I have implemented the RSS feed via an /api route, supporting both sv and en locales.

However, I'd like to get feedback on the UI part of this PR. I have currently placed the button next to the "Nyheter" ("News") heading on the home page, and I'm not sure how to get it to look good.

image

@Scoutboy06 Scoutboy06 added the enhancement New feature or request label Apr 15, 2026
@Scoutboy06 Scoutboy06 requested a review from GAsplund as a code owner April 15, 2026 07:05
@Scoutboy06 Scoutboy06 added the help wanted Extra attention is needed label Apr 15, 2026
Copy link
Copy Markdown
Member

@GAsplund GAsplund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR! I think the button location is fine where it is now, but maybe @Sus-H can come with some more useful insights on that.

I have added some comments on the code implementation that will need addressing before merging, please check them out!

@@ -0,0 +1,28 @@
'use client';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this component does not need any client-side functionality?

const l = i18nService.getLocale(locale);

return (
<a
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use <Link> instead.

Comment thread src/services/rssService.ts Outdated
static generateFeed(
newsItems: NewsItem[],
locale: string = 'sv',
baseUrl: string = 'https://chalmers.it'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably not be a parameter, instead just read it from the environment variable inside the function. I don't think there's much reason to be able to make this URL different from the env-configured one?

Comment thread src/services/rssService.ts Outdated
Comment on lines +16 to +47
/**
* Converts a date to RFC 822 format for RSS feeds
* Example: "Mon, 14 Apr 2025 10:00:00 GMT"
*/
private static dateToRFC822(date: Date | string): string {
const d = typeof date === 'string' ? new Date(date) : date;
const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
const months = [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec'
];

const dayName = days[d.getUTCDay()];
const dayNum = String(d.getUTCDate()).padStart(2, '0');
const monthName = months[d.getUTCMonth()];
const year = d.getUTCFullYear();
const hours = String(d.getUTCHours()).padStart(2, '0');
const minutes = String(d.getUTCMinutes()).padStart(2, '0');
const seconds = String(d.getUTCSeconds()).padStart(2, '0');

return `${dayName}, ${dayNum} ${monthName} ${year} ${hours}:${minutes}:${seconds} GMT`;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Date.toUTCString instead. RFC-7231 is compatible with RFC-822.

Comment on lines +5 to +6
padding: 0.5rem;
border-radius: 0.25rem;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: You can probably remove this with no regressions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite true I believe. Having a padding is important for mobile, and the border-radius is just a bit of eye-candy for the tab-focused state

@Scoutboy06
Copy link
Copy Markdown
Contributor Author

Made a commit based on your feedback!

@GAsplund
Copy link
Copy Markdown
Member

GAsplund commented Apr 15, 2026

Looks better! Don't forget to remove the old RFC822 function and the (now) extra parameter.

@Sus-H
Copy link
Copy Markdown
Contributor

Sus-H commented Apr 21, 2026

I think it looks good. Assuming this is a feature for advanced users, it's good that it somewhat blends in. I would maybe experiment with vertical middle align, baseline align, or have the icon be the same as the line height.

@Scoutboy06 Scoutboy06 closed this Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants