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);
|
||||
|
|
|
|||
BIN
scaffolding/OEBPS/cover.png
Normal file
BIN
scaffolding/OEBPS/cover.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 332 KiB |
20
scaffolding/OEBPS/cover.xhtml
Normal file
20
scaffolding/OEBPS/cover.xhtml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Cover</title>
|
||||
<style>
|
||||
body {
|
||||
text-align: center;
|
||||
}
|
||||
img {
|
||||
max-width: 100%;
|
||||
height: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<img src="cover.png" alt="Worm"/>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue