Add a cover
This commit is contained in:
parent
807a3f4349
commit
c82c5e31a3
3 changed files with 33 additions and 1 deletions
|
|
@ -17,6 +17,10 @@ life and limb, Taylor faces the dilemma of having to do the wrong things for the
|
|||
|
||||
const NCX_FILENAME = "toc.ncx";
|
||||
|
||||
const COVER_IMG_FILENAME = "cover.png";
|
||||
const COVER_XHTML_FILENAME = "cover.xhtml";
|
||||
const COVER_MIMETYPE = "image/png";
|
||||
|
||||
module.exports = function (scaffoldingPath, bookPath, contentPath, chaptersPath, manifestPath) {
|
||||
return Promise.all([
|
||||
cpr(scaffoldingPath, bookPath),
|
||||
|
|
@ -49,16 +53,24 @@ function writeOpf(chapters, contentPath) {
|
|||
<dc:creator opf:file-as="${BOOK_AUTHOR}" opf:role="aut">${BOOK_AUTHOR}</dc:creator>
|
||||
<dc:publisher>${BOOK_PUBLISHER}</dc:publisher>
|
||||
<dc:description>${BOOK_DESCRIPTION}</dc:description>
|
||||
<meta name="cover" content="cover-image"/>
|
||||
</metadata>
|
||||
|
||||
<manifest>
|
||||
${manifestChapters}
|
||||
<item id="ncx" href="${NCX_FILENAME}" media-type="application/x-dtbncx+xml"/>
|
||||
<item id="cover" href="${COVER_XHTML_FILENAME}" media-type="application/xhtml+xml"/>
|
||||
<item id="cover-image" href="${COVER_IMG_FILENAME}" media-type="${COVER_MIMETYPE}"/>
|
||||
${manifestChapters}
|
||||
</manifest>
|
||||
|
||||
<spine toc="ncx">
|
||||
<itemref idref="cover" linear="no"/>
|
||||
${spineChapters}
|
||||
</spine>
|
||||
|
||||
<guide>
|
||||
<reference type="cover" title="Cover" href="${COVER_XHTML_FILENAME}"/>
|
||||
</guide>
|
||||
</package>`;
|
||||
|
||||
return fs.writeFile(path.resolve(contentPath, "content.opf"), contents);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue