diff --git a/src/epub/epub.js b/src/epub/epub.js index b870cc8..2e6799f 100644 --- a/src/epub/epub.js +++ b/src/epub/epub.js @@ -167,6 +167,12 @@ class Epub extends Publication { this.displayOptions = await this.loadDisplayOptions(packaging); + if (packaging.coverImagePath) { + let cover = this.resources.get(this.resolve(packaging.coverPath)) + if (cover) { + cover.rel.push("cover-image") + } + } return this; } diff --git a/src/epub/packaging.js b/src/epub/packaging.js index 3f9a1b9..9436320 100644 --- a/src/epub/packaging.js +++ b/src/epub/packaging.js @@ -45,6 +45,7 @@ class Packaging { throw new Error("No Spine Found"); } + this.metadata = this.parseMetadata(metadataNode); this.manifest = this.parseManifest(manifestNode); this.navPath = this.findNavPath(manifestNode); this.ncxPath = this.findNcxPath(manifestNode, spineNode); @@ -56,7 +57,6 @@ class Packaging { this.spine = this.parseSpine(spineNode, this.manifest); this.uniqueIdentifier = this.findUniqueIdentifier(packageDocument); - this.metadata = this.parseMetadata(metadataNode); this.metadata.direction = spineNode.getAttribute("page-progression-direction"); @@ -121,7 +121,7 @@ class Packaging { var items = Array.prototype.slice.call(selected); //-- Create an object with the id as key - items.forEach(function (item) { + items.forEach((item) => { var id = item.getAttribute("id"), href = item.getAttribute("href") || "", type = item.getAttribute("media-type") || "", @@ -158,7 +158,7 @@ class Packaging { // var epubcfi = new EpubCFI(); //-- Add to array to maintain ordering and cross reference with manifest - items.forEach(function(item, index){ + items.forEach((item, index) => { const idref = item.getAttribute("idref"); const props = item.getAttribute("properties") || ""; const propArray = props.length ? props.split(" ") : []; diff --git a/src/publication/resource.js b/src/publication/resource.js index 894dfca..045bbbe 100644 --- a/src/publication/resource.js +++ b/src/publication/resource.js @@ -9,7 +9,7 @@ class Resource { if (item && !item.url) { throw new Error("Resource url is required."); } - if (item.rel || !Array.isArray(item.rel)) { + if (item.rel && !Array.isArray(item.rel)) { item.rel = [item.rel]; } this.data = {