Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Add cover to first page (cover doesn't show on eReaders) #64

Open
actuallymentor opened this issue Jul 28, 2018 · 1 comment
Open

Comments

@actuallymentor
Copy link
Contributor

I noticed that while apps like iBooks respect the cover in the meta, many eReaders (kobo) show the first page of the epub as the title page.

What this results in is the table of contents showing as the book thumbnail.

Is this a known issue?

I'm happy to do a PR for this functionality.

@Firsh
Copy link

Firsh commented Jul 21, 2022

You can create such a page manually, but you need to "register" it. So when you convert with Calibre to AZW3 it gets recognized therefore the Kindle doesn't show it twice.

{
  title: 'Cover',
  data: `<section epub:type="cover">` +
    `<div class="cover-image"><img alt="Cover" id="coverimage" src="${cover}"/></div>` +
    `</section>`,
  beforeToc: true,
  excludeFromToc: true,
  filename: 'cover.xhtml'
}

If you include it in the toc, you'll end up with a broken link in the AZW3. If you exclude it from the toc, epub-gen also excludes it from the ncx, making the page disappear. Therefore check the attached template (I modified it from the source) which fixes it.

Near the end where the toc is registered in guide, the cover needs to be there as well:

    <guide>
        <reference type="text" title="Table of Content" href="toc.xhtml"/>
        <reference href="cover.xhtml" title="Cover" type="cover"/>
    </guide>

Also, where the spine toc ncx begins notice I played with the conditions to reinclude the Cover-titled page:

    <spine toc="ncx">
        <% content.forEach(function(content, index){ %>
            <% if(content.beforeToc && (!content.excludeFromToc || content.title == 'Cover')){ %>
                <itemref idref="content_<%= index %>_<%= content.id %>"/>
            <% } %>
        <% }) %>
        <itemref idref="toc" />

Download modified template: content.opf.zip

Load it via the top-level option:

        customOpfTemplatePath: path.join(__dirname, 'content.opf.ejs'),

Daylon pushed a commit to Daylon/epub-gen that referenced this issue Sep 29, 2024
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants