Add sorting option: Title followed by Series

This commit is contained in:
aditya.chandel
2025-05-27 07:35:16 -07:00
committed by Aditya Chandel
parent e559efc2f7
commit 1acb2917dd
2 changed files with 10 additions and 2 deletions
@@ -9,6 +9,12 @@ export class SortService {
private readonly fieldExtractors: Record<string, (book: Book) => any> = {
title: (book) => book.metadata?.title?.toLowerCase() || null,
titleSeries: (book) => {
const title = book.metadata?.title?.toLowerCase() || '';
const inSeries = !!book.metadata?.seriesName;
const seriesOrder = book.metadata?.seriesNumber ?? Number.MAX_SAFE_INTEGER;
return [title, inSeries ? 1 : 0, seriesOrder];
},
author: (book) => book.metadata?.authors?.map(a => a.toLowerCase()).join(", ") || null,
publishedDate: (book) => book.metadata?.publishedDate === null ? null : new Date(book.metadata?.publishedDate!).getTime(),
publisher: (book) => book.metadata?.publisher || null,