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:
parent
0c6afd1d01
commit
7a495aff30
2 changed files with 25 additions and 7 deletions
|
@ -57,7 +57,11 @@
|
|||
margin-bottom: 5px;
|
||||
|
||||
list-style-type: none;
|
||||
font-size: 120%;
|
||||
font-size: 1.2rem;
|
||||
|
||||
ul {
|
||||
padding-left: 1.5rem;
|
||||
}
|
||||
|
||||
a:link {
|
||||
color: #000;
|
||||
|
|
|
@ -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() {
|
||||
const rendition = this.rendition;
|
||||
|
||||
|
@ -67,12 +86,7 @@ export default class TableOfContents {
|
|||
tocHtml += '</div>';
|
||||
tocHtml += '<ul class="toc">';
|
||||
rendition.book.navigation.forEach((chapter) => {
|
||||
tocHtml += '<li>';
|
||||
|
||||
// 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 += this.chapterTocItem(rendition.book, chapter);
|
||||
});
|
||||
|
||||
tocHtml += '</ul>';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue