Use splitTOCHref to support other ebook formats as discussed in foliate-js#45

This commit is contained in:
chrox
2024-12-20 22:44:35 +01:00
parent b581251b58
commit d7ccbbcaa2
4 changed files with 12 additions and 7 deletions
+2 -2
View File
@@ -114,13 +114,13 @@ export const useReaderStore = create<ReaderStore>((set, get) => ({
console.log('Loading book', key);
const { book: loadedBookDoc } = await new DocumentLoader(file).open();
const bookDoc = loadedBookDoc as BookDoc;
if (bookDoc.toc && bookDoc.sections) {
if (bookDoc.toc?.length > 0 && bookDoc.sections?.length > 0) {
updateTocID(bookDoc.toc);
const sections = bookDoc.sections.reduce((map: Record<string, SectionItem>, section) => {
map[section.id] = section;
return map;
}, {});
updateTocCFI(bookDoc.toc, sections);
updateTocCFI(bookDoc, bookDoc.toc, sections);
}
useBookDataStore.setState((state) => ({
booksData: {