Skip to content

Commit 395266c

Browse files
committed
refactor(rss): update getRSS to use lastEdit for accurate date handling
1 parent 3989202 commit 395266c

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/app/rss.xml/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { getRSS } from "@/lib/rss"
22

33
export const revalidate = false
44

5-
export function GET() {
6-
return new Response(getRSS())
5+
export async function GET() {
6+
return new Response(await getRSS())
77
}

src/lib/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ export async function lastEdit(page: Page): Promise<Date> {
2525
owner: "TheNextLvl-net",
2626
repo: "docs",
2727
token: process.env.GITHUB_TOKEN,
28-
path: `content/docs/${page.file.path}`,
28+
path: `content/docs/${page.path}`,
2929
}).catch((error) => {
3030
console.error("Error fetching last edit date:", error)
31-
return new Date(0)
31+
return new Date()
3232
})
3333
return time ? time : new Date()
3434
}

src/lib/rss.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Feed } from "feed"
22
import { blog } from "@/lib/source"
3+
import { lastEdit } from "@/lib/api"
34

45
const baseUrl = "https://thenextlvl.net"
56

6-
export function getRSS() {
7+
export async function getRSS() {
78
const feed = new Feed({
89
title: "TheNextLvl Blog",
910
id: `${baseUrl}/blog`,
@@ -22,11 +23,10 @@ export function getRSS() {
2223
title: page.data.title,
2324
description: page.data.description,
2425
link: `${baseUrl}${page.url}`,
25-
date: new Date(page.data.lastModified?.getDate() ?? new Date()),
26-
26+
date: await lastEdit(page),
2727
author: [
2828
{
29-
name: "TheNextLvl",
29+
name: page.data.author
3030
},
3131
],
3232
})

0 commit comments

Comments
 (0)