1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Show nested chapters in bookplayer TOC

This commit is contained in:
Vincent Lark 2023-10-19 09:44:32 +02:00 committed by Bill Thornton
parent 0c6afd1d01
commit 7a495aff30
2 changed files with 25 additions and 7 deletions

View file

@ -57,7 +57,11 @@
margin-bottom: 5px; margin-bottom: 5px;
list-style-type: none; list-style-type: none;
font-size: 120%; font-size: 1.2rem;
ul {
padding-left: 1.5rem;
}
a:link { a:link {
color: #000; color: #000;

View file

@ -51,6 +51,25 @@ export default class TableOfContents {
}); });
} }
chapterTocItem(book, chapter) {
let itemHtml = '<li>';
// remove parent directory reference from href to fix certain books
const link = chapter.href.startsWith('../') ? chapter.href.slice(3) : chapter.href;
itemHtml += `<a href="${book.path.directory + link}">${chapter.label}</a>`;
if (chapter.subitems?.length) {
const subHtml = chapter.subitems
.map((nestedChapter) => this.chapterTocItem(book, nestedChapter))
.join('');
itemHtml += `<ul>${subHtml}</ul>`;
}
itemHtml += '</li>';
return itemHtml;
}
createMediaElement() { createMediaElement() {
const rendition = this.rendition; const rendition = this.rendition;
@ -67,12 +86,7 @@ export default class TableOfContents {
tocHtml += '</div>'; tocHtml += '</div>';
tocHtml += '<ul class="toc">'; tocHtml += '<ul class="toc">';
rendition.book.navigation.forEach((chapter) => { rendition.book.navigation.forEach((chapter) => {
tocHtml += '<li>'; tocHtml += this.chapterTocItem(rendition.book, chapter);
// remove parent directory reference from href to fix certain books
const link = chapter.href.startsWith('../') ? chapter.href.slice(3) : chapter.href;
tocHtml += `<a href="${rendition.book.path.directory + link}">${chapter.label}</a>`;
tocHtml += '</li>';
}); });
tocHtml += '</ul>'; tocHtml += '</ul>';