Added ad-walled support, with counters and changed a lot of the current pages look to see funnel people toward that path
This commit is contained in:
@@ -109,10 +109,21 @@ export async function fetchBookChapterLinks(bookId: string): Promise<Book> {
|
||||
*/
|
||||
export async function fetchBookById(bookId: string): Promise<Book> {
|
||||
const currentDateTime = new Date().toISOString();
|
||||
const nextday = addDays(new Date(), 1).toISOString();
|
||||
//[chapters][filters][release_datetime][$lte]=${currentDateTime}
|
||||
const data = await fetchFromAPI<Book>(
|
||||
`/api/books/${bookId}?populate[chapters][filters][release_datetime][$lte]=${currentDateTime}&populate=cover`
|
||||
`/api/books/${bookId}?populate[chapters][filters][release_datetime][$lte]=${nextday}&populate=cover`
|
||||
);
|
||||
const stripped_data = []
|
||||
for (const chapter of data[0].chapters) {
|
||||
const stripped_chapter = chapter;
|
||||
if (new Date(chapter.release_datetime).toISOString() > currentDateTime) {
|
||||
stripped_chapter.content = "";
|
||||
stripped_chapter.documentId = "";
|
||||
}
|
||||
stripped_data.push(stripped_chapter)
|
||||
}
|
||||
data[0].chapters = stripped_data;
|
||||
//I do not know why the hell it refuse to populate glossary only 1 field is allow to be populated after ????????
|
||||
const glossary = await fetchGlossaryByBookId(bookId);
|
||||
data[0].glossary = glossary;
|
||||
@@ -140,11 +151,17 @@ export async function fetchEditors(): Promise<Editor[]> {
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function fetchEarlyRelease(): Promise<Chapter[]> {
|
||||
const current_datetime = new Date()
|
||||
const data = await fetchFromAPI<Chapter>(`/api/chapters/?populate[book][fields][0]=title&fields[0]=number&fields[1]=title&fields[2]=release_datetime&filters[release_datetime][$gte]=${current_datetime.toISOString()}&filters[release_datetime][$lte]=${addDays(current_datetime, 1).toISOString()}`);
|
||||
return data;
|
||||
}
|
||||
|
||||
export type ChapterRelease = { current_chapters: Chapter[], future_chapters: Chapter[] }
|
||||
export async function fetchReleases(): Promise<{ current_chapters: Chapter[], future_chapters: Chapter[] }> {
|
||||
const current_datetime = new Date()
|
||||
const previous_week = subDays(current_datetime, 3);
|
||||
const next_week = addDays(current_datetime, 3);
|
||||
const previous_week = subDays(current_datetime, 1);
|
||||
const next_week = addDays(current_datetime, 1);
|
||||
|
||||
const data = await fetchFromAPI<Chapter>(`/api/chapters/?populate[book][fields][0]=title&fields[0]=number&fields[1]=title&fields[2]=release_datetime&filters[release_datetime][$gte]=${previous_week.toISOString()}&filters[release_datetime][$lte]=${next_week.toISOString()}`);
|
||||
const chapters: Chapter[] = data;
|
||||
@@ -168,13 +185,15 @@ export async function createReport(
|
||||
details: string,
|
||||
book_id: string,
|
||||
chapter_id: string,
|
||||
email: string
|
||||
) {
|
||||
const payload = {
|
||||
data: {
|
||||
error_type: error_type,
|
||||
details: details,
|
||||
book: book_id,
|
||||
chapter: chapter_id
|
||||
chapter: chapter_id,
|
||||
report_email: email
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ export interface Book {
|
||||
rating: number;
|
||||
views: number;
|
||||
readers: number;
|
||||
release_rate: number;
|
||||
}
|
||||
|
||||
export interface Announcement {
|
||||
|
||||
@@ -28,4 +28,14 @@ export async function markdownToHtml(markdown: string): Promise<string> {
|
||||
return markdown
|
||||
}
|
||||
return sanitizedHtml
|
||||
}
|
||||
|
||||
export function encodeId(documentId: string): string {
|
||||
const salt = "salty_aff"
|
||||
return Buffer.from(documentId + salt).toString('base64')
|
||||
}
|
||||
|
||||
export function decodeId(encodedId: string): string {
|
||||
const salt = "salty_aff"
|
||||
return Buffer.from(encodedId, 'base64').toString().replace(salt, '')
|
||||
}
|
||||
Reference in New Issue
Block a user