Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ jobs:
uses: actions-rs/install@v0.1
with:
crate: mdbook
version: latest
version: 0.4.51
- name: Install mdbook-epub
run: cargo install --locked mdbook-epub --version 0.4.48

- name: Copy mdbook to cache directory
if: steps.cache-cargo.outputs.cache-hit != 'true'
Expand All @@ -78,6 +80,18 @@ jobs:
- name: Put new cargo binary directory into path
run: echo "~/cargo-bin" >> $GITHUB_PATH


- name: Build EPUB
working-directory: mdbook
run: mdbook-epub -s


- name: Copy EPUB to static directory
working-directory: mdbook
run: |
mkdir -p src/static
cp book/epub/*.epub src/static/

- name: Build book
working-directory: mdbook
run: mdbook build
Expand Down
1 change: 1 addition & 0 deletions mdbook/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/book
/static
15 changes: 15 additions & 0 deletions mdbook/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,18 @@ language = "en"

[output.html]
git-repository-url = "https://github.com/rust-embedded/discovery-mb2/"
additional-js = ["epub-link.js"]
# additional-css = ["custom.css"]


[output.epub]
# Optional settings
title = "Discovery"
author = "Rust Embedded Resources Team"

[output.html.site]
url = "/"
# Optional settings
# base-url = "/discovery-mb2/"
# git-repository-url = "

13 changes: 13 additions & 0 deletions mdbook/epub-link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
window.addEventListener('DOMContentLoaded', () => {
const rightButtons = document.querySelector(".right-buttons");
if (!rightButtons) return;

const epubLink = document.createElement("a");
epubLink.href = "/static/Discovery.epub";
epubLink.textContent = "📘ePUB";
epubLink.download = "Discovery.epub"; // force download
epubLink.classList.add("epub-download");

rightButtons.appendChild(epubLink);
});

4 changes: 4 additions & 0 deletions mdbook/src/DOWNLOAD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# 📥 download ePUB version of the book


You can download the EPUB version of this book here: [Download](/static/Discovery.epub)
2 changes: 1 addition & 1 deletion mdbook/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
- [What's left for you to explore](explore.md)

---

[Download epub version of the book](DOWNLOAD.md)
[General troubleshooting](appendix/1-general-troubleshooting/README.md)
[How to use GDB](appendix/2-how-to-use-gdb/README.md)
[Magnetometer calibration](appendix/3-mag-calibration/README.md)
Expand Down
Loading