Publish Ebook Preview
Overview
Use this skill to prepare an ebook project for EPUB upload and web preview publishing. Favor simple, reproducible build steps, clean EPUB packaging, and a restrained preview site that shows only the first half of the book while linking readers to Google Books for purchase.
Workflow
Inspect the repository structure before editing.
- Look for
src/ Markdown chapters, web/ static site files, epub/ EPUB source tree, and tools/build_epub.py or equivalent scripts.
- Read project instructions such as
AGENTS.md, BOOK_STRUCTURE.md, and validation scripts.
- Check
git status --short and preserve unrelated user changes.
Rebuild the EPUB deterministically.
- Prefer an existing build script, usually
python tools/build_epub.py.
- Keep the first ZIP entry as
mimetype, uncompressed, with content exactly application/epub+zip.
- Keep the EPUB package minimal: top-level entries should normally be only
mimetype, META-INF/, and OEBPS/.
- Include every
OEBPS/ resource in content.opf manifest.
- Prefer PNG/JPG cover images for Google Books compatibility. Avoid relying on SVG-only covers.
- Ensure
cover.xhtml, content.opf, nav.xhtml, and toc.ncx all point to the same cover resource.
- Use a stable
dc:identifier when regenerating a revised version of the same book.
Build the web preview with the first half of chapters.
- If the book has 10 chapters, expose chapters 1-5 as the preview.
- If chapter count differs, use the first
ceil(total / 2) chapters unless the user gives a specific preview range.
- Keep later chapters visible only as locked/listed items or omit their content, depending on the existing site pattern.
- Do not duplicate full paid-book content into the free preview site.
Add the Google Books purchase link at the end of chapter pages.
- Put the CTA after the visible chapter content, effectively on the last page/last section of each web chapter view.
- Use the project's existing CTA style and wording when present.
- The link should point directly to the Google Books purchase/detail URL supplied by the user or already used in the project.
- If no URL is available, leave a clear placeholder constant in the code and tell the user it needs the final Google Books URL.
Validate before finishing.
- Run the project validator if present, for example
python tools/validate_project.py.
- Parse XML/XHTML files in the EPUB when possible:
.xml, .opf, .ncx, .xhtml.
- Confirm ZIP contents do not include source-only files such as root-level cover source images.
- Confirm the web preview limit is implemented in code or data.
- If
epubcheck is installed, run it on the final .epub. If it is unavailable, state that clearly.
EPUB Build Notes
When writing or editing a build script:
with ZipFile(output_path, "w") as epub_zip:
epub_zip.write(epub_dir / "mimetype", "mimetype", compress_type=ZIP_STORED)
for file_path in sorted(epub_dir.rglob("*")):
if file_path.is_dir() or file_path.name in {output_path.name, "mimetype"}:
continue
epub_zip.write(file_path, file_path.relative_to(epub_dir).as_posix(), compress_type=ZIP_DEFLATED)
Add explicit exclusions for source-only assets, for example an original cover1.png copied into OEBPS/Images/cover.png.
For Google Books review, prefer:
OEBPS/Images/cover.png
- OPF manifest item:
media-type="image/png" properties="cover-image"
meta name="cover" content="cover-image"
cover.xhtml with <img src="../Images/cover.png" .../>
Web Preview Pattern
For JavaScript-driven static sites, look for code like:
const previewChapters = chapters.slice(0, 5);
Adjust 5 to the first half of the chapter count. If possible, compute it:
const previewCount = Math.ceil(chapters.length / 2);
const previewChapters = chapters.slice(0, previewCount);
Place the Google Books CTA after rendered chapter content, not before the reader reaches the chapter ending.
Final Response
Report:
- The final EPUB path and whether the filename was reused.
- The preview range, such as chapters 1-5 of 10.
- The Google Books link location in the web chapter flow.
- Validation commands run and whether
epubcheck was available.
1---2name: publish-ebook-preview3description: Build and validate EPUB packages and preview websites for ebook publishing projects, especially simple HTML/CSS/JS + Markdown book repos. Use when the user asks to regenerate an EPUB for Google Books/Google Play Books review, document the EPUB build process, publish a web preview using the first half of chapters, or add a final-page Google Books purchase link/CTA to online chapter pages.4---56# Publish Ebook Preview78## Overview910Use this skill to prepare an ebook project for EPUB upload and web preview publishing. Favor simple, reproducible build steps, clean EPUB packaging, and a restrained preview site that shows only the first half of the book while linking readers to Google Books for purchase.1112## Workflow13141. Inspect the repository structure before editing.15 - Look for `src/` Markdown chapters, `web/` static site files, `epub/` EPUB source tree, and `tools/build_epub.py` or equivalent scripts.16 - Read project instructions such as `AGENTS.md`, `BOOK_STRUCTURE.md`, and validation scripts.17 - Check `git status --short` and preserve unrelated user changes.18192. Rebuild the EPUB deterministically.20 - Prefer an existing build script, usually `python tools/build_epub.py`.21 - Keep the first ZIP entry as `mimetype`, uncompressed, with content exactly `application/epub+zip`.22 - Keep the EPUB package minimal: top-level entries should normally be only `mimetype`, `META-INF/`, and `OEBPS/`.23 - Include every `OEBPS/` resource in `content.opf` manifest.24 - Prefer PNG/JPG cover images for Google Books compatibility. Avoid relying on SVG-only covers.25 - Ensure `cover.xhtml`, `content.opf`, `nav.xhtml`, and `toc.ncx` all point to the same cover resource.26 - Use a stable `dc:identifier` when regenerating a revised version of the same book.27283. Build the web preview with the first half of chapters.29 - If the book has 10 chapters, expose chapters 1-5 as the preview.30 - If chapter count differs, use the first `ceil(total / 2)` chapters unless the user gives a specific preview range.31 - Keep later chapters visible only as locked/listed items or omit their content, depending on the existing site pattern.32 - Do not duplicate full paid-book content into the free preview site.33344. Add the Google Books purchase link at the end of chapter pages.35 - Put the CTA after the visible chapter content, effectively on the last page/last section of each web chapter view.36 - Use the project's existing CTA style and wording when present.37 - The link should point directly to the Google Books purchase/detail URL supplied by the user or already used in the project.38 - If no URL is available, leave a clear placeholder constant in the code and tell the user it needs the final Google Books URL.39405. Validate before finishing.41 - Run the project validator if present, for example `python tools/validate_project.py`.42 - Parse XML/XHTML files in the EPUB when possible: `.xml`, `.opf`, `.ncx`, `.xhtml`.43 - Confirm ZIP contents do not include source-only files such as root-level cover source images.44 - Confirm the web preview limit is implemented in code or data.45 - If `epubcheck` is installed, run it on the final `.epub`. If it is unavailable, state that clearly.4647## EPUB Build Notes4849When writing or editing a build script:5051```python52with ZipFile(output_path, "w") as epub_zip:53 epub_zip.write(epub_dir / "mimetype", "mimetype", compress_type=ZIP_STORED)54 for file_path in sorted(epub_dir.rglob("*")):55 if file_path.is_dir() or file_path.name in {output_path.name, "mimetype"}:56 continue57 epub_zip.write(file_path, file_path.relative_to(epub_dir).as_posix(), compress_type=ZIP_DEFLATED)58```5960Add explicit exclusions for source-only assets, for example an original `cover1.png` copied into `OEBPS/Images/cover.png`.6162For Google Books review, prefer:6364- `OEBPS/Images/cover.png`65- OPF manifest item: `media-type="image/png" properties="cover-image"`66- `meta name="cover" content="cover-image"`67- `cover.xhtml` with `<img src="../Images/cover.png" .../>`6869## Web Preview Pattern7071For JavaScript-driven static sites, look for code like:7273```javascript74const previewChapters = chapters.slice(0, 5);75```7677Adjust `5` to the first half of the chapter count. If possible, compute it:7879```javascript80const previewCount = Math.ceil(chapters.length / 2);81const previewChapters = chapters.slice(0, previewCount);82```8384Place the Google Books CTA after rendered chapter content, not before the reader reaches the chapter ending.8586## Final Response8788Report:8990- The final EPUB path and whether the filename was reused.91- The preview range, such as chapters 1-5 of 10.92- The Google Books link location in the web chapter flow.93- Validation commands run and whether `epubcheck` was available.