hammer / test-book

https://blissful-einstein-69cf1e.netlify.com/
0 stars 0 forks source link

Build with Travis, publish to Netlify #1

Open hammer opened 5 years ago

hammer commented 5 years ago

Bookdown project template

Configuration

_bookdown.yml

book_filename: "test-book"
delete_merged_file: true
language:
  ui:
    chapter_name: "Chapter "

Our book also has:

_output.yml

bookdown::gitbook:
  css: style.css
  config:
    toc:
      before: |
        <li><a href="./">A Minimal Book Example</a></li>
      after: |
        <li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li>
    download: ["pdf", "epub"]
bookdown::pdf_book:
  includes:
    in_header: preamble.tex
  latex_engine: xelatex
  citation_package: natbib
  keep_tex: yes
bookdown::epub_book: default

Our book doesn't use any of these settings, only (under bookdown::gitbook:):

index.Rmd preamble

title: "A Minimal Book Example"
author: "Yihui Xie"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
bibliography: [book.bib, packages.bib]
biblio-style: apalike
link-citations: yes
description: "This is a minimal example of using the bookdown package to write a book. The output format for this example is bookdown::gitbook."

Our book adds

Here's an R chunk to get the cover image in index.Rmd:

```{r fig.align='center', echo=FALSE, include=identical(knitr:::pandoc_to(), 'html')}
knitr::include_graphics('images/cover.png', dpi = NA)


## Build
When we built the book (`Ctrl+Shift+B`), we get:
- `packages.bib`
- `_book/`
- `_bookdown_files/`

Add these all to `.gitignore`
hammer commented 5 years ago

First lesson from first Travis build (7 min): use binary installs!

With caching, second build only took 2 minutes. Still...

hammer commented 5 years ago

NB: the download PDF and EPUB links don't work out of the box, not clear why...

hammer commented 5 years ago

Turns out Yihui added this capability to the demo a while back: https://github.com/rstudio/bookdown/issues/133

hammer commented 5 years ago

When I add an image in images/, it gets picked up locally and moved into _book. For some reason, it's not getting picked up by Netlify, as I don't see an images/ directory in the zip file. I don't think it's Netlify's fault as the image is < 1 MB (so probably not hitting a size restriction) and png files don't seem to be on Netlify's default exclude list. Will try to manually build again to see if it was maybe a caching issue?