mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-22 06:16:18 -05:00
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { Feed } from "feed";
|
|
import { baseUrl } from "./metadata";
|
|
import { blogs } from "./source";
|
|
|
|
export function getRSS() {
|
|
const feed = new Feed({
|
|
title: "Better Auth Blog",
|
|
description: "Latest updates, articles, and insights about Better Auth",
|
|
generator: "better-auth",
|
|
id: `${baseUrl}blog`,
|
|
link: `${baseUrl}blog`,
|
|
language: "en",
|
|
image: `${baseUrl}release-og/blogs.png`,
|
|
favicon: `${baseUrl}favicon/favicon-32x32.png`,
|
|
copyright: `All rights reserved ${new Date().getFullYear()}, Better Auth Inc.`,
|
|
});
|
|
|
|
for (const page of blogs.getPages().sort((a, b) => {
|
|
return new Date(b.data.date).getTime() - new Date(a.data.date).getTime();
|
|
})) {
|
|
const url = page.url.replace("blogs/", "blog/");
|
|
|
|
feed.addItem({
|
|
id: page.url,
|
|
title: page.data.title,
|
|
description: page.data.description,
|
|
image: page.data.image
|
|
? page.data.image.startsWith("/")
|
|
? `${baseUrl}${page.data.image.slice(1)}`
|
|
: page.data.image
|
|
: undefined,
|
|
link: url.startsWith("/") ? `${baseUrl}${url.slice(1)}` : url,
|
|
date: new Date(page.data.date),
|
|
author: page.data.author
|
|
? [
|
|
{
|
|
name: page.data.author.name,
|
|
avatar: page.data.author.avatar,
|
|
link: page.data.author.twitter,
|
|
},
|
|
]
|
|
: [],
|
|
});
|
|
}
|
|
|
|
return feed.rss2();
|
|
}
|