Skip to content

Commit ee4e7ae

Browse files
cursoragentschacon
andcommitted
Add ebook download links to the site's book page
Link PDF/EPUB/FB2/HTML from /book/ to the GitHub release assets that release-on-merge.yml attaches on every merge to main, via the stable releases/latest/download URLs. MOBI is not linked because the build does not actually produce it. Co-authored-by: Scott Chacon <schacon@gmail.com>
1 parent 932b622 commit ee4e7ae

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

‎site/src/pages/book/index.astro‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
import Base from '../../layouts/Base.astro';
33
import { url } from '../../lib/url';
44
import book from '../../generated/book.json';
5+
6+
// Ebook files are attached to a GitHub release on every merge to main
7+
// (see .github/workflows/release-on-merge.yml); "latest" always points there.
8+
const downloadBase = 'https://github.com/progit/progit3/releases/latest/download';
9+
const downloads = [
10+
{ label: 'PDF', file: 'progit.pdf' },
11+
{ label: 'EPUB', file: 'progit.epub' },
12+
{ label: 'FB2', file: 'progit.fb2.zip' },
13+
{ label: 'HTML', file: 'progit.html' },
14+
];
515
---
616

717
<Base title="Read Pro Git online — Table of Contents" description="The complete Pro Git book, one page per section. Free to read.">
@@ -14,6 +24,12 @@ import book from '../../generated/book.json';
1424
Read the whole book right here, one section at a time — or
1525
<a href={url('/search/')}>search it</a> for what you need.
1626
</p>
27+
<p class="downloads">
28+
Download:
29+
{downloads.map((d) => (
30+
<a href={`${downloadBase}/${d.file}`}>{d.label}</a>
31+
))}
32+
</p>
1733
<p class="rev">Built from the sources · rev {book.revnumber} · {book.revdate}</p>
1834
</div>
1935
</div>
@@ -63,6 +79,29 @@ import book from '../../generated/book.json';
6379
margin: 0 0 0.6rem;
6480
}
6581

82+
.downloads {
83+
color: var(--muted);
84+
font-size: 0.95rem;
85+
margin: 0 0 0.6rem;
86+
}
87+
88+
.downloads a {
89+
display: inline-block;
90+
margin-left: 0.35rem;
91+
padding: 0.1rem 0.6rem;
92+
border: 1px solid var(--border);
93+
border-radius: 999px;
94+
color: var(--accent);
95+
font-size: 0.85rem;
96+
text-decoration: none;
97+
}
98+
99+
.downloads a:hover {
100+
background: var(--accent);
101+
color: var(--bg);
102+
border-color: var(--accent);
103+
}
104+
66105
.rev {
67106
font-family: var(--mono);
68107
font-size: 0.78rem;

0 commit comments

Comments
 (0)