mirror of
https://github.com/daniel-j/fimfic2epub.git
synced 2024-06-02 18:44:36 +12:00
Move non-linear items to the end of the book. Not all eReaders hide them, so this is an easy workaround
This commit is contained in:
parent
e221235367
commit
5111f5ec32
|
@ -77,6 +77,19 @@ export function createChapter (ch, html, callback) {
|
|||
})
|
||||
}
|
||||
|
||||
// some eReaders doesn't understand linear=no, so sort those items to the end of the spine/book.
|
||||
function sortItemsLinear (a, b) {
|
||||
let linearA = a.attrs.linear !== 'no'
|
||||
let linearB = b.attrs.linear !== 'no'
|
||||
if (linearA === linearB) {
|
||||
return 0
|
||||
} else if (linearA) {
|
||||
return -1
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
export function createOpf (ffc) {
|
||||
let remotes = []
|
||||
ffc.remoteResources.forEach((r, url) => {
|
||||
|
@ -128,7 +141,7 @@ export function createOpf (ffc) {
|
|||
m('itemref', {idref: 'nav', linear: ffc.storyInfo.chapters.length <= 1 ? 'no' : undefined})
|
||||
].concat(ffc.storyInfo.chapters.map((ch, num) =>
|
||||
m('itemref', {idref: 'chapter_' + zeroFill(3, num + 1)})
|
||||
))),
|
||||
)).sort(sortItemsLinear)),
|
||||
|
||||
m('guide', [
|
||||
m('reference', {type: 'cover', title: 'Cover', href: 'Text/cover.xhtml'}),
|
||||
|
|
Loading…
Reference in a new issue