Added rss feed for novelupdates.com to auto pickup novel being published

This commit is contained in:
2025-01-12 21:36:29 -05:00
parent 522bf5ab56
commit 418b3e4a3f
3 changed files with 71 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
import { subDays } from "date-fns";
import { Book, Chapter, Editor } from "./types";
const API_URL = process.env.NEXT_PUBLIC_API_URL as string;
@@ -48,6 +49,14 @@ export async function fetchBooks(): Promise<Book[]> {
return data.data;
}
export async function fetchChaptersRSS(): Promise<Chapter[]> {
const currentDateTime = new Date()
const yesterday = subDays(currentDateTime, 1);
const data = await fetchFromAPI<{ data: Chapter[] }>
(`/api/chapters?populate=book&filters[release_datetime][$lte]=${currentDateTime.toISOString()}&filters[release_datetime][$gte]=${yesterday.toISOString()}`);
return data.data;
}
export async function fetchBookChapterLinks(bookId: string): Promise<Book> {
const currentDateTime = new Date().toISOString();
const data = await fetchFromAPI<{ data: Book }>(`/api/books/${bookId}?populate[chapters][filters][release_datetime][$lte]=${currentDateTime}`);