Add sorting option: Title followed by Series
This commit is contained in:
committed by
Aditya Chandel
parent
e559efc2f7
commit
1acb2917dd
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user